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.
keyword in c++.
* bfd/aoutx.h (NAME (aout, make_empty_symbol)): Rename variable
new to new_symbol.
* bfd/coffgen.c (coff_make_empty_symbol)
(coff_bfd_make_debug_symbol): Rename variable new to new_symbol.
* bfd/cpu-ia64-opc.c (ext_reg, ins_imms_scaled): Rename variable
new to new_insn.
* bfd/doc/chew.c (newentry, add_intrinsic): Rename variable new to
new_d.
* bfd/ecoff.c (_bfd_ecoff_make_empty_symbol): Rename variable new
to new_symbol.
* bfd/elf32-m68k.c (elf_m68k_get_got_entry_type): Rename argument
new to new_reloc.
* bfd/hash.c (bfd_hash_lookup): Rename variable new to new_string.
* bfd/ieee.c (ieee_make_empty_symbol): Rename variable new to
new_symbol.
* bfd/linker.c (bfd_new_link_order): Rename variable new to
new_lo.
* bfd/mach-o.c (bfd_mach_o_sizeof_headers): Rename variable new to
symbol.
* bfd/oasys.c (oasys_make_empty_symbol): Rename variable new to
new_symbol_type.
* bfd/pdp11.c (NAME (aout, make_empty_symbol)): Rename variable
new to new_symbol_type.
* bfd/plugin.c (bfd_plugin_make_empty_symbol): Rename variable new
to new_symbol.
* bfd/rs6000-core.c (CoreHdr, VmInfo): Rename union member new to
new_dump.
(read_hdr, rs6000coff_core_p)
(rs6000coff_core_file_matches_executable_p)
(rs6000coff_core_file_failing_command)
(rs6000coff_core_file_failing_signal): Updated function to use new
union member name.
* bfd/som.c (som_make_empty_symbol): Rename variable new to
new_symbol_type.
* bfd/syms.c (_bfd_generic_make_empty_symbol): Rename variable new
to new_symbol.
* bfd/tekhex.c (first_phase, tekhex_make_empty_symbol): Rename
variable new to new_symbol.
* binutils/nlmconv.c (main): Rename variable new to new_name.
* gas/config/tc-arm.c (insert_reg_alias): Rename variable new to
new_reg.
* gas/config/tc-dlx.c (parse_operand): Rename variable new to
new_pos.
* gas/config/tc-ia64.c (ia64_gen_real_reloc_type): Rename variable
new to newr.
* gas/config/tc-mcore.c (parse_exp, parse_imm): Rename variable
new to new_pointer.
* gas/config/tc-microblaze.c (parse_exp, parse_imm, check_got):
Change name from new to new_pointer.
* gas/config/tc-or32.c (parse_operand): Rename variable new to
new_pointer.
* gas/config/tc-pdp11.c (md_assemble): Rename variable new to
new_pointer.
* gas/config/tc-pj.c (alias): Change argument new to new_name.
* gas/config/tc-score.c (s3_build_score_ops_hsh): Rename variable
new to new_opcode. (s3_build_dependency_insn_hsh) Rename variable
new to new_i2n. (s3_convert): Rename variables old and new to
r_old and r_new.
* gas/config/tc-score7.c (s7_build_score_ops_hsh): Rename variable
new to new_opcode. (s7_build_dependency_insn_hsh): Rename variable
new to new_i2d. (s7_b32_relax_to_b16, s7_convert_frag): Rename
variables old and new to r_old and r_new.
* gas/config/tc-sh.c (parse_exp): Rename variable new to
new_pointer.
* gas/config/tc-sh64.c (shmedia_parse_exp): Rename variable new to
new_pointer.
* gas/config/tc-tic4x.c (tic4x_operand_parse): Rename variable new
to new_pointer.
* gas/config/tc-z8k.c (parse_exp): Rename variable new to
new_pointer.
* gas/listing.c (listing_newline): Rename variable new to new_i.
* ld/ldexp.c (exp_intop, exp_bigintop, exp_relop, exp_binop)
(exp_trinop, exp_unop, exp_nameop, exp_assop): Rename variable new
to new_e.
* ld/ldfile.c (ldfile_add_library_path): Rename variable new to
new_dirs. (ldfile_add_arch): Rename variable new to new_arch.
* ld/ldlang.c (new_statement, lang_final, lang_add_wild)
(lang_target, lang_add_fill, lang_add_data, lang_add_assignment)
(lang_add_insert): Rename variable new to new_stmt. (new_afile):
Added missing cast. (lang_memory_region_lookup): Rename variable
new to new_region. (init_os): Rename variable new to
new_userdata. (lang_add_section): Rename variable new to
new_section. (ldlang_add_undef): Rename variable new to
new_undef. (realsymbol): Rename variable new to new_name.
* opcodes/z8kgen.c (internal, gas): Rename variable new to new_op.
Updated sources to avoid using the identifier name "template",
which is a keyword in c++.
* bfd/elf32-arm.c (struct stub_def): Rename member template to
template_sequence. (arm_build_one_stub,
find_stub_size_and_template, arm_size_one_stub, arm_map_one_stub):
Rename variable template to template_sequence.
* bfd/elfxx-ia64.c (elfNN_ia64_relax_br, elfNN_ia64_relax_brl):
Rename variable template to template_val.
* gas/config/tc-arm.c (struct asm_cond, struct asm_psr, struct
asm_barrier_opt): Change member template to
template_name. (md_begin): Update code to reflect new member
names.
* gas/config/tc-i386.c (struct templates, struct _i386_insn)
(match_template, cpu_flags_match, match_reg_size, match_mem_size)
(operand_size_match, md_begin, i386_print_statistics, pi)
(build_vex_prefix, md_assemble, parse_insn, optimize_imm)
(optimize_disp): Updated code to use new names. (parse_insn):
Added casts.
* gas/config/tc-ia64.c (dot_template, emit_one_bundle): Updated
code to use new names.
* gas/config/tc-score.c (struct s3_asm_opcode): Renamed member
template to template_name. (s3_parse_16_32_inst, s3_parse_48_inst,
s3_do_macro_ldst_label, s3_build_score_ops_hsh): Update code to
use new names.
* gas/config/tc-score7.c (struct s7_asm_opcode): Renamed member
template to template_name. (s7_parse_16_32_inst,
s7_do_macro_ldst_label, s7_build_score_ops_hsh): Update code to
use new names.
* gas/config/tc-tic30.c (md_begin, struct tic30_insn)
(md_assemble): Update code to use new names.
* gas/config/tc-tic54x.c (struct _tic54x_insn, md_begin)
(optimize_insn, tic54x_parse_insn, next_line_shows_parallel):
Update code to use new names.
* include/opcode/tic30.h (template): Rename type template to
insn_template. Updated code to use new name.
* include/opcode/tic54x.h (template): Rename type template to
insn_template.
* opcodes/cris-dis.c (bytes_to_skip): Update code to use new name.
* opcodes/i386-dis.c (putop): Update code to use new name.
* opcodes/i386-gen.c (process_i386_opcodes): Update code to use
new name.
* opcodes/i386-opc.h (struct template): Rename struct template to
insn_template. Update code accordingly.
* opcodes/i386-tbl.h (i386_optab): Update type to use new name.
* opcodes/ia64-dis.c (print_insn_ia64): Rename variable template
to template_val.
* opcodes/tic30-dis.c (struct instruction, get_tic30_instruction):
Update code to use new name.
* opcodes/tic54x-dis.c (has_lkaddr, get_insn_size)
(print_parallel_instruction, print_insn_tic54x, tic54x_get_insn):
Update code to use new name.
* opcodes/tic54x-opc.c (tic54x_unknown_opcode, tic54x_optab):
Update type to new name.
2009-07-16 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_relocate_section): Don't get local
STT_GNU_IFUNC symbol for relocatable link.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
ld/testsuite/
2009-07-16 H.J. Lu <hongjiu.lu@intel.com>
* ld-ifunc/ifunc-5r-local-i386.d: New.
* ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
and ref_regular_nonweak comment.
* elflink.c (elf_link_output_extsym): Special case ifunc syms
when def_regular, not ref_regular.
(elf_link_add_object_symbols): Don't set needs_plt on ifunc syms,..
* elf32-i386.c (elf_i386_check_relocs): ..set it here instead..
* elf64-x86-64.c (elf64_x86_64_check_relocs): ..and here.
2009-06-19 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_tls_transition): Add a parameter,
r_symndx. Report local symbol name on error.
(elf_i386_check_relocs): Updated. Report local symbol name on
error.
(elf_i386_gc_sweep_hook): Updated.
(elf_i386_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_tls_transition): Add a parameter,
r_symndx. Report local symbol name on error.
(elf64_x86_64_check_relocs): Updated. Report local symbol name
on error.
(elf64_x86_64_gc_sweep_hook): Updated.
(elf64_x86_64_relocate_section): Likewise.
ld/testsuite/
2009-06-19 H.J. Lu <hongjiu.lu@intel.com>
* ld-i386/i386.exp: Run tlsgd2.
* ld-i386/tlsgd2.d: New.
* ld-i386/tlsgd2.s: Likewise.
* ld-x86-64/tlsgd3.d: Updated.
2009-06-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/10270
* elf32-i386.c (elf_i386_allocate_dynrelocs): Disallow
dynamic IFUNC pointer in non-shared object. Use .got.plt
for IFUNC definition in PIE.
(elf_i386_allocate_dynrelocs): Resolve IFUNC definition in
PIE locally.
* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Disallow
dynamic IFUNC pointer in non-shared object. Use .got.plt
for IFUNC definition in PIE.
(elf64_x86_64_relocate_section): Resolve IFUNC definition in
PIE locally.
ld/testsuite/
2009-06-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/10270
* ld-ifunc/ifunc-9-x86.d: New.
* ld-ifunc/ifunc-9-x86.s: Likewise.
* elf32-i386.c (elf_i386_relocate_section): Properly report
local symbol for unhandled relocation against STT_GNU_IFUNC
symbol.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Properly report
local symbol for unhandled relocation against STT_GNU_IFUNC
symbol.
* elf64-x86-64.c (elf64_x86_64_check_relocs): Likewise.
2009-06-06 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_link_hash_table): Add irelifunc.
(elf_i386_link_hash_table_create): Initialize irelifunc.
(elf_i386_check_relocs): Updated. Set up irelifunc for
shared objects.
(elf_i386_allocate_dynrelocs): Use irelifunc for dynamic
relocation for non-GOT reference of STT_GNU_IFUNC symbol in
shared objects.
(elf_i386_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_link_hash_table): Add irelifunc.
(elf64_x86_64_link_hash_table_create): Initialize irelifunc.
(elf64_x86_64_check_relocs): Updated. Set up irelifunc for
shared objects.
(elf64_x86_64_allocate_dynrelocs): Use irelifunc for dynamic
relocation for non-GOT reference of STT_GNU_IFUNC symbol in
shared objects.
(elf64_x86_64_relocate_section): Likewise.
* elf-bfd.h (_bfd_elf_create_static_ifunc_sections): Renamed to
...
(_bfd_elf_create_ifunc_sections): This.
* elflink.c (_bfd_elf_create_static_ifunc_sections): Renamd to
...
(_bfd_elf_create_ifunc_sections): This. Create .rel[a].ifunc
for shared objects.
ld/
2009-06-06 H.J. Lu <hongjiu.lu@intel.com>
* scripttempl/elf.sc: Add .rel.ifunc and .rela.ifunc.
* elf32-i386.c (elf_i386_check_relocs): Make room for dynamic
relocation for R_386_32 against STT_GNU_IFUNC symbol when
building shared object. Check info->executable instead of
!info->shared when setting non_got_ref.
(elf_i386_allocate_dynrelocs): Allocate dynamic relocation
for non-GOT reference of STT_GNU_IFUNC symbol in shared
object. Allocate GOT relocation agsinst STT_GNU_IFUNC
symbol if needed.
(elf_i386_relocate_section): Output dynamic relocation for
R_386_32 against STT_GNU_IFUNC symbol to get the real
function address when building shared object.
(elf_i386_finish_dynamic_symbol): Output R_386_GLOB_DAT
relocation for STT_GNU_IFUNC symbol in shared object.
* elf64-x86-64.c (elf64_x86_64_check_relocs): Make room for
dynamic relocation for R_X86_64_64 against STT_GNU_IFUNC
symbol when building shared object. Check info->executable
instead of !info->shared when setting non_got_ref.
(elf64_x86_64_allocate_dynrelocs): Allocate dynamic relocation
for non-GOT reference of STT_GNU_IFUNC symbol in shared
library. Allocate GOT relocation agsinst STT_GNU_IFUNC symbol
if needed.
(elf64_x86_64_relocate_section): Output dynamic relocation
for R_X86_64_64 against STT_GNU_IFUNC symbol to get the real
function address when building shared object.
(elf64_x86_64_finish_dynamic_symbol): Output R_X86_64_GLOB_DAT
relocation for STT_GNU_IFUNC symbol in shared object.
* elf32-i386.c (elf_i386_allocate_dynrelocs): Allocate
GOT entry for STT_GNU_IFUNC symbol with pointer equality.
(elf_i386_relocate_section): Adjust R_386_GOT32 relocation
against STT_GNU_IFUNC symbols for static executables.
(elf_i386_finish_dynamic_symbol): Load GOT entry with
PLT entry for STT_GNU_IFUNC symbol with pointer equality.
* elf64-x86-64.c (elf64_x86_64_allocate_dynrelocs): Allocate
GOT entry for STT_GNU_IFUNC symbol with pointer equality.
(elf64_x86_64_finish_dynamic_symbol): Load GOT entry with
PLT entry for STT_GNU_IFUNC symbol with pointer equality.
2009-04-30 Nick Clifton <nickc@redhat.com>
* common.h (STT_GNU_IFUNC): Define.
elfcpp
2009-04-30 Nick Clifton <nickc@redhat.com>
* (enum STT): Add STT_GNU_IFUNC.
gas
2009-04-30 Nick Clifton <nickc@redhat.com>
* config/obj-elf.c (obj_elf_type): Add support for a
gnu_indirect_function type.
* config/tc-i386.c (tc_i386_fix_adjustable): Do not adjust fixups
against indirect function symbols.
* doc/as.texinfo (.type): Document the support for the
gnu_indirect_function symbol type.
* NEWS: Mention the new feature.
gas/testsuite
2009-04-30 Nick Clifton <nickc@redhat.com>
* gas/elf/elf.exp: Extend type test to include an ifunc symbol.
Provide an alternative test for targets which do not support ifunc
symbols.
(type.s): Add entry for an ifunc symbol.
(type.e): Add ifunc entry to expected symbol dump.
(section2.e-armelf): Add entry for ifunc symbol.
(type-noifunc.s): New file.
(type-noifunc.e): New file.
bfd/
2009-04-30 Nick Clifton <nickc@redhat.com>
* elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs
section pointer.
(struct elf_obj_data): Add has_ifunc_symbols boolean.
* elf.c (swap_out_syms): Convert BSF_GNU_INDIRECT_FUNCTION flags
into a STT_GNU_IFUNC symbol type.
(_bfd_elf_is_function_type): Accept STT_GNU_IFUNC as a function
type.
(_bfd_elf_set_osabi): Set the osasbi field to ELFOSABI_LINUX if
the binary contains ifunc symbols.
* elfcode.h (elf_slurp_symbol_table): Translate the STT_GNU_IFUNC
symbol type into a BSF_GNU_INDIRECT_FUNCTION flag.
* elf32-i386.c (is_indirect_function): New function.
(elf_i386_check_relocs): Create an ifunc output section.
(allocate_dynrelocs): Create dynamic relocs in the ifunc output
section if necessary.
(elf_i386_relocate_section): Emit a reloc against an ifunc symbol
if necessary.
(elf_i386_add_symbol_hook): New function. Set the
has_ifunc_symbols field of the elf_obj_data structure if an ifunc
symbol is encountered.
(elf_backend_post_process_headers): Define.
(elf_backend_add_symbol_hook): Define.
(elf_i386_post_process_headers): Rename to
elf_i388_fbsd_post_process_headers.
* elf64-x86_64.c (IS_X86_64_PCREL_TYPE): New macro.
(is_indirect_function): New function.
(elf64_x86_64_check_relocs): Create an ifunc output section.
(allocate_dynrelocs): Create dynamic relocs in the ifunc output
section if necessary.
(elf64_x86_64_relocate_section): Emit a reloc against an ifunc
symbol if necessary.
(elf_i386_add_symbol_hook): Set the has_ifunc_symbols field of the
elf_obj_data structure if an ifunc symbol is encountered.
(elf_backend_post_process_headers): Define.
* elflink.c (_bfd_elf_adjust_dynamic_symbol): Always create a PLT
if we have ifunc symbols to handle.
(get_ifunc_reloc_section_name): New function. Computes the name
for an ifunc section.
(_bfd_elf_make_ifunc_reloc_section): New function. Creates a
section to hold ifunc relocs.
* syms.c (BSF_GNU_INDIRECT_FUNCTION): Define.
(bfd_print_symbol_vandf): Handle ifunc symbols.
(bfd_decode_symclass): Likewise.
* bfd-in2.h: Regenerate.
binutils
2009-04-30 Nick Clifton <nickc@redhat.com>
* readelf.c (dump_relocations): Display a relocation against an
ifunc symbol as if it were a function invocation.
(get_symbol_type): Handle STT_GNU_IFUNC.
ld
2009-04-30 Nick Clifton <nickc@redhat.com>
* NEWS: Mention support for IFUNC symbols.
ld/testsuite
2009-04-30 Nick Clifton <nickc@redhat.com>
* ld-ifunc: New directory.
* ld-ifunc/ifunc.exp: New file: Run the IFUNC tests.
* ld-ifunc/prog.c: New file.
* ld-ifunc/lib.c: New file.
PR ld/9938
* elf32-i386.c (elf_i386_check_tls_transition): Use strncmp
to check ___tls_get_addr.
* elf64-x86-64.c (elf64_x86_64_check_tls_transition): Use
strncmp to check __tls_get_addr.
* common.h (STT_IFUNC): Define.
elfcpp/
* elfcpp.h (enum STT): Add STT_IFUNC.
bfd/
* syms.c (struct bfd_symbol): Add new flag BSF_INDIRECT_FUNCTION.
Remove redundant flag BFD_FORT_COMM_DEFAULT_VALUE. Renumber flags
to remove gaps.
(bfd_print_symbol_vandf): Return 'i' for BSF_INDIRECT_FUNCTION.
(bfd_decode_symclass): Likewise.
* elf.c (swap_out_syms): Translate BSF_INDIRECT_FUNCTION into
STT_IFUNC.
(elf_find_function): Treat STT_IFUNC in the same way as STT_FUNC.
(_bfd_elf_is_function_type): Likewise.
* elf32-arm.c (arm_elf_find_function): Likewise.
(elf32_arm_adjust_dynamic_symbol): Likewise.
(elf32_arm_swap_symbol_in): Likewise.
(elf32_arm_additional_program_headers): Likewise.
* elf32-i386.c (is_indirect_symbol): New function.
(elf_i386_check_relocs): Also generate dynamic relocs for
relocations against STT_IFUNC symbols.
(allocate_dynrelocs): Likewise.
(elf_i386_relocate_section): Likewise.
* elf64-x86-64.c (is_indirect_symbol): New function.
(elf64_x86_64_check_relocs): Also generate dynamic relocs for
relocations against STT_IFUNC symbols.
(allocate_dynrelocs): Likewise.
(elf64_x86_64_relocate_section): Likewise.
* elfcode.h (elf_slurp_symbol_table): Translate STT_IFUNC into
BSF_INDIRECT_FUNCTION.
* elflink.c (_bfd_elf_adjust_dynamic_reloc_section): Add support
for STT_IFUNC symbols.
(get_ifunc_reloc_section_name): New function.
(_bfd_elf_make_ifunc_reloc_section): New function.
* elf-bfd.h (struct bfd_elf_section_data): Add indirect_relocs field.
* bfd-in2.h: Regenerate.
gas/
* config/obj-elf.c (obj_elf_type): Add support for STT_IFUNC type.
* doc/as.texinfo: Document new feature.
* NEWS: Mention new feature.
gas/testsuite/
* gas/elf/type.s: Add test of STT_IFUNC symbol type.
* gas/elf/type.e: Update expected disassembly.
* gas/elf/elf.exp: Update grep of symbol types.
ld/
* NEWS: Mention new feature.
* pe-dll.c (process_def_file): Replace use of redundant
BFD_FORT_COMM_DEFAULT_VALUE with 0.
* scripttempl/elf.sc: Add .rel.ifunc.dyn and .rela.ifunc.dyn
sections.
ld/testsuite/
* ld-mips-elf/reloc-1-n32.d: Updated expected output for reloc
descriptions.
* ld-mips-elf/reloc-1-n64.d: Likewise.
* ld-i386/ifunc.d: New test.
* ld-i386/ifunc.s: Source file for the new test.
* ld-i386/i386.exp: Run the new test.
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.
* elf32-i386.c (struct elf_i386_link_hash_table): Added field
tls_module_base.
(elf_i386_link_hash_table_create): Initialize it.
(elf_i386_always_size_sections): Set it.
(set_tls_module_base): New.
(elf_i386_relocate_sections): Call it.
* elf64-x86-64.c (struct elf64_x86_64_link_hash_table): Added
field tls_module_base.
(elf64_x86_64_link_hash_table_create): Initialize it.
(elf64_x86_64_always_size_sections): Set it.
(set_tls_module_base): New.
(elf64_x86_64_relocate_sections): Call it.
Reported by Cary Coutant <ccoutant@google.com>
ld/testsuite/ChangeLog:
* ld-i386/tlsbindesc.dd: Adjust incorrect expectations for LD to
LE relaxation.
* ld-x86-64/tlsbindesc.dd: Likewise.
* ld-i386/tlsbindesc.rd: Adjust address of _TLS_MODULE_BASE_.
* ld-x86-64/tlsbindesc.rd: Likewise.
Reported by Cary Coutant <ccoutant@google.com>
* elf-bfd.h (enum elf_object_id): New enum, used to identify
target specific extensions to the elf_obj_tdata structure.
(struct elf_obj_tdata): New field 'object_id'.
(elf_object_id, elf_program_header_size, elf_symtab_hdr): New
macros for accessing fields in the elf_obj_tdata structure.
(bfd_elf_mkobject): Rename to bfd_elf_make_generic_object.
(bfd_elf_allocate_object): New function.
* elf.c (bfd_elf_mkobject): Rename to bfd_elf_make_generic_object
and implement by calling bfd_elf_allocate_object.
(bfd_elf_allocate_object): New function: Allocates an
elf_obj_tdata structure, possibly with a target specific
extension.
* elfxx-target.h (bfd_elfNN_mkobject): Use
bfd_elf_make_generic_object as the default value.
* elf32-arm.c (elf32_arm_obj_tdata): Rename to elf_arm_obj_tdata
for consistency with other, similar structures.
(is_arm_elf): New macro. Checks a BFD to make sure that is an ARM
ELF bfd.
(elf32_arm_mkobject): Call bfd_elf_allocate_object.
(bfd_elf32_arm_vfp11_erratum_scan): Use is_arm_elf macro to check
the bfd being processed.
(bfd_elf32_arm_vfp11_fix_veneer_locations): Likewise.
(bfd_elf32_arm_set_target_relocs): Likewise.
(bfd_elf32_arm_final_link_relocate): Likewise.
(bfd_elf32_arm_copy_private_bfd_data): Likewise.
(bfd_elf32_arm_merge_eabi_attributes): Likewise.
(bfd_elf32_arm_merge_private_bfd_data): Likewise.
(bfd_elf32_arm_check_relocs): Likewise.
(bfd_elf32_arm_gc_mark_extra_sections): Likewise.
(bfd_elf32_arm_size_dynamic_sections): Likewise.
(bfd_elf32_arm_process_before_allocation): Use elf_symtab_hdr.
(bfd_elf32_arm_init_maps): Likewise.
(bfd_elf32_arm_final_link_relocate): Likewise.
(bfd_elf32_arm_relocate_section): Likewise.
(bfd_elf32_arm_gc_sweep_hook): Likewise.
(bfd_elf32_arm_check_relocs): Likewise.
(bfd_elf32_arm_size_dynamic_sections): Likewise.
* elf32-i386.c (elf_i386_mkobject): Call bfd_elf_allocate_object.
(is_i386_elf): New macro. Checks a BFD to make sure that is an x86
ELF bfd.
(elf_i386_check_relocs): Use is_i386_elf macro to check the bfd
being processed.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_check_relocs): Use elf_symtab_hdr.
(elf_i386_gc_sweep_hook): Likewise.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_mkobject): Call bfd_elf_allocate_object.
(elf_create_pointer_linker_section): Use is_ppc_elf_target to
verify that the bfd before accessing target specific fields.
(ppc_elf_check_relocs): Likewise.
(elf_finish_pointer_linker_section): Likewise.
(elf_create_pointer_linker_section): Use elf_symtab_hdr.
(ppc_elf_check_relocs): Likewise.
(ppc_elf_gc_sweep_hook): Likewise.
(ppc_elf_tls_optimize): Likewise.
(ppc_elf_size_dynamic_sections): Likewise.
(ppc_elf_relax_section): Likewise.
(ppc_elf_relocate_section): Likewise.
* elf32-s390.c (struct elf_s390_obj_tdata): Add a comment
reminding programmers to keep this structure in sync with the one
defined in elf64-s390.c.
(elf_s390_mkobject): Call bfd_elf_allocate_object.
(is_s390_elf): New macro. Checks a BFD to make sure that is an s390
ELF bfd.
(elf_s390_check_relocs): Use is_s390_elf macro to check the bfd
being processed.
(elf_s390_size_dynamic_sections): Likewise.
(elf_s390_relocate_section): Likewise.
(elf_s390_check_relocs): Use elf_symtab_hdr.
(elf_s390_gc_sweep_hook): Likewise.
(elf_s390_size_dynamic_sections): Likewise.
(elf_s390_relocate_section): Likewise.
* elf32-sh.c (sh_elf_mkobject): Call bfd_elf_allocate_object.
(is_sh_elf): New macro. Checks a BFD to make sure that is an SH
ELF bfd.
(sh_elf_size_dynamic_sections): Use is_sh_elf macro to check the
bfd being processed.
(sh_elf_relocate_section): Likewise.
(sh_elf_check_relocs): Likewise.
(sh_elf_copy_private_data): Likewise.
(sh_elf_relax_section): Use elf_symtab_hdr.
(sh_elf_size_dynamic_sections): Likewise.
(sh_elf_relocate_section): Likewise.
(sh_elf_get_relocated_section_contents): Likewise.
(sh_elf_gc_sweep_hook): Likewise.
(sh_elf_check_relocs): Likewise.
* elf64-alpha.c (elf64_alpha_mkobject): Call bfd_elf_allocate_object.
(is_alpha_elf): New macro. Checks a BFD to make sure that is an
Alpha ELF bfd.
(elf64_alpha_create_got_section): Use is_alpha_elf macro to check
the bfd being processed.
(elf64_alpha_create_dynamic_section): Likewise.
(elf64_alpha_check_relocs): Likewise.
(elf64_alpha_size_got_sections): Likewise.
(elf64_alpha_relax_section): Likewise.
(elf64_alpha_relocate_section): Likewise.
(elf64_alpha_final_link): Likewise.
(elf64_alpha_check_relocs): Use elf_symtab_hdr.
(elf64_alpha_relax_section): Likewise.
(elf64_alpha_relocate_section_r): Likewise.
(elf64_alpha_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_mkobject): Call bfd_elf_allocate_object.
(ppc64_elf_check_relocs): Use is_ppc64_elf_target to check the bfd
being processed.
(opd_entry_value): Likewise.
(allocate_dynrelocs): Likewise.
(ppc64_elf_relocate_section): Likewise.
(ppc64_elf_check_relocs): Use elf_symtab_hdr.
(opd_entry_value): Likewise.
(ppc64_elf_gc_sweep_hook): Likewise.
(get_sym_h): Likewise.
(ppc64_elf_edit_opd): Likewise.
(ppc64_elf_tls_optimize): Likewise.
(ppc64_elf_edit_toc): Likewise.
(ppc64_elf_size_dynamic_sections): Likewise.
(toc_adjusting_stub_needed): Likewise.
(ppc64_elf_size_stubs): Likewise.
(ppc64_elf_relocate_section): Likewise.
* elf64-s390.c (struct elf_s390_obj_tdata): Add a comment
reminding programmers to keep this structure in sync with the one
defined in elf32-s390.c.
(elf_s390_mkobject): Call bfd_elf_allocate_object.
(is_s390_elf): New macro. Checks a BFD to make sure that is an s390
ELF bfd.
(elf_s390_check_relocs): Use is_s390_elf macro to check the bfd
being processed.
(elf_s390_size_dynamic_sections): Likewise.
(elf_s390_relocate_section): Likewise.
(elf_s390_check_relocs): Use elf_symtab_hdr.
(elf_s390_gc_sweep_hook): Likewise.
(elf_s390_size_dynamic_sections): Likewise.
(elf_s390_relocate_section): Likewise.
* elf64-x86_64.c (elf64_x86_64_mkobject): Call bfd_elf_allocate_object.
(is_x86_64_elf): New macro. Checks a BFD to make sure that is an
x86_64 ELF bfd.
(elf64_x86_64_check_relocs): Use is_x86_64_elf macro to check the bfd
being processed.
(elf64_x86_64_size_dynamic_sections): Likewise.
(elf64_x86_64_relocate_section): Likewise.
(elf64_x86_64_check_relocs): Use elf_symtab_hdr.
(elf64_x86_64_gc_sweep_hook): Likewise.
(elf64_x86_64_size_dynamic_sections): Likewise.
(elf64_x86_64_relocate_section): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_mkobject): Call bfd_elf_allocate_object.
(is_sparc_elf): New macro. Checks a BFD to make sure that is a Sparc
ELF bfd.
(_bfd_sparc_elf_check_relocs): Use is_sparc_elf macro to check the
bfd being processed.
(_bfd_sparc_elf_gc_sweep_hook): Likewise.
(_bfd_sparc_elf_size_dynamic_sections): Likewise.
(_bfd_sparc_elf_check_relocs): Use elf_symtab_hdr.
(_bfd_sparc_elf_gc_sweep_hook): Likewise.
(_bfd_sparc_elf_size_dynamic_sections): Likewise.
(_bfd_sparc_elf_relocate_section): Likewise.