pe/coff: handle weak defined symbol for gc-sections.
bfd/ * coffgen.c (_bfd_coff_gc_mark_hook): Handle PE weak external symbols with a definition. (_bfd_coff_gc_mark_extra_sections): Fix typo. ld/ * testsuite/ld-pe/pe.exp: New test. * testsuite/ld-pe/weakdef-1.s: New test source. * testsuite/ld-pe/weakdef-1.d: New test.
This commit is contained in:
parent
436252de3e
commit
1fd6d11190
@ -1,3 +1,9 @@
|
|||||||
|
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>
|
2017-04-07 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* po/SRC-POTFILES.in: Regenerate.
|
* po/SRC-POTFILES.in: Regenerate.
|
||||||
|
@ -2785,8 +2785,22 @@ _bfd_coff_gc_mark_hook (asection *sec,
|
|||||||
case bfd_link_hash_common:
|
case bfd_link_hash_common:
|
||||||
return h->root.u.c.p->section;
|
return h->root.u.c.p->section;
|
||||||
|
|
||||||
case bfd_link_hash_undefined:
|
|
||||||
case bfd_link_hash_undefweak:
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2897,7 +2911,7 @@ _bfd_coff_gc_mark_extra_sections (struct bfd_link_info *info,
|
|||||||
asection *isec;
|
asection *isec;
|
||||||
bfd_boolean some_kept;
|
bfd_boolean some_kept;
|
||||||
|
|
||||||
if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour)
|
if (bfd_get_flavour (ibfd) != bfd_target_coff_flavour)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Ensure all linker created sections are kept, and see whether
|
/* Ensure all linker created sections are kept, and see whether
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
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>
|
2017-04-07 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* testsuite/ld-elf/mbind1a.d: Remove matches for PT_LOAD segments.
|
* testsuite/ld-elf/mbind1a.d: Remove matches for PT_LOAD segments.
|
||||||
|
@ -76,6 +76,8 @@ run_dump_test "longsecn-5"
|
|||||||
run_dump_test "orphan"
|
run_dump_test "orphan"
|
||||||
run_dump_test "orphan_nu"
|
run_dump_test "orphan_nu"
|
||||||
|
|
||||||
|
run_dump_test "weakdef-1"
|
||||||
|
|
||||||
run_dump_test "pr19803"
|
run_dump_test "pr19803"
|
||||||
set pr19803_dll {
|
set pr19803_dll {
|
||||||
{ "PR 19803: not exporting swept symbols"
|
{ "PR 19803: not exporting swept symbols"
|
||||||
|
8
ld/testsuite/ld-pe/weakdef-1.d
Normal file
8
ld/testsuite/ld-pe/weakdef-1.d
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#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
|
19
ld/testsuite/ld-pe/weakdef-1.s
Normal file
19
ld/testsuite/ld-pe/weakdef-1.s
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
.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
|
Loading…
Reference in New Issue
Block a user