* elf32-ppc.c (apuinfo_set): New static var.
(ppc_elf_begin_write_processing): Set it here, always create an
APUinfo section if there were any in the inputs.
(ppc_elf_write_section): Check apuinfo_set.
(ppc_elf_final_write_processing): Likewise.
ld/testsuite/
* ld-powerpc/apuinfo-nul.rd: New.
* ld-powerpc/apuinfo-nul1.s: New.
* ld-powerpc/powerpc.exp: Add it.
bfd/
2010-02-18 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_add_symbol_hook): Don't set
has_ifunc_symbols if the symbol comes from a shared library.
* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
* elf64-x86-64.c (elf64_x86_64_add_symbol_hook): Likewise.
ld/testsuite/
2010-02-18 H.J. Lu <hongjiu.lu@intel.com>
* ld-ifunc/ifunc.exp: Expect System V OSABI in dynamic
ifunc-using executable.
include/elf/
* ppc.h (R_PPC_RELAX32, R_PPC_RELAX32PC, R_PPC_RELAX32_PLT,
R_PPC_RELAX32PC_PLT): Delete.
(R_PPC_RELAX, R_PPC_RELAX_PLT, R_PPC_RELAX_PLTREL24): Define.
bfd/
* elf32-ppc.c (update_plt_info): Clear sec here when addend is
less than 32768..
(ppc_elf_check_relocs): ..rather than doing so here. Ignore new
relax relocs.
(ppc_elf_gc_sweep_hook): Don't segfault when symbol hiding has
removed plt_entry records.
(ppc_elf_tls_setup): Handle PIE calls to __tls_get_addr correctly.
(ppc_elf_tls_optimize): Likewise. Also dec __tls_get_addr refcount
when optimizing code using new tlsgd and tlsld marker relocs.
(ppc_elf_relax_section): Differentiate relaxed PLTREL24 relocs
from ADDR24 relocs using plt or glink. Don't clear the addend
for R_PPC_RELAX_PLTREL24.
(ppc_elf_relocate_section): Correctly handle addends on relaxed
PLTREL24 relocs.
* elf32-ppc.c (ppc_elf_relocate_section): Delete __tls_get_addr
symbol reference from relocs belonging to calls that are
optimized away.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_howto_raw): Make R_PPC_EMB_SDAI16 and
R_PPC_EMB_SDA2I16 complain_overflow_signed.
(create_sdata_sym): Pass info rather than htab.
Update all callers. Ensure symbols are hidden.
(ppc_elf_check_relocs): Allow SDAREL16 when shared.
(ppc_elf_size_dynamic_sections): When shared, equate _SDA_BASE_ to
_GLOBAL_OFFSET_TABLE_.
(elf_finish_pointer_linker_section): Don't assume that sdata base
symbol is always at 0x8000 offset. Don't subtract the addend here.
(is_static_defined): New function.
(ppc_elf_relocate_section): Verify symbol base used in SDA relocs
is statically defined. Clear addend for EMB_SDAI16 and EMB_SDA2I16
relocs. Downgrade error on unexpected section for EMB_SDA2REL
reloc symbols to a warning.
* elf32-ppc.c (shared_stub_entry, stub_entry): Use r12, not r11.
(ppc_elf_relax_section): Use symbol index to distinguish
relocatable stubs.
ld/testsuite/
* ld-powerpc/relax.s: New.
* ld-powerpc/relax.d: New.
* ld-powerpc/relaxr.d: New.
* ld-powerpc/powerpc.exp: Add new tests.
info for STT_GNU_IFUNC.
* elf32-ppc.c (ppc_elf_check_relocs): Count a needed plt entry
on got refs in case the symbol turns out to be ifunc.
(ppc_elf_gc_sweep_hook): Similarly.
(ppc_elf_adjust_dynamic_symbol): Adjust assertion.
(allocate_dynrelocs): Don't specially allocate got relocs for ifunc.
(ppc_elf_size_dynamic_sections): Likewise.
(ppc_elf_relocate_section): Likewise.
for local ifunc symbols in non-pie executables, regardless of
reloc type. Don't specially create ifunc dyn relocs. Tidy ifunc
code so that it's obvious that we only do anything special for
local ifunc syms.
(ppc_elf_gc_sweep_hook): Adjust to suit check_relocs changes.
(allocate_dynrelocs): Correct comment for syms defined in plt.
Don't specially allocate ifunc dyn relocs.
(ppc_elf_relax_section): Relax branches to ifunc plt entries too.
(ppc_elf_relocate_section): Set "relocation" value for ifunc
syms in non-pie executables. No specially allocated dyn relocs
for ifunc to write. Allow for local sym on R_PPC_RELAX32_PLT.
(ppc_elf_finish_dynamic_symbol): Set value of ifunc symbols in
a non-pie executable.
used by indirect function support. Count dynamic relocs for
ifunc syms.
(ppc_elf_adjust_dynamic_symbol): Tweak for ifunc.
(allocate_dynrelocs): Allocate all non-dynamic ifunc plt entries
in iplt and their relocs in reliplt. Don't make ifunc syms
dynamic. Allocate got entry relocs for non-dynamic ifunc in
reliplt. Handle other dynamic relocs for ifunc.
(ppc_elf_size_dynamic_sections): Alloc dyn relocs for static
ifunc in reliplt, likewise relocs for got against local ifunc.
Typo fix on reliplt size adjust.
(ppc_elf_relocate_section): Don't use plt scheme of allocating
relocs 1-1 with entries for iplt, instead just add using
reloc_count. Write got relocs and dyn relocs for ifunc to reliplt.
Error on invalid ifunc dyn relocs.
(ppc_elf_finish_dynamic_symbol): Adjust for non-dynamic ifunc plt
in iplt/reliplt.
* elf64-ppc.c (ppc64_elf_howto_raw): Add R_PPC64_JMP_IREL,
R_PPC64_REL16, R_PPC64_REL16_LO, R_PPC64_REL16_HI, R_PPC64_REL16_HA.
(ppc64_elf_reloc_type_lookup): Handle new relocs.
(ppc64_elf_check_relocs): Likewise. Count dyn relocs for ifunc.
(allocate_dynrelocs): As for elf32-ppc.c above.
(ppc64_elf_size_dynamic_sections): Likewise.
(ppc_build_one_stub): Put non-dynamic ifunc plt call stubs in iplt,
and their relocs in reliplt. Use R_PPC64_JMP_IREL.
(ppc_size_one_stub): Similarly.
(ppc64_elf_relocate_section): As for elf32-ppc.c above. Handle new
relocs too.
(ppc64_elf_finish_dynamic_symbol): As for elf32-ppc.c above.
(is_nonpic_glink_stub): New function.
(ppc_elf_get_synthetic_symtab): Check for last non-pic stub rather
than first pic one.
(struct ppc_elf_link_hash_table <glink_pltresolve>): Comment fix.
* ppc.h (R_PPC_TLSGD, R_PPC_TLSLD): Add new relocs.
* ppc64.h (R_PPC64_TLSGD, R_PPC64_TLSLD): Add new relocs.
bfd/
* reloc.c (BFD_RELOC_PPC_TLSGD, BFD_RELOC_PPC_TLSLD): New.
* section.c (struct bfd_section): Add has_tls_get_addr_call.
(BFD_FAKE_SECTION): Init new flag.
* ecoff.c (bfd_debug_section): Likewise.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elf32-ppc.c (ppc_elf_howto_raw): Add R_PPC_TLSGD and R_PPC_TLSLD.
(ppc_elf_reloc_type_lookup): Handle new relocs.
(ppc_elf_check_relocs): Set has_tls_get_addr_call on finding such
without marker relocs.
(ppc_elf_tls_optimize): Allow out-of-order __tls_get_addr relocs
if section has no old-style calls.
(ppc_elf_relocate_section): Set tls_mask for non-tls relocs too.
Don't try to optimize new-style __tls_get_addr call when handling
arg setup relocs. Instead do so for R_PPC_TLSGD and R_PPC_TLSLD
relocs.
* elf64-ppc.c (ppc64_elf_howto_raw): Add R_PPC64_TLSGD, R_PPC64_TLSLD.
(ppc64_elf_reloc_type_lookup): Handle new relocs.
(ppc64_elf_check_relocs): Set has_tls_get_addr_call on finding such
without marker relocs.
(ppc64_elf_tls_optimize): Allow out-of-order __tls_get_addr relocs
if section has no old-style calls. Set toc_ref for new relocs as
appropriate.
(ppc64_elf_relocate_section): Set tls_mask for non-tls relocs too.
Don't try to optimize new-style __tls_get_addr call when handling
arg setup relocs. Instead do so for R_PPC_TLSGD and R_PPC_TLSLD
relocs.
gas/
* config/tc-ppc.c (ppc_elf_suffix): Error if ppc32 tls got relocs
have non-zero addend.
(md_assemble): Parse args of __tls_get_addr calls.
(md_apply_fix): Handle BFD_RELOC_PPC_TLSGD and BFD_RELOC_PPC_TLSLD.
ld/testsuite/
* ld-powerpc/tlsmark.s, * ld-powerpc/tlsmark.d: New test.
* ld-powerpc/tlsmark32.s, * ld-powerpc/tlsmark32.d: New test.
* ld-powerpc/powerpc.exp: Run them.
add toc.symndx and toc.add.
(ppc64_elf_check_relocs): Don't set htab->tls_get_addr here.
Set up toc.add.
(get_tls_mask): Add toc_addend param, set from toc.add. Adjust all
callers.
(ppc64_elf_tls_setup): Set htab->tls_get_addr and tls_get_addr_fd.
(branch_reloc_hash_match): New function, extracted from..
(ppc64_elf_tls_optimize): ..here.
(ppc64_elf_relocate_section): Properly set addends when optimizing
tls sequences. Avoid unnecessary reading and writing of insns.
Only redo reloc when symbol changed. Bypass symbol checks when
using tlsld_got.
* elf32-ppc.c (ppc_elf_tls_setup): Correct comment.
(branch_reloc_hash_match): New function, extracted from..
(ppc_elf_tls_optimize): ..here.
(ppc_elf_relocate_section): Avoid unnecessary reading of insns.
Don't clear addend on zapped __tls_get_addr reloc.
given name matches the name of the reloc-containing section
associated with the given section.
(get_dynamic_reloc_section_name): New function. Computes the name
of the section that contains the dynamic relocs associated with
the given section.
(_bfd_elf_get_dynamic_reloc_section): New function. Returns a
pointer to the section containing the dynamic relocs associated
with the given section.
(_bfd_elf_make_dynamic_reloc_section): New function. Creates a
section to contain the dynamic relocs associated with a given
section.
* elf-bfd.h: Prototype the new functions.
* elf-m10300.c (mn10300_elf_check_relocs): Use new functions.
(mn10300_elf_final_link_relocs): Likewise.
* elf32-arm.c (reloc_section_p): Delete - replaced by new
functions.
(elf32_arm_final_link_relocate): Use new functions.
(elf32_arm_check_relocs): Likewise.
* elf32-cris.c (cris_elf_relocate_section): Likewise.
(elf_cris_check_relocs): Likewise.
* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
* elf32-i370.c (i370_elf_check_relocs): Likewise.
(i370_elf_relocate_section): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
(m32r_elf_check_relocs): Likewise.
* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
* elf32_ppc.c (ppc_elf_check_relocs): Likewise.
(ppc_elf_relocate_section): Likewise.
* elf32-s390.c (elf_s390_check_relocs): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
(sh_elf_check_relocs): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Likewise.
(elf_vax_relocate_section): Likewise.
* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
* elf64-s390.c (elf_s390_check_relocs): Likewise.
* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
* elf32-bfin.c (bfin_check_relocs): Remove redundant local
variable 'sreloc'.
(bfin_relocate_section): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
TLS_LD even when symbol is used with other TLS reloc types.
(ppc_elf_relocate_section): Bypass symbol checks when using tlsld_got.
Leave addend zero on LD DTPMOD dynamic reloc.
* elf32-ppc.c (SYM_VAL): Define. Use throughout to find symbol vma.
(ppc_elf_relocate_section): Correct GOT offset calculation.
(ppc_elf_finish_dynamic_symbol): Use PPC_HA and PPC_LO.
(ppc_elf_finish_dynamic_sections): Likewise. Error if
htab->elf.hgot symbol is not defined in htab->got section.
(ppc_elf_get_synthetic_symtab): New function.
(bfd_elf32_get_synthetic_symtab): Define.
* elf64-ppc.c (section_covers_vma): New function.
(ppc64_elf_get_synthetic_symtab): Generate sym@plt on glink branch
table entries, and __glink_PLTresolve on resolver stub.
(ppc64_elf_build_stubs): Rename __glink sym to __glink_PLTresolve.
* elf32-ppc.c (MUST_BE_DYN_RELOC): Delete.
(must_be_dyn_reloc): New function.
(ppc_elf_check_relocs): Don't set DF_STATIC_TLS for tprel relocs
in pies.
(ppc_elf_tls_optimize): Optimise pies.
(ppc_elf_relocate_section): Use a section symbol rather than no
symbol if possible for LD->IE TLS sequence, but don't error if
we must use no symbol.
* elf64-ppc.c (MUST_BE_DYN_RELOC): As for elf32-ppc.c.
(must_be_dyn_reloc): Likewise.
(ppc64_elf_check_relocs): Likewise.
(ppc64_elf_tls_optimize): Likewise.
(ppc64_elf_relocate_section): Likewise.
undefined symbols with internal or hidden visibility.
(ppc_elf_relocate_section): Likewise. Use SYMBOL_CALLS_LOCAL
rather than SYMBOL_REFERENCES_LOCAL on branches. Don't
return immediately on dynamic reloc error.