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.
relocation entries for weak undefined symbols with non-default
visibility.
(elf64_x86_64_relocate_section): Initialize the GOT entries and
skip R_386_32/R_386_PC32 for weak undefined symbols with
non-default visibility.
* elflink.h (elf_merge_symbol): Don't record a hidden/internal
symbol dynamic. Check indirection when removing the old
definition for symbols with non-default visibility.
(elf_add_default_symbol): Skip when told by elf_merge_symbol.
ELF_LINK_NON_GOT_REF for weakdefs when symbol already adjusted.
(ELIMINATE_COPY_RELOCS): Define as one. Use throughout.
(elf_x86_64_adjust_dynamic_symbol): For weak symbols, copy
ELF_LINK_NON_GOT_REF from weakdef.
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.
2003-04-28 H.J. Lu <hjl@gnu.org>
* elflink.h (elf_merge_symbol): Call elf_backend_copy_indirect_symbol
to copy any information related to dynamic linking when we flip
the indirection.
ld/testsuite/
2003-04-28 H.J. Lu <hjl@gnu.org>
* ld-elfvers/vers.exp (picflag): Set PIC flag for compiler.
(build_vers_lib): Support PIC.
(build_vers_lib_no_pic): New. Change all calls to build_vers_lib
to build_vers_lib_no_pic.
(build_vers_lib_pic): New.
Add tests vers26a, vers26b1, vers26b2 and vers26b3 for versioned
definition vs. normal definition in different files.
* ld-elfvers/vers26a.c: New file.
* ld-elfvers/vers26a.dsym: Likewise.
* ld-elfvers/vers26a.map: Likewise.
* ld-elfvers/vers26a.ver: Likewise.
* ld-elfvers/vers26b.c: Likewise.
* ld-elfvers/vers26b.dsym: New empty file.
* ld-elfvers/vers26b.ver: Likewise.
2003-04-27 H.J. Lu <hjl@gnu.org>
* elf-bfd.h (ELF_LINK_DYNAMIC_DEF): New.
(ELF_LINK_DYNAMIC_WEAK): New.
* elflink.h (elf_merge_symbol): Add one argument to indicate if
a symbol should be skipped. Ignore definitions in dynamic
objects for symbols with non-default visibility.
(elf_add_default_symbol): Adjusted.
(elf_link_add_object_symbols): Check if a symbol should be
skipped. Don't merge the visibility field with the one from
a dynamic object.
(elf_link_check_versioned_symbol): Use undef_bfd.
(elf_link_output_extsym): Warn if a forced local symbol is
referenced from dynamic objects. Make non-weak undefined symbol
with non-default visibility a fatal error.
ld/testsuite/
2003-04-27 H.J. Lu <hjl@gnu.org>
* ld-elfvsb/elfvsb.dat: Updated.
* ld-elfvsb/elfvsb.exp: Likewise.
* ld-elfvsb/main.c: Likewise.
* ld-elfvsb/sh1.c: Likewise.
* ld-elfvsb/sh2.c: Likewise.
* elf32-m68hc11.c (m68hc11_elf_relax_section): Clear prev_insn_group
when we couldn't relax something.
* ld-m68hc11/bug-3331.d: New test.
* ld-m68hc11/bug-3331.s: New file.
* elflink.h (elf_merge_symbol): When we find a regular definition
for an indirect symbol, flip the indirection so that the old
direct symbol now points to the new definition.
(m68hc11_elf_hash_table_create): New function.
(elf32_m68hc11_link_hash_table_free): New function.
(stub_hash_newfunc): New function.
(m68hc11_add_stub): New function.
(elf32_m68hc11_add_symbol_hook): New function.
(elf32_m68hc11_setup_section_lists): New function.
(elf32_m68hc11_next_input_section): New function.
(elf32_m68hc11_size_stubs): New function.
(elf32_m68hc11_build_stubs): New function.
(m68hc11_get_relocation_value): New function.
(elf32_m68hc11_relocate_section): Call the above to redirect
some relocations to the trampoline code.
(m68hc11_elf_export_one_stub): New function.
(m68hc11_elf_set_symbol): New function.
(elf32_m68hc11_build_stubs): Call it via bfd_hash_traverse.
(m68hc11_elf_get_bank_parameters): Get parameters only when the info
is not yet initialized.
* elf32-m68hc1x.h: New file (from elf32-m68hc11.c and elf32-m68hc12.c)
(elf32_m68hc11_stub_hash_entry): New struct.
(m68hc11_page_info): Add trampoline handler address.
(m68hc11_elf_link_hash_table): Add stubs generation members.
(elf32_m68hc11_add_symbol_hook): Declare.
(elf32_m68hc11_setup_section_lists): Declare.
(elf32_m68hc11_size_stubs): Declare.
(elf32_m68hc11_build_stubs): Declare.
* elf32-m68hc11.c (m68hc11_elf_ignore_reloc): Move to elf32-m68hc1x.c.
(elf32_m68hc11_gc_mark_hook, elf32_m68hc11_gc_sweep_hook): Likewise.
(elf32_m68hc11_check_relocs, elf32_m68hc11_relocate_section): Ditto.
(_bfd_m68hc11_elf_set_private_flags): Ditto.
(_bfd_m68hc11_elf_merge_private_bfd_data): Ditto.
(_bfd_m68hc11_elf_print_private_bfd_data): Ditto.
(bfd_elf32_bfd_link_hash_table_create): Define.
(elf_backend_add_symbol_hook): Define.
(m68hc11_elf_bfd_link_hash_table_create): New function.
(m68hc11_elf_build_one_stub): New function.
(m68hc11_elf_size_one_stub): New function.
(m68hc11_elf_bfd_link_hash_table_create): Install the above.
(bfd_elf32_bfd_link_hash_table_create): Define.
* elf32-m68hc12.c (m68hc11_elf_ignore_reloc): Remove.
(m68hc12_addr_is_banked): Remove, use m68hc11_addr_is_banked.
(m68hc12_phys_addr): Ditto.
(m68hc12_phys_page): Ditto.
(m68hc12_elf_special_reloc): Move to elf32-m68hc1x.c.
(elf32_m68hc11_gc_mark_hook): Likewise.
(elf32_m68hc11_gc_sweep_hook): Likewise.
(elf32_m68hc11_check_relocs): Likewise.
(elf32_m68hc11_relocate_section): Likewise.
(_bfd_m68hc12_elf_set_private_flags): Likewise.
(_bfd_m68hc12_elf_merge_private_bfd_data): Likewise.
(_bfd_m68hc12_elf_print_private_bfd_data): Likewise.
(m68hc12_elf_build_one_stub): New function.
(m68hc12_elf_size_one_stub): New function.
(m68hc12_elf_bfd_link_hash_table_create): New function, use the above.
(elf_backend_add_symbol_hook): Define.
(elf_m68hc11_howto_table): Use TRUE for pcrel relocs; fix masks.
GOT_PAGE/GOT_OFST referencing overridable symbol to
GOT_DISP/addend.
(_bfd_mips_elf_check_relocs): Handle GOT_PAGE referencing
global symbol as GOT_DISP.
symbols that mark the end of the section.
(m68hc11_elf_relax_section): Use R_M68HC11_PCREL_8 relocs when
converting to a relative branch so that the offset is computed after
the relaxation; also relocate a jsr into a bsr if possible but don't
relax them if they are to a far symbol as we need to call the
trampoline code.
(elf_m68hc11_howto_table): Set pcrel_offset to true.
executables.
(coff_swap_scnhdr_in): Only set the s_size field for object files or for
executables who have not already initialised the field.
(bfd_pe_executable_p): New macro. Return true if the PE format bfd is an
executable.
parameter symbol_table. Optionally use it instead of the symbol
table from the bfd. Save and restore output offsets and output
sections around bfd_get_relocated_section_contents. Fix a memory
leak.
(simple_save_output_info, simple_restore_output_info): New
functions.
* bfd-in2.h: Regenerate.
* dwarf2.c (read_abbrevs): Use
bfd_simple_get_relocated_section_contents instead of
bfd_get_section_contents.
(decode_line_info): Likewise.
(_bfd_dwarf2_find_nearest_line): Likewise. Don't call
find_rela_addend.
(find_rela_addend): Remove.
* elfxx-ia64.c (elfNN_ia64_reloc): Weaken sanity check for
debugging sections.
(elfNN_ia64_hash_table_create): Create the hash table with malloc,
not bfd_zalloc.
(elf_m68k_relocate_section): Use it to correctly handle symbols
forced to be local.
(elf_m68k_finish_dynamic_symbol): Emit RELATIVE reloc for got
entries for symbols that are forced to be local.
field.
(canon_reloc_count): Define.
(sparc64_elf_slurp_one_reloc_table, sparc64_elf_slurp_reloc_table,
sparc64_elf_canonicalize_dynamic_reloc): Use it instead of
reloc_count.
(sparc64_elf_canonicalize_reloc): New routine.
(bfd_elf64_canonicalize_reloc): Define.
dynamic relocations pointing to local or section symbols, use the
NULL symbol instead. Document the choice to not emit an
additional R_MIPS_64 relocation.
zero index dynamic tls relocs generated for the GOT. Tidy code.
Set "relocation" to 1 on DTPMOD32 relocs. Optimize HA adjustment.
* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
* ld-powerpc/tlsso.r: Adjust for corrected zero symbol index relocs.
* ld-powerpc/tlsso32.r: Likewise.
(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.
error messages.
(ELIMINATE_COPY_RELOCS): Define to zero.
(ppc_elf_relocate_section): Don't deref htab->tls_sec when calculating
TLSLD relocs. Report reloc types on a number of errors. Optimize
LOCAL24PC check for non-local syms. Don't capitalize error messages.
* elf64-ppc.c (ELIMINATE_COPY_RELOCS): Define to zero.
(ppc64_elf_relocate_section): Don't deref htab->tls_sec when
calculating TLSLD relocs. Report reloc types on a number of errors.
Don't capitalize error messages.
gcc:
* config/sh/sh.h (EXTRA_SPECS): Add subtarget_asm_relax_spec and
subtarget_asm_isa_spec.
(SUBTARGET_ASM_RELAX_SPEC, SUBTARGET_ASM_ISA_SPEC): Define.
(ASM_SPEC): Define as SH_ASM_SPEC.
(SH_ASM_SPEC): New; take the role of ASM_SPEC, but safe from svr4.h.
Use subtarget_asm_relax_spec and subtarget_asm_isa_spec.
* config/sh/elf.h (ASM_SPEC): Use SH_ASM_SPEC.
(SUBTARGET_ASM_ISA_SPEC): Undef / define.
gcc/testsuite:
gcc.dg/sh-relax.c: New test.
include/elf:
* sh.h (EF_SH_MERGE_MACH): Make sure SH2E & SH3/SH3E merge to SH3E,
and SH2E & SH4 merge to SH4, not SH2E.
gas:
* config/tc-sh.c (sh_dsp): Replace with preset_target_arch.
(md_begin): Use preset_target_arch.
(md_longopts): Make isa option unconditional.
(md_parse_option): Make OPTION_DSP and OPTION_ISA sh4 / any
set preset_target_arch.
(md_apply_fix3): If BFD_ASSEMBLER, adjust SWITCH_TABLE fixups
by -S_GET_VALUE (fixP->fx_subsy).
(tc_gen_reloc): For SWITCH_TABLE fixups, the symbol is fixp->fx_subsy,
and the addend is 0.
Adjust addend of R_SH_IND12W relocations by fixp->fx_offset - 4.
* config/tc-sh.h (TC_FORCE_RELOCATION_SUB_LOCAL): Define.
bfd:
elf32-sh.c (sh_elf_howto_tab): Make R_SH_IND12W into an ordinary
relocation (no special function), and make it non-partial_inplace.
(sh_elf_relax_section): When creating a bsr, use a consistent value
no matter if the symbol is extern or not; set addend to -4.
Don't swap load / non-load instructions for SH4.
(sh_elf_relax_delete_bytes): In R_SH_IND12W case, check the offset
rather than if the symbol is external to determine if adjusting the
offset makes sense. Adjust the addend too if appropriate.
(sh_elf_relocate_section): In R_SH_IND12W, don't fiddle with the
relocation.