* elf-bfd.h (ELF_LINK_POINTER_EQUALITY_NEEDED): Define new flag.
* elf.c (_bfd_elf_link_hash_copy_indirect): Copy it.
* elf32-i386.c (elf_i386_copy_indirect_symbol): Likewise.
(elf_i386_check_relocs): Set it.
(elf_i386_finish_dynamic_symbol): If it is not set,
clear st_value of SHN_UNDEF symbol.
* elfxx-ia64.c (struct elfNN_ia64_link_hash_table): Add rel_fptr_sec.
(elfNN_ia64_dynamic_symbol_p): Change info->shared into
!info->executable.
(get_fptr): For -pie create .opd as writable section and create
.rela.opd as well.
(elfNN_ia64_check_relocs): Change info->shared into
!info->executable.
(allocate_fptr): Likewise.
(allocate_dynrel_entries): Account for a relative reloc for -pie
@fptr(). Don't account for a relative reloc if -pie want_ltoff_fptr
for undefweak symbol. Account for an IPLT reloc in .rela.opd
section if -pie.
(set_got_entry): Don't create a relative reloc if -pie
want_ltoff_fptr for undefweak symbol.
(set_fptr_entry): Emit an IPLT reloc in .rela.opd for -pie.
(elfNN_ia64_relocate_section): Emit a relative reloc for -pie
@fptr().
* elfxx-ia64.c (elfNN_ia64_relocate_section): Issue undefined_symbol
even if -pie.
* elf32-i386.c (elf_i386_relocate_section): Likewise.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
* elf64-s390.c (elf_s390_relocate_section): Likewise.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
* elf32-s390.c (elf_s390_relocate_section): Likewise.
* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
ld/
* emulparams/elf64_ia64.sh (OTHER_READONLY_SECTIONS): Don't include
.opd if -pie.
(OTHER_READWRITE_SECTIONS): Include .opd if -pie.
* scripttempl/elf.sc: Use SHLIB_DATA_ADDR instead of DATA_ADDR
if -pie.
elf32-ppc.c. Add ELF_LINK_FORCED_LOCAL check.
* elf32-ppc.c: (SYMBOL_REFERENCES_LOCAL, SYMBOL_CALLS_LOCAL): Delete.
(allocate_dynrelocs): Use SYMBOL_REFERENCES_LOCAL for dynreloc check.
(ppc_elf_relocate_section): Likewise.
* elf64-ppc.c (allocate_dynrelocs): Likewise.
(ppc64_elf_relocate_section): Likewise. Use for .got relocs too.
(ppc64_elf_adjust_dynamic_symbol): Don't assume symbols with .plt
relocs need no other types.
* elf32-i386.c (allocate_dynrelocs): Use SYMBOL_REFERENCES_LOCAL for
dynreloc check.
(elf_i386_relocate_section): Likewise. Use for .got relocs too.
(elf_i386_finish_dynamic_symbol): Use SYMBOL_REFERENCES_LOCAL for
.got relocs.
non-default visibility, a) don't make them dynamic, b) discard
space for dynamic relocs.
* elf64-x86-64.c (allocate_dynrelocs): Likewise.
* elf32-ppc.c (allocate_dynrelocs): For undef weak syms with
non-default visibility, a) don't allocate plt entries, b) don't
allocate .got relocs, c) discard dyn rel space,
(ppc_elf_relocate_section): d) don't generate .got relocs, e)
don't generate dynamic relocs.
* elf64-ppc.c (allocate_dynrelocs): As above.
(ppc64_elf_relocate_section): As above.
weakdef sym has already been adjusted before treating it specially.
* elf32-i386.c (elf_i386_copy_indirect_symbol): Don't copy
ELF_LINK_NON_GOT_REF for weakdefs when symbol already adjusted.
* elf64-ppc.c (ppc64_elf_copy_indirect_symbol): Likewise.
(ppc64_elf_check_relocs): Set ELF_LINK_NON_GOT_REF.
(ppc_elf_adjust_dynamic_symbol): For weak symbols, copy
ELF_LINK_NON_GOT_REF from weakdef.
* elf64-ppc.c (ELIMINATE_COPY_RELOCS): Define as one.
(ppc64_elf_adjust_dynamic_symbol): For weak symbols, copy
ELF_LINK_NON_GOT_REF from weakdef.
* elf32-i386.c (ELIMINATE_COPY_RELOCS): Define as one. Use throughout.
(elf_i386_adjust_dynamic_symbol): For weak symbols, copy
ELF_LINK_NON_GOT_REF from weakdef.
to DT_JMPREL. Use srelplt input section size for DT_PLTRELSZ and
DT_RELSZ adjustment, not output section. Avoid writing tags when
unchanged. Don't assume linker script is sane, adjust DT_REL too.
* elf32-hppa.c (elf32_hppa_finish_dynamic_sections): Just use raw
size of srelplt for DT_PLTRELSZ. Use srelplt input section size for
DT_RELASZ adjustment, not output section. Avoid writing tags when
unchanged. Adjust DT_RELA.
* elf64-ppc.c (ppc64_elf_finish_dynamic_sections): Tweaks for better
formatting. Avoid writing tags when unchanged. Adjust DT_RELA.
* reloc.c (BFD_RELOC_386_TLS_TPOFF, BFD_RELOC_386_TLS_IE,
BFD_RELOC_386_TLS_GOTIE): Add.
* bfd-in2.h, libbfd.h: Rebuilt.
* elf32-i386.c (elf_howto_table): Add R_386_TLS_TPOFF, R_386_TLS_IE
and R_386_TLS_GOTIE.
(elf_i386_reloc_type_lookup): Handle it.
(struct elf_i386_link_hash_entry): Change tls_type type to unsigned
char instead of enum, change GOT_* into defines.
(GOT_TLS_IE_POS, GOT_TLS_IE_NEG, GOT_TLS_IE_BOTH): Define.
(elf_i386_tls_transition): Handle R_386_TLS_IE and R_386_TLS_GOTIE.
(elf_i386_check_relocs): Likewise. Avoid crash if local symbol is
accessed both as normal and TLS symbol. Move R_386_TLS_LDM and
R_386_PLT32 cases so that R_386_TLS_IE can fall through.
Handle R_386_TLS_LE_32 and R_386_TLS_LE in shared libs.
(elf_i386_gc_sweep_hook): Handle R_386_TLS_IE and R_386_TLS_GOTIE.
Handle R_386_TLS_LE_32 and R_386_TLS_LE in shared libs.
(allocate_dynrelocs): Allocate 2 .got and 2 .rel.got entries if
tls_type is GOT_TLS_IE_BOTH.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Handle R_386_TLS_IE and R_386_TLS_GOTIE.
Handle R_386_TLS_LE_32 and R_386_TLS_LE in shared libs.
(elf_i386_finish_dynamic_symbol): Use tls_type & GOT_TLS_IE to catch
all 4 GOT_TLS_* TLS types.
gas/
* config/tc-i386.c (tc_i386_fix_adjustable): Handle
BFD_RELOC_386_TLS_IE and BFD_RELOC_386_TLS_GOTIE.
(BFD_RELOC_386_TLS_IE, BFD_RELOC_386_TLS_GOTIE): Define to 0
if not defined.
(lex_got): Handle @GOTNTPOFF and @INDNTPOFF.
(md_apply_fix3, tc_gen_reloc): Handle BFD_RELOC_386_TLS_IE and
BFD_RELOC_386_TLS_GOTIE.
gas/testsuite/
* gas/i386/tlspic.s: Add tests.
* gas/i386/tlspic.d: Regenerated.
* gas/i386/tlsnopic.s: Add tests.
* gas/i386/tlsnopic.d: Regenerated.
include/
* elf/i386.h (R_386_TLS_TPOFF, R_386_TLS_IE, R_386_TLS_GOTIE):
Define.
ld/testsuite/
* ld-i386/i386.exp: New.
* ld-i386/tlsbin.dd: New test.
* ld-i386/tlsbinpic.s: New test.
* ld-i386/tlsbin.rd: New test.
* ld-i386/tlsbin.s: New test.
* ld-i386/tlsbin.sd: New test.
* ld-i386/tlsbin.td: New test.
* ld-i386/tlslib.s: New test.
* ld-i386/tlsnopic1.s: New test.
* ld-i386/tlsnopic2.s: New test.
* ld-i386/tlsnopic.dd: New test.
* ld-i386/tlsnopic.rd: New test.
* ld-i386/tlsnopic.sd: New test.
* ld-i386/tlspic1.s: New test.
* ld-i386/tlspic2.s: New test.
* ld-i386/tlspic.dd: New test.
* ld-i386/tlspic.rd: New test.
* ld-i386/tlspic.sd: New test.
* ld-i386/tlspic.td: New test.
* elf32-i386.c: Don't defined ELF_ARCH etc. if this file is included
by a target variant implementation.
* elf64-alpha.c: Likewise.
* elf32-i386-fbsd.c: New file.
* elf64-alpha-fbsd.c: New file.
* targets.c: Support bfd_elf32_i386_freebsd_vec and
bfd_elf64_alpha_freebsd_vec.
* configure.in: Accept the vectors bfd_elf32_i386_freebsd_vec,
bfd_elf64_alpha_freebsd_vec.
* Makefile.am (BFD32_BACKENDS): Add elf32-i386-fbsd.lo.
(BFD32_BACKENDS_CFILES): Add elf32-i386-fbsd.c.
(BFD64_BACKENDS): Add elf64-alpha-fbsd.lo.
(BFD64_BACKENDS_CFILES): Add elf64-alpha-fbsd.c.
(elf32-i386-fbsd.lo, elf64-alpha-fbsd.lo): Add dependencies.
* config.bfd: For FreeBSD targets, set targ_defvec to a FreeBSD
specific targets. Define OLD_FREEBSD_ABI_LABEL if appropriate.
* config/tc-i386.h (ELF_TARGET_FORMAT): New macro.
(TARGET_FORMAT): Use ELF_TARGET_FORMAT instead of "elf32-i386".
* config/tc-i386.c (i386_target_format): Likewise.
* config/tc-alpha.h (ELF_TARGET_FORMAT): New macro.
(TARGET_FORMAT): Use ELF_TARGET_FORMAT instead of "elf64-alpha".
* emulparams/elf_i386_fbsd.sh: Set OUTPUT_FORMAT to
elf32-i386-freebsd.
* emulparams/elf64alpha_fbsd.sh: Set OUTPUT_FORMAT to
elf64-alpha-freebsd.
Approved by: Alan Modra <amodra@bigpond.net.au>
Message-ID: <20020715021113.GJ30362@bubble.sa.bigpond.net.au>
against section syms in readonly sections. Don't do the global
sym check if we find one.
* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
(elf_s390_grok_prstatus): Add missing prototype.
include/elf/ChangeLog
* external.h (Elf_External_Sym_Shndx): Declare.
* internal.h (struct elf_internal_sym <st_shndx>): Make it an
unsigned int.
* common.h (SHN_BAD): Define.
bfd/ChangeLog
* configure.in: Bump bfd version.
* configure: Regenerate.
* elf-bfd.h (elf_size_info <swap_symbol_out>): Add shndx param.
(bfd_elf32_swap_symbol_in): Likewise.
(bfd_elf32_swap_symbol_out): Likewise.
(bfd_elf64_swap_symbol_in): Likewise.
(bfd_elf64_swap_symbol_out): Likewise.
(elf_reloc_cookie): Add locsym_shndx field. Make locsyms a PTR.
(elf_obj_tdata): Add num_elf_sections, symtab_shndx_hdr and
symtab_shndx_section.
(elf_numsections): Define.
(elf_symtab_shndx): Define.
* elf.c (setup_group): Use elf_numsections rather than header e_shnum.
(bfd_elf_find_section): Likewise.
(bfd_section_from_elf_index): Likewise.
(bfd_section_from_shdr): Likewise. Handle SHT_SYMTAB_SHNDX.
(bfd_section_from_r_symndx): Read symbol shndx extension, and
translate st_shndx for > SHN_HIRESERVE.
(assign_section_numbers): Skip reserved sections. Assign
symtab_shndx_section and elf_numsections. Exclude reserved
sections from e_shnum. Set up symtab_shndx_hdr.
(_bfd_elf_compute_section_file_positions): Handle symtab_shndx_hdr.
(map_sections_to_segments): Don't map eh_frame_hdr unless required.
(assign_file_positions_except_relocs): Use elf_numsections rather
than header e_shnum. Skip reserved sections and symtab_shndx_section.
(prep_headers): Set name for symtab_shndx_hdr.
(_bfd_elf_assign_file_positions_for_relocs): Use elf_numsections.
(_bfd_elf_write_object_contents): Likewise. Skip reserved sections.
(_bfd_elf_section_from_bfd_section): Check bfd_{abs,com,und}_section
first. Use elf_section_data if available. Use elf_numsections.
Start scan at index 1.
(copy_private_bfd_data ): Comment fixes.
(MAP_ONESYMTAB): Define above SHN_HIOS.
(MAP_DYNSYMTAB): Likewise.
(MAP_STRTAB): Likewise.
(MAP_SHSTRTAB): Likewise.
(MAP_SYM_SHNDX): New define.
(_bfd_elf_copy_private_symbol_data): Handle symtab_shndx_section.
(swap_out_syms): Swap out SHT_SYMTAB_SHNDX section too.
* elfcode.h (elf_swap_symbol_in): Add shndx param, and handle shndx
extension.
(elf_swap_symbol_out): Likewise.
(elf_object_p): Set elf_numsections, and use instead of e_shnum.
Initialialise reserved elf_elfsections to point at shdr[0]. Remove
redundant bfd_release calls.
(elf_slurp_symbol_table): Read symbol shndx extension, and use with
elf_swap_symbol_in. Translate st_shndx for > SHN_HIRESERVE too.
* elflink.h (elf_link_is_defined_archive_symbol): Read symbol shndx
extension, and use with elf_swap_symbol_in.
(elf_link_record_local_dynamic_symbol): Likewise.
(elf_link_add_object_symbols): Likewise. Also translate st_shndx
for elf sections > SHN_HIRESERVE.
(NAME(bfd_elf,size_dynamic_sections)): Adjust elf_swap_symbol_out
call.
(struct elf_final_link_info): Add locsym_shndx and symshndxbuf.
(elf_bfd_final_link): Allocate the above, and tidy code allocating
other buffers. Use elf_numsections instead of e_shnum. Adjust
elf_swap_symbol_out calls.
(elf_link_output_sym): Swap out symbol shndx extension too.
(elf_link_flush_output_syms): And flush them to disk.
(elf_link_output_extsym): Use SHN_BAD. Adjust elf_swap_symbol_out
calls.
(elf_gc_mark): Read symbol shndx extension, and use with
elf_swap_symbol_in.
(elf_link_input_bfd): Likewise, Translate st_shndx for elf sections
> SHN_HIRESERVE too. Use SHN_BAD.
(elf_reloc_symbol_deleted_p): Use symbol shndx extensions with
elf_swap_symbol_in. Translate st_shndx > SHN_HIRESERVE too.
(elf_bfd_discard_info): Read symbol shndx extension. Don't attempt
to continue after a bfd error.
* elf-m10200.c (mn10200_elf_relax_section): Only read local syms.
Stash them immediately to symtab_hdr->contents rather than later
in multiple places. Clean up afterwards. Read symbol shndx
extension, and use with swap_symbol_in. Translate SHN_UNDEF,
SHN_ABS, SHN_COMMON and elf sections > SHN_HIRESERVE to bfd
sections too. Remove dead code.
(mn10200_elf_relax_delete_bytes): Use symbol shndx extension
when swapping in symbols. Tidy code adjusting global syms.
Don't swap in global syms.
(mn10200_elf_symbol_address_p): Likewise. Remove extsyms param.
(mn10200_elf_get_relocated_section_contents): Read symbol shndx
extension, and use with swap_symbol_in. Rename "size" -> "amt"
to maximize code in common with other files. Translate st_shndx
for > SHN_HIRESERVE too. Remove dead code.
* elf-m10300.c (mn10300_elf_relax_section): Only read local syms.
Stash them immediately to symtab_hdr->contents rather than later
in multiple places. Clean up afterwards. Read symbol shndx
extension, and use with swap_symbol_in. Remove dead code.
(mn10300_elf_relax_delete_bytes): As for elf-m10200.c.
(mn10300_elf_symbol_address_p): Likewise.
(mn10300_elf_get_relocated_section_contents): Likewise.
* elf32-h8300.c (elf32_h8_relax_section): As for elf-m10300.c.
(elf32_h8_relax_delete_bytes): Likewise.
(elf32_h8_symbol_address_p): Likewise.
(elf32_h8_get_relocated_section_contents): Likewise.
* elf32-hppa.c (elf32_hppa_size_stubs): Read symbol shndx
extension, and use with swap_symbol_in.
* elf64-hppa.c (elf64_hppa_check_relocs): Likewise.
* elf32-i370.c (i370_elf_finish_dynamic_sections): Adjust call to
bfd_elf32_swap_symbol_out.
* elf32-m32r.c (m32r_elf_get_relocated_section_contents): Translate
elf sections > SHN_HIRESERVE too.
* elf32-m68k.c (bfd_m68k_elf32_create_embedded_relocs): Only read
local syms. Read symbol shndx extension, and use with swap_symbol_in.
* elf32-mips.c (_bfd_mips_elf_final_write_processing): Use
elf_numsections rather than header e_shnum.
* elf32-sh.c (sh_elf_relax_section): As for elf-m10300.c.
(sh_elf_relax_delete_bytes): Likewise.
(sh_elf_get_relocated_section_contents): Likewise. Only read local
symbols.
* elf32-v850.c (v850_elf_symbol_processing): Use an unsigned int to
hold section index. Use elf_numsections rather than e_shnum.
Rename "index" -> "indx" to avoid shadowing warning.
(v850_elf_add_symbol_hook): Likewise.
* elf64-alpha.c (elf64_alpha_relax_section): Only read local syms.
Read symbol shndx extension, and use with swap_symbol_in.
* elf32-xstormy16.c (xstormy16_elf_relax_section): Likewise.
Translate SHN_COMMON and elf sections > SHN_HIRESERVE too.
* elfxx-ia64.c (elfNN_ia64_relax_section): Likewise.
(elfNN_ia64_aix_add_symbol_hook): Use elf_numsections.
* elf-m10300.c (mn10300_elf_gc_mark_hook): Remove unnecessary checks
before calling bfd_section_from_elf_index on local syms.
* elf32-arm.h (elf32_arm_gc_mark_hook): Likewise.
* elf32-avr.c (elf32_avr_gc_mark_hook): Likewise.
* elf32-cris.c (cris_elf_gc_mark_hook): Likewise.
* elf32-d10v.c (elf32_d10v_gc_mark_hook): Likewise.
* elf32-fr30.c (fr30_elf_gc_mark_hook): Likewise.
* elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise.
* elf32-i386.c (elf_i386_gc_mark_hook): Likewise.
* elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise.
* elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise.
* elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise.
* elf32-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise.
* elf32-openrisc.c (openrisc_elf_gc_mark_hook): Likewise.
* elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise.
* elf32-s390.c (elf_s390_gc_mark_hook): Likewise.
* elf32-sh.c (sh_elf_gc_mark_hook): Likewise.
* elf32-sparc.c (elf32_sparc_gc_mark_hook): Likewise.
* elf32-v850.c (v850_elf_gc_mark_hook): Likewise.
* elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Likewise.
* elf64-mips.c (mips_elf64_gc_mark_hook): Likewise.
* elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise.
* elf64-ppc.c (ppc64_elf_gc_mark_hook): Likewise.
* elf64-s390.c (elf_s390_gc_mark_hook): Likewise.
* elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise.
binutils/ChangeLog
* readelf.c (symtab_shndx_hdr): New global.
(SECTION_HEADER_INDEX): Define.
(SECTION_HEADER_NUM): Define.
(SECTION_HEADER): Define.
(GET_ELF_SYMBOLS): Pass two params rather than three.
(get_32bit_elf_symbols): Take file and section args. Read and
use SHT_SYMTAB_SHNDX.
(get_64bit_elf_symbols): Likewise.
(dump_relocations): Use SECTION_HEADER to index "section_headers".
(process_section_headers): Likewise. Use SECTION_HEADER_NUM too.
Remember symtab_shdx_hdr.
(process_program_headers): Scan from index 1 for segment map.
(slurp_ia64_unwind_table): Use SECTION_HEADER to index
"section_headers".
(process_relocs): Likewise. Also adjust call to GET_ELF_SYMBOLS.
(process_unwind): Likewise.
(process_version_sections): Likewise.
(process_symbol_table): Likewise.
(display_debug_info): Likewise.
(process_dynamic_segment): Fake up a symtab section for changed
GET_ELF_SYMBOLS.
(get_symbol_index_type): Check SHN_LOOS before SHN_LORESERVE.
(process_program_headers): Kill signed/unsigned warning.
(load_debug_str): Likewise.
(display_debug_info): Likewise.
elf_backend_copy_indirect_symbol so that backend has a chance to
copy other necessary fields.
* elf-bfd.h (struct elf_backend_data): Update description of
elf_backend_copy_indirect_symbol.
* elf.c (_bfd_elf_link_hash_copy_indirect): Bail out after
copying flags if this is a weakdef.
* elfxx-ia64.c (elfNN_ia64_hash_copy_indirect): Likewise.
(elfNN_ia64_aix_add_symbol_hook): Use elf_link_hash_lookup rather
than bfd_link_hash_lookup.
* elf32-i386 (elf_i386_adjust_dynamic_symbol): Don't do copy
reloc processing for weakdefs.
* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
(struct elf_backend_data): Add can_refcount.
* elf.c (_bfd_elf_link_hash_newfunc): Get rid of a few casts. Set
got.refcount and plt.refcount from init_refcount.
(_bfd_elf_link_hash_table_init): Set up init_refcount.
(_bfd_elf_link_hash_copy_indirect): Reference got/plt.refcount
rather than got/plt.offset, and test for <= 0 rather than -1.
* elflink.h (size_dynamic_sections): Set init_refcount to -1.
* elfxx-target.h (elf_backend_can_refcount): Define.
(elfNN_bed): Init can_refcount.
* linker.c (_bfd_link_hash_newfunc): Get rid of a few casts.
(_bfd_generic_link_hash_newfunc): Likewise.
* elf32-cris.c (cris_elf_check_relocs): Modify for refcounts
starting from zero.
(elf_backend_can_refcount): Define.
* elf32-hppa.c (elf32_hppa_check_relocs): Modify for refcounts
starting from zero.
(elf32_hppa_copy_indirect_symbol): Make static to agree with
prototype.
(elf_backend_can_refcount): Define.
* elf32-i386.c (elf_i386_check_relocs): Modify for refcounts
starting from zero.
(allocate_dynrelocs): Set plt/got.offset rather than *.refcount.
(elf_i386_finish_dynamic_symbol): Expand SHN_UNDEF comment.
(elf_i386_finish_dynamic_sections): Use local var so line < 80 chars.
(elf_backend_can_refcount): Define.
(elf_i386_copy_indirect_symbol): Make static to agree with
prototype. Formatting fix.
* elf32-m68k.c (elf_m68k_check_relocs): Modify for refcounts
starting from zero.
(elf_backend_can_refcount): Define.
* elf32-ppc.c (ppc_elf_check_relocs): Modify for refcounts
starting from zero.
(elf_backend_can_refcount): Define.
* elf32-s390.c (elf_s390_check_relocs): Modify for refcounts
starting from zero.
(elf_backend_can_refcount): Define.
* elf64-s390.c (elf_s390_check_relocs): Modify for refcounts
starting from zero.
(elf_backend_can_refcount): Define.
* elf64-x86-64.c (elf64_x86_64_check_relocs): Modify for refcounts
starting from zero.
(elf_backend_can_refcount): Define.
no longer allocate here. Localise some vars to blocks where they
are used. Remove separate switch stmt for creating .got sec.
(elf_i386_adjust_dynamic_symbol): Correct a comment. Remove
redundant casts and aborts. Delay setting of vars until needed.
(allocate_dynrelocs): Remove redundant casts and aborts.
(elf_i386_size_dynamic_sections): Move comment.
(elf_i386_finish_dynamic_symbol): Move expressions out of function
calls.
(elf_i386_relocate_section): Likewise. Comment typo fix.
(elf_i386_finish_dynamic_sections): Migrate common code out of
switch statement.
(elf_backend_* defines): Sort.
(elf_backend_copy_indirect_symbol): Define.
(struct elf_i386_link_hash_entry): Rename "root" to "elf".
(struct elf_i386_link_hash_table): Likewise.
(link_hash_newfunc): Get rid of unnecessary casts.
(elf_i386_link_hash_table_create): Likewise.
(elf_i386_check_relocs): Initialise local_got_refcounts to 0.
Don't test input section SEC_READONLY here to try to avoid copy
relocs, and keep dyn_relocs regardleas of ELF_LINK_NON_GOT_REF.
(elf_i386_adjust_dynamic_symbol): Check output section SEC_READONLY
here to properly test whether we need copy relocs. Do so for weak
syms too.
* elf32-hppa (elf32_hppa_copy_indirect_symbol): New function.
(elf_backend_copy_indirect_symbol): Define.
(struct elf32_hppa_link_hash_table): Rename "root" to "elf".
(stub_hash_newfunc): Get rid of unnecessary casts.
(hppa_link_hash_newfunc): Likewise.
(elf32_hppa_check_relocs): Initialise local_got_refcounts to 0.
Don't test input section SEC_READONLY here to try to avoid copy
relocs, and keep dyn_relocs regardleas of ELF_LINK_NON_GOT_REF.
(elf32_hppa_adjust_dynamic_symbol): Check output section SEC_READONLY
here to properly test whether we need copy relocs. Do so for weak
syms too.
(elf_i386_link_hash_newfunc): Rename to link_hash_newfunc.
(elf_i386_grok_prstatus): Move before linker functions.
(elf_i386_grok_psinfo): Likewise.
(elf_i386_fake_sections): Move so that functions are ordered.
(elf_i386_reloc_type_class): Likewise. Comment function purpose.
and "sreloc" fields.
* elf32-i386.c (struct elf_i386_dyn_relocs): Add "sec", and
"pc_count" fields. Remove "section" field.
(elf_i386_check_relocs): Don't set DF_TEXTREL here. Don't
allocate space for dynamic relocs here. Instead, record all
needed dynamic relocs via dyn_relocs and local_dynrel. Cache
pointer to "sreloc" section in elf_section_data.
(elf_i386_gc_sweep_hook): Sweep dyn_relocs and local_dynrel.
(allocate_plt_and_got_and_discard_relocs): Rename to
allocate_dynrelocs. Allocate rather than discarding dyn relocs.
(readonly_dynrelocs): New function.
(elf_i386_size_dynamic_sections): Call readonly_dynrelocs.
Rename "i" to "ibfd". Allocate space for local dyn relocs.
(elf_i386_relocate_section): Make use of cached sreloc.
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
as well as DEF_DYNAMIC in test for avoided copy relocs.
(allocate_plt_and_got_and_discard_relocs): Likewise.
* elf32-i386.c (elf_i386_relocate_section): Likewise.
(allocate_plt_and_got_and_discard_relocs): Likewise.
(struct elf_backend_data): Add elf_backend_reloc_type_class.
(_bfd_elf_reloc_type_class): New.
* elfxx-target.h (elf_backend_reloc_type_class): Define.
(elfNN_bed): Add elf_backend_reloc_type_class.
* elf.c (_bfd_elf_reloc_type_class): New.
* elf32-i386.c (elf_i386_check_relocs): Set DF_TEXTREL if the reloc
is against read-only section.
(elf_i386_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(elf_i386_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elf32-sparc.c (elf32_sparc_check_relocs): Set DF_TEXTREL if the
reloc is against read-only section.
(elf32_sparc_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(elf32_sparc_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elf64-sparc.c (sparc64_elf_check_relocs): Set DF_TEXTREL if the
reloc is against read-only section.
(sparc64_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(sparc64_elf_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elfxx-ia64.c (struct elfNN_ia64_link_hash_table): Add reltext field.
(elfNN_ia64_hash_table_create): Clear ia64_info.
(get_reloc_section): Set DF_TEXTREL if the reloc is against read-only
section.
(elfNN_ia64_size_dynamic_sections): Use ia64_info->reltext flag
instead of looking up section names for DT_TEXTREL.
(elfNN_ia64_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elflink.h (size_dynamic_sections): Add spare DT_NULL tags.
(struct elf_link_sort_rela): New.
(elf_link_sort_cmp1, elf_link_sort_cmp2, elf_link_sort_relocs): New.
(elf_bfd_final_link): Call elf_link_sort_relocs.
Convert one spare DT_NULL into DT_RELCOUNT resp. DT_RELACOUNT if
necessary.
* bfdlink.h (struct bfd_link_info): Add combreloc and
spare_dynamic_tags fields.
* emultempl/elf32.em (place_orphan): Place orphan .rel* sections
into .rel.dyn resp. .rela.dyn if combreloc.
(get_script): If .x linker script is equal to .xn, only put it
once into the binary.
Add .xc and .xsc scripts.
(parse_args): Handle -z combreloc and -z nocombreloc.
* scripttempl/elf.sc (.rela.sbss): Fix a typo.
For .xc and .xsc scripts put all .rel* or .rela* input sections
but .rel*.plt and PLT-like sections into .rel.dyn resp. .rela.dyn.
* genscripts.sh (GENERATE_COMBRELOC_SCRIPT): Set if SCRIPT_NAME
is elf.
Strip trailing whitespace from script.
Generate .xc and .xsc scripts if requested.
* ldmain.c (main): Initialize link_info.combreloc and
link_info.spare_dynamic_tags.
* lexsup.c (OPTION_SPARE_DYNAMIC_TAGS): Define.
(ld_options): Add --spare-dynamic-tags option.
(parse_args): Likewise.
* ld.texinfo: Document -z combreloc and -z nocombreloc.
* ldint.texinfo: Document .xc and .xsc linker scripts.
* NEWS: Add notes about -z combreloc and SHF_MERGE.
here..
(elf_i386_adjust_dynamic_symbol): ..nor here..
(allocate_plt_and_got_and_discard_relocs): .. instead do so here
after gc has run.
(elf_i386_size_dynamic_sections): Fix a comment.
(elf_i386_relocate_section <R_386_32, R_386_PC32>): Rearrange code
involved in writing reloc out.
Ensure syms are dynamic if we might be emitting a reloc.
(allocate_plt_and_got_and_discard_relocs): Don't discard relocs
for undefweak or undefined syms..
(elf_i386_relocate_section <R_386_32, R_386_PC32>): .. and emit.
* elf32-i386.c (elf_i386_relocate_section): Check the
ELF_LINK_HASH_DEF_DYNAMIC to see if a symbol is not defined
in the regular object file and treat the weak definition as
the normal one.
unresolved_reloc test to exclude cases where we use "relocation"
before setting it to point into the .got. Reinstate fudge for
unresolved relocs in debugging sections.
* elf32-i386.c (elf_i386_check_relocs): Tweak condition under
which .got created. Mark symbols used by R_386_32 and R_386_PC32
relocs as ELF_LINK_NON_GOT_REF to create COPY relocs only when the
reloc is in a read-only section. Instead, allocate space for a
dynamic reloc to reference the library symbol directly. Keep
track of space we allocate using pcrel_relocs_copied.
(discard_copies): Delete, and move code to ..
(allocate_plt_and_got): ..here. Rename to
allocate_plt_and_got_and_discard_relocs. Remove unneeded dynamic
relocs for non-shared link.
(elf_i386_size_dynamic_sections): Update calls to above functions.
(elf_i386_relocate_section): Write out the dynamic relocs. Add
more ugly logic to avoid "unresolvable relocation" error. Use
htab shortcut in place of elf_hash_table macro.
(elf_i386_finish_dynamic_sections): Allow that dynamic .got may
not always be created now.
discard_copies, and use elf_link_hash_entry arg rather than
elf_i386_link_hash_entry.
(elf_i386_link_hash_traverse): Delete.
(elf_i386_size_dynamic_sections): Adjust call to discard_copies.
Tidy sizing of dynamic sections.
(elf_i386_check_relocs <R_386_32, R_386_PC32>): Reference count
possible .plt entries.
(elf_i386_gc_sweep_hook): Likewise.
(elf_i386_adjust_dynamic_symbol): Discard .plt entries for
everything with plt.refcount <= 0.
* elf32-i386.c (elf_i386_check_relocs): Don't allocate .got and
.relgot space here.
(elf_i386_gc_sweep_hook): ..and no need to deallocate here..
(elf32_hppa_adjust_dynamic_symbol): ..and don't allocate .plt and
.rel.plt here..
(allocate_plt_and_got): ..instead do it all here. New function.
(elf_i386_size_dynamic_sections): Allocate local .got space and
call allocate_plt_and_got. No need to zap .relgot if not dynamic.
(bfd_elf32_bfd_final_link): Delete. (ie. use regular final link
rather than gc variety).
(WILL_CALL_FINISH_DYNAMIC_SYMBOL): Define.
(elf_i386_relocate_section): Use it here and correct handling of
R_386_GOT32. Provide section and offset for "unresolvable
relocation" error message.
(elf_i386_finish_dynamic_symbol): Correct handling of R_386_GOT32.
* elf32-i386.c (struct elf_i386_link_hash_table): Add sgot,
sgotplt, srelgot, splt, srelplt, sdynbss, srelbss fields.
(elf_i386_link_hash_table_create): Init them.
(create_got_section): New function.
(elf_i386_create_dynamic_sections): New function.
(elf_backend_create_dynamic_sections): Set to above.
(elf_i386_check_relocs): Use shortcuts from hash table rather than
calling bfd_get_section_by_name.
(elf_i386_gc_sweep_hook): Likewise.
(elf_i386_adjust_dynamic_symbol): Likewise.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_sections): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Report files with bad
relocation section names.
(elf_i386_relocate_section): Report files with bad relocation
section names and return false.
* elf32-arm.h (elf32_arm_size_dynamic_sections): Also set
DF_TEXTREL if DT_TEXTREL is set.
* elf32-i370.c (i370_elf_size_dynamic_sections): Likewise.
* elf32-i386.c (elf_i386_size_dynamic_sections): Likewise.
* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
* elf32-mips.c (_bfd_mips_elf_size_dynamic_sections): Likewise.
* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
* elf32-sparc.c (elf32_sparc_size_dynamic_sections): Likewise.
* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
* elf64-ia64.c (elf64_ia64_size_dynamic_sections): Likewise.
* elf64-sparc.c (sparc64_elf_size_dynamic_sections): Likewise.
* bfd/elflink.h (NAME(bfd_elf,size_dynamic_sections)): Also
set DF_SYMBOLIC for symbolic link. Also set DT_RUNPATH if
DT_RPATH is set.
Set the DT_FLAGS and DT_FLAGS_1 entries if necessary.
If it passed as non-NULL, use it to check whether any input BFD
has an input section which uses this output section. Change all
callers.
* bfd-in2.h: Rebuild.
* bfd-in.h: Move declarations of bfd_get_elf_phdr_upper_bound and
bfd_get_elf_phdrs in from bfd-in2.h, correcting patch of
1999-11-29.
* bfd-in2.h: Rebuild.
* elflink.h (elf_adjust_dynamic_symbol): Copy REF_REGULAR_NONWEAK
and NON_GOT_REF from weak defined symbol to real symbol.
* elf32-i386.c (elf_i386_check_relocs): Set NON_GOT_REF.
(elf_i386_adjust_dynamic_symbol): If NON_GOT_REF is not set, don't
create a COPY reloc.
* elf32-sparc.c (elf32_sparc_check_relocs): Set NON_GOT_REF.
(elf32_sparc_adjust_dynamic_symbol): If NON_GOT_REF is not set,
don't create a COPY reloc.
as appropriate. Use EMPTY_HOWTO as appropriate. Fill in
structure initializations. Add casts.
* reloc.c (EMPTY_HOWTO): Define.
* bfd-in2.h: Rebuild.
* coff-h8300.c (h8300_reloc16_extra_cases): Remove useless
comparisons against 0.
* elf32-sparc.c (elf32_sparc_merge_private_bfd_data): Change
previous_ibfd_e_flags to unsigned long.
* vms.h (struct vms_private_data_struct): Change section_count to
unsigned.
* vms-gsd.c (_bfd_vms_slurp_gsd): Change psect_idx to unsigned.
(_bfd_vms_write_gsd): Change symnum to unsigned.
* vms-hdr.c (_bfd_vms_write_hdr): Change symnum to unsigned.
* vms-tir.c (etir_sta): Change psect to unsigned.
(alloc_section): Change idx to unsigned.
(tir_sta, tir_ctl): Change psect to unsigned.
(_bfd_vms_write_tir): Change len and before to bfd_size_type.
* vms.c (priv_section_count): Change to unsigned.
as appropriate. Fill in structure initializations. Add variable
initializations. Add casts.
* dwarf1.c (parse_line_table): Change eachLine to unsigned long.
(dwarf1_unit_find_nearest_line): Change i to unsigned long.