The idea here is to drop .eh_frame FDEs corresponding to dropped
comdat group sections or linkonce sections, but not perform changes in
encoding.
bfd/
PR 17467
* elf-eh-frame.c (ENSURE_NO_RELOCS): Don't stop at first NONE reloc.
(_bfd_elf_parse_eh_frame): When relocatable output, don't set
flags enabling conversion of CIEs and FDEs to use relative encoding.
(find_merged_cie): Similarly.
(_bfd_elf_write_section_eh_frame): Don't edit FDEs when
relocatable, except for CIE pointer.
* elflink.c (bfd_elf_reloc_symbol_deleted_p): Return true for
relocs against symbols in dropped comdat group sections.
(bfd_elf_discard_info): Do some eh_frame optimisation when
relocatable.
ld/
* ldlang.c (lang_add_section): Set up map_head.s and map_tail.s when
relocatable.
I noticed recently that .eh_frame FDEs generated by the linker for
call stubs and .glink weren't being indexed in .eh_frame_hdr, due to
bfd_elf_discard_info being run before the linker generated .eh_frame
sections were available for parsing. This patch moves code around in
elf64-ppc.c and ppc64elf.em to avoid that problem.
Another problem fixed here is that --gc-sections parses .eh_frame
early, and the existing machinery allows only one go at parsing the
.eh_frame sections. That resulted in the linker generated .eh_frame
CIEs not being merged and no .eh_frame_hdr index entries for those
FDEs. It turns out that all the info from parsing .eh_frame is
attached to the section, so order of parsing isn't important, and
after parsing sec_info_type being set will prevent a section being
parsed again. At least, when parsing doesn't hit an error. So there
isn't really any need for "parsed_eh_frame". "merge_cies" is also
redundant, which means _bfd_elf_{begin,end}_eh_frame_parsing can also
disappear.
bfd/
* elf-bfd.h (struct eh_frame_hdr_info): Delete merge_cies and
parsed_eh_frames.
(_bfd_elf_begin_eh_frame_parsing): Delete.
(_bfd_elf_end_eh_frame_parsing): Delete.
* elf-eh-frame.c (_bfd_elf_begin_eh_frame_parsing): Delete.
(_bfd_elf_end_eh_frame_parsing): Delete.
(_bfd_elf_parse_eh_frame): Don't test parsed_eh_frame. Test
!info->relocatable in place of merge_cies.
* elflink.c (bfd_elf_gc_sections, bfd_elf_discard_info): Adjust.
* elf64-ppc.c (glink_eh_frame_cie): Pad to multiple of 8.
(ppc64_elf_size_stubs): Likewise pad stub FDE.
(ppc64_elf_build_stubs): Move code setting glink .eh_frame to..
(ppc64_elf_size_stubs): ..here and..
(ppc64_elf_finish_dynamic_sections): ..here.
ld/
* emultempl/ppc64elf.em (gld${EMULATION_NAME}_after_allocation): Call
bfd_elf_discard_info after generating glink .eh_frame. Delete
redundant test on ppc64_elf_setup_section_lists status.
PR 17287
bfd/
* elflink.c (on_needed_list): Only consider libraries that have
been loaded.
ld/
* ld.texinfo (--as-needed): Clarify that references from libraries
must be from needed libraries.
ld/testsuite/
* ld-plugin/needed3.c: New file.
* ld-elf/shared.exp: Add needed3 test.
Presents .eh_frame input sections to the optimisation machinery in
elf-eh-frame.c in the order they are given by the linker script.
PR 16563
bfd/
* elflink.c (bfd_elf_discard_info): Process .eh_frame and .stab
in the order they are mapped to output sections.
ld/
* ldlang.c (map_head_is_link_order): Rename from
stripped_excluded_sections.
(lang_clear_os_map): New function, extracted from..
(strip_excluded_output_sections): ..here.
* ldlang.h (lang_clear_os_map): Declare.
* ldwrite.c (ldwrite): Call lang_clear_os_map.
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_after_allocation):
Likewise.
The main aim of this change was to have non_ir_ref set correctly on
new indirect symbols. I could have added a "copy" param to the "notice"
function, so that indirect symbols could be created in plugin_notice,
but it seemed cleaner to create indirect syms earlier and pass them
rather than "string" to "notice".
include/
* bfdlink.h (struct bfd_link_callbacks <notice>): Remove "string"
param, add "inh".
bfd/
* coff-aux.c (coff_m68k_aux_link_add_one_symbol): Only call "notice"
here when not calling the generic add_symbol function. Formatting.
Correct handling of indirect symbols. Update notice call.
* elflink.c (_bfd_elf_notice_as_needed): Update notice call.
* linker.c (_bfd_generic_link_add_one_symbol): Create indirect
symbols early. Update notice call. Add comments regarding weak
symbols vs. indirect.
ld/
* ldmain.c (notice): Update args.
* plugin.c (plugin_notice): Likewise. Follow warning sym link.
Handle new indirect symbol.
Avoid scan of symbols on objects in coff archives since we don't need
to do anything special with common symbols. The scan is quite useless,
and breaks LTO due to slim LTO objects not having symbols available
until after the plugin has claimed them. Instead we can add objects
based on their archive symbol map.
Also, rip out the archive symbol hash table used by the generic
linker. Using a hash breaks one feature of unix archive linking;
The first object file in an archive defining any given symbol should
be the object extracted to satisfy that symbol. What's more a hash
isn't much faster except in pathological cases where object file
ordering causes many scans of the archive. See the comment which I'm
removing from elf_link_add_archive_symbols.
Finally, tidy elflink.c archive handling a little.
PR 13557
* linker.c (struct archive_list, struct archive_hash_entry,
struct archive_hash_table, archive_hash_newfunc,
archive_hash_table_init, archive_hash_lookup, archive_hash_allocate,
archive_hash_table_free): Delete.
(_bfd_generic_link_add_archive_symbols): Add h and name params to
checkfn. Rewrite using a straight-forward scan over archive map.
(generic_link_check_archive_element_no_collect,
generic_link_check_archive_element_collect,
generic_link_check_archive_element): Add h and name params.
* aoutx.h (aout_link_check_archive_element): Likewise.
* pdp11.c (aout_link_check_archive_element): Likewise.
* xcofflink.c (xcoff_link_check_archive_element): Likewise.
* cofflink.c (coff_link_check_archive_element): Likewise. Don't
scan symbols, simply add archive element whenever h is undefined.
(coff_link_check_ar_symbols): Delete.
* ecoff.c (read_ext_syms_and_strs): Delete.
(reread_ext_syms_and_strs): Delete.
(ecoff_link_check_archive_element): Add h and name param. Don't
scan symbols, simply add based on h. Use ecoff_link_add_object_symbols.
* elflink.c (elf_link_is_defined_archive_symbol): Don't test
archive_pass.
(elf_link_add_archive_symbols): Delete "defined" array, merge
functionality into "included". Make "included" a char array. Don't
set or test archive_pass.
* libbfd-in.h (_bfd_generic_link_add_archive_symbols): Update.
* libbfd.h: Regenerate.
So that we munge isym->st_other once per symbol.
* elflink.c (elf_merge_st_other): Update comments. Simplify
visibility handling. Make isym const. Move code modifying
isym->st_other for --exclude-libs to..
(elf_link_add_object_symbols): ..here.
This fixes a problem seen on powerpc64le ELFv2 when creating a
function symbol alias with ld --defsym. st_other needs to be copied
from the source symbol to the alias in order to set up the local entry
offset for the alias. I decided to make this change in the generic
ELF code rather than in elf64-ppc.c since it looks like other targets
that use st_other bits might benefit too.
bfd/
* elflink.c (_bfd_elf_copy_link_hash_symbol_type): Copy st_other
bits from source to dest.
* linker.c (_bfd_generic_copy_link_hash_symbol_type): Update comment.
* targets.c (struct bfd_target <_bfd_copy_link_hash_symbol_type>):
Likewise.
* bfd-in2.h: Regenerate.
ld/testsuite/
* ld-powerpc/defsym.s, * ld-powerpc/defsym.d: New test.
* ld-powerpc/powerpc.exp: Run it.
PR 16846
* elflink.c (_bfd_elf_merge_symbol): Ignore TLS mismatch when
current bfd is a plugin. Don't always set type_change_ok
when old bfd is a plugin.
The testcase in pr16417 comment #6 produces a map file showing
libpthread.so.0 (write@@GLIBC_2.2.5)
ie. missing the file referencing the symbol.
* elflink.c (_bfd_elf_add_default_symbol): Pass poldbfd when
merging non-default sym.
For powerpc64 as HJ did earlier for other ELF targets, and a tidy.
PR gold/15530
* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Support
--export-dynamic and --dynamic-list marking of symbols.
* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Reorder
cheap tests first.
This patch provides a means for backend relax_section support to
increase the size of a section without needing to reallocate
section contents. This helps reduce memory usage when the added space
does not need to be written in relax_section, as is the case for
powerpc. Writing the stubs later means a few tweaks are needed in the
powerpc relocate_section function, but also removes some code
duplication since the extra ld -r relocs can be written there too.
* elf-bfd.h (struct elf_backend_data): Add caches_rawsize.
* elfxx-target.h (elf_backend_caches_rawsize): Define.
(elfNN_bed): Init new field.
* elflink.c (elf_link_input_bfd): Handle caches_rawsize.
* elf32-ppc.c (shared_stub_entry): Zero addi offset.
(ppc_elf_relax_section): Don't reallocate section here, write
stubs, or write out relocs for ld -r here..
(ppc_elf_relocate_section): ..instead write stubs here, and use
existing code to write out relocs for ld -r. Fix offset
adjustment on reloc for little-endian.
(elf_backend_caches_rawsize): Define.
Adds a section for --as-needed libraries to a linker map file, similar
to what we do for archive libraries.
bfd/
* elflink.c (elf_link_add_object_symbols): Call minfo for --as-needed.
ld/
* ldlang.c (asneeded_list_head, asneeded_list_tail): New vars.
(lang_init): Initialise them.
(lang_print_asneeded): New function.
(lang_process): Call lang_print_asneeded.
* ldlang.h (struct asneeded_minfo): New.
(asneeded_list_tail): Declare.
* ldmain.c (add_archive_element): Improve archive map heading.
* ldmisc.c (minfo): Stash --as-needed info.
After resolving a versioned reference, foo@VER1, to a default versioned
definition, foo@@VER1, from a shared object, we also merge it with
the existing regular default symbol definition, foo. When foo is IFUNC
and foo@@VER1 aren't, we will merge 2 incompatible definitions. This
patch avoids merging foo@@VER1 definition with foo definition if
one is IFUNC and the other isn't.
There is nothing linker can do when a type mismatched default definition
are made dynamic by info->shared, info->export_dynamic or h->ref_dynamic.
But we do want to avoid exporting it when building PIE. Let's remove
those checks.
bfd/
PR ld/2404
* elflink.c (_bfd_elf_merge_symbol): Don't check info->shared,
info->export_dynamic, nor !h->ref_dynamic for type mismatch when
adding the default version.
ld/testsuite/
PR ld/2404
* ld-elf/shared.exp: Add a PIE test for PR ld/2404.
libx.so refers to some_sym, liby.so provides some_sym@some_version
wasn't seen as satisfying the reference.
* elf64-ppc.c (_bfd_elf_add_default_symbol): Set dynamic_def
and ref_dynamic_nonweak when chaining together indirect
symbols.
There's no real need to emit these always: They're needed only if we
indeed want to emit a localized symbol. Hence defer emission until we
at least did the basic early checks that would lead to no such symbol
getting emitted. This in particular avoids emitting such a symbol in
the majority of (if not all) "ld -r" cases.
I hope my set of cross build tests caught all the test cases needing
adjustment - please forgive if I missed a few.
bfd/
2013-10-29 Jan Beulich <jbeulich@suse.com>
* elflink.c (struct elf_outext_info): Add field file_sym_done.
(bfd_elf_final_link): Initialize new field. Move fake STT_FILE
symbol emission from here ...
(elf_link_output_extsym): ... to here.
gas/testsuite/
2013-10-29 Jan Beulich <jbeulich@suse.com>
* gas/microblaze/relax_size.elf: Drop expectation of no longer
present STT_FILE symbol.
* gas/microblaze/relax_size2.elf: Likewise.
ld/testsuite/
2013-10-29 Jan Beulich <jbeulich@suse.com>
* ld-cris/tls-e-tpoffcomm1.d: Drop expectation of no longer
present STT_FILE symbol.
* ld-mmix/bpo-18.d: Likewise.
* ld-mmix/bpo-22.d: Likewise.
* ld-mmix/greg-6.d: Likewise.
* ld-mmix/greg-7.d: Likewise.
* ld-mmix/loc4.d: Likewise.
* ld-mmix/local1.d: Likewise.
* ld-mmix/local3.d: Likewise.
* ld-mmix/local5.d: Likewise.
* ld-mmix/local7.d: Likewise.
* ld-mmix/loct-1.d: Likewise.
* ld-sh/sh64/abi32.xd: Likewise.
* ld-sh/sh64/abi64.xd: Likewise.
* ld-sh/sh64/cmpct1.xd: Likewise.
* ld-sh/sh64/crange1.rd: Likewise.
* ld-sh/sh64/crange2.rd: Likewise.
* ld-sh/sh64/crange3-cmpct.rd: Likewise.
* ld-sh/sh64/crange3-media.rd: Likewise.
* ld-sh/sh64/crange3.rd: Likewise.
* ld-sh/sh64/crangerel1.rd: Likewise.
* ld-sh/sh64/crangerel2.rd: Likewise.
* ld-sh/sh64/mix1.xd: Likewise.
* ld-sh/sh64/mix2.xd: Likewise.
* ld-sh/sh64/shdl32.xd: Likewise.
* ld-sh/sh64/shdl64.xd: Likewise.
hashes around loading as-needed library. Zero them on allocation,
and restore to initial all-zero state if library not needed.
Arrange to reuse hashes if we load library again later.
usual common symbols as well as for dynamic. Add poldbfd param.
Save old bfd. Adjust callers.
(_bfd_elf_add_default_symbol): Add poldbfd param. Pass "section"
and "value" by value, not pointer. Adjust caller.
(elf_link_add_object_symbols): Combine undef_bfd and old_bfd vars.
Delete code to set same. Use old_bfd and old_alignment from
_bfd_elf_merge_symbol instead. Add default symbol before
alignment and size checks. Wrap overlong lines.
(_bfd_elf_init_reloc_shdr): Delete.
* elf.c (_bfd_elf_init_reloc_shdr): Make static.
* elf64-x86-64.c (elf_x86_64_merge_symbol): Trim parameters to
just what is needed.
* elflink.c (_bfd_elf_merge_symbol): Update bed->merge_symbol call.