PR ld/20828: Reorder the symbol sweep stage of section GC
authorMaciej W. Rozycki <macro@imgtec.com>
Mon, 23 Jan 2017 11:38:20 +0000 (11:38 +0000)
committerMaciej W. Rozycki <macro@imgtec.com>
Tue, 24 Jan 2017 13:11:32 +0000 (13:11 +0000)
commitb531344c34b05fcd55ce65776ff50b9a752d60c1
tree12c0ee03f155bb1f6718ff7c6ffc50ced2de28b2
parent1a792e1c00e07a1e644145a9f71446cf2e75e9ab
PR ld/20828: Reorder the symbol sweep stage of section GC

Complement commit 81ff47b3a546 ("PR ld/20828: Fix linker script symbols
wrongly forced local with section GC") and move the symbol sweep stage
of section GC from `elf_gc_sweep' to `bfd_elf_size_dynamic_sections',
avoiding the need to clear the `forced_local' marker, problematic for
targets that have special processing in their `elf_backend_hide_symbol'
handler.  Set `mark' instead in `bfd_elf_record_link_assignment' and,
matching changes from commit 3bd43ebcb602 ("ld --gc-sections fail with
__tls_get_addr_opt"), also in PowerPC `__tls_get_addr_opt' handling
code, removing a:

FAIL: PR ld/20828 dynamic symbols with section GC (version script)

test suite failure with the `score-elf' target.

The rationale is it is enough if symbols are swept at the beginning of
`bfd_elf_size_dynamic_sections' as it is only in this function that the
size of the GOT, the dynamic symbol table and other dynamic sections is
determined, which will depend on the number of symbols making it to the
dynamic symbol table.  It is also appropriate to do the sweep at this
point as it is already after any changes have been made to symbols with
`bfd_elf_record_link_assignment', and not possible any earlier as calls
to that function are only made just beforehand -- barring audit entry
processing -- via `gld${EMULATION_NAME}_find_statement_assignment'
invoked from `gld${EMULATION_NAME}_before_allocation' which is the ELF
handler for `ldemul_before_allocation'.

bfd/
PR ld/20828
* elflink.c (bfd_elf_record_link_assignment): Revert last
change and don't ever clear `forced_local'.  Set `mark'
unconditionally.
(elf_gc_sweep_symbol_info, elf_gc_sweep_symbol): Reorder within
file.
(elf_gc_sweep): Move the call to `elf_gc_sweep_symbol'...
(bfd_elf_size_dynamic_sections): ... here.
* elf32-ppc.c (ppc_elf_tls_setup): Don't clear `forced_local'
and set `mark' instead in `__tls_get_addr_opt' processing.
* elf64-ppc.c (ppc64_elf_tls_setup): Likewise.
bfd/ChangeLog
bfd/elf32-ppc.c
bfd/elf64-ppc.c
bfd/elflink.c
This page took 0.025218 seconds and 4 git commands to generate.