+2017-04-07 gingold <gingold@gingold-Precision-7510>
+
+ * coffgen.c (_bfd_coff_gc_mark_hook): Handle PE weak
+ external symbols with a definition.
+ (_bfd_coff_gc_mark_extra_sections): Fix typo.
+
2017-04-07 Alan Modra <amodra@gmail.com>
* po/SRC-POTFILES.in: Regenerate.
case bfd_link_hash_common:
return h->root.u.c.p->section;
- case bfd_link_hash_undefined:
case bfd_link_hash_undefweak:
+ if (h->symbol_class == C_NT_WEAK && h->numaux == 1)
+ {
+ /* PE weak externals. A weak symbol may include an auxiliary
+ record indicating that if the weak symbol is not resolved,
+ another external symbol is used instead. */
+ struct coff_link_hash_entry *h2 =
+ h->auxbfd->tdata.coff_obj_data->sym_hashes[
+ h->aux->x_sym.x_tagndx.l];
+
+ if (h2 && h2->root.type != bfd_link_hash_undefined)
+ return h2->root.u.def.section;
+ }
+ break;
+
+ case bfd_link_hash_undefined:
default:
break;
}
asection *isec;
bfd_boolean some_kept;
- if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
+ if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour)
continue;
/* Ensure all linker created sections are kept, and see whether
+2017-04-07 gingold <gingold@gingold-Precision-7510>
+
+ * testsuite/ld-pe/pe.exp: New test.
+ * testsuite/ld-pe/weakdef-1.s: New test source.
+ * testsuite/ld-pe/weakdef-1.d: New test.
+
2017-04-07 Alan Modra <amodra@gmail.com>
* testsuite/ld-elf/mbind1a.d: Remove matches for PT_LOAD segments.
run_dump_test "orphan"
run_dump_test "orphan_nu"
+run_dump_test "weakdef-1"
+
run_dump_test "pr19803"
set pr19803_dll {
{ "PR 19803: not exporting swept symbols"
--- /dev/null
+#source: weakdef-1.s
+#target: i*86-*-cygwin* i*86-*-pe i*86-*-mingw*
+#ld: -e _start --gc-sections
+#objdump: -d
+
+#...
+ 401003: a1 00 20 40 00 mov 0x402000,%eax
+#pass
--- /dev/null
+ .weak _wsym
+ .section .data$wsym,"w"
+ .align 4
+_wsym:
+ .long 1
+
+ .section .text$start,"x"
+ .globl _start
+ .def _start; .scl 2; .type 32; .endef
+_start:
+ pushl %ebp
+ movl %esp, %ebp
+ movl _wsym, %eax
+ testl %eax, %eax
+ sete %al
+ movzbl %al, %eax
+ nop
+ popl %ebp
+ ret