aboutsummaryrefslogtreecommitdiff
path: root/ld
AgeCommit message (Collapse)AuthorFilesLines
14 hoursLoongArch: Do not relax against __[start|stop]_SECNAME symbolLulu Cai3-0/+25
15 hoursx86/APX: correct libbfd's EVEX Rn -> Bn transformationsJan Beulich1-44/+44
In the recent GOTPCREL addition I screwed up, in clearing the Rn bits afterwards rather than setting them. While that ought to be benign (for the bits being ignored in situations like this), we still want to leave "canonical" encodings. The pre-existing GOTTPOFF conversion wasn't doing quite correctly either: We cannot assume the incoming Bn bits to be in a particular state, as for the addressing form in question they're ignored as well. To address both, introduce a helper function. This is then also an overall reduction of (source) code size (and use of "magic" numbers).
44 hoursx86-64: Remove pr19609-4c.d and pr19609-4d.dH.J. Lu4-30/+11
Remove pr19609-4c.d and pr19609-4d.d since they are identical to pr19609-4a.d and pr19609-4b.d, respectively. * testsuite/ld-x86-64/pr19609-4c.d: Removed. * testsuite/ld-x86-64/pr19609-4d.d: Likewise. * testsuite/ld-x86-64/pr19609-4e.d: Renamed to ... * testsuite/ld-x86-64/pr19609-4c.d: This. * testsuite/ld-x86-64/x86-64.exp: Updated. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 daysAdd translations for various sub-directoriesNick Clifton1-1808/+2041
4 dayss390: Generate .eh_frame unwind information for .plt sectionJens Remus4-4/+46
Enable unwinding using .eh_frame information through PLT entries. Based on x86-64. This enhances stack traces if the instruction pointer is in a PLT entry. For instance perf call graphs, when using --call-graph=dwarf, and Glibc backtraces, when using backtrace() e.g. from a signal handler. Note that GDB could already unwind through PLT entries using its s390- specific prologue unwinder. Furthermore this lays the foundation to generate SFrame information for the PLT section in the future. bfd/ * elf64-s390.c: Include dwarf2.h. (PLT_CIE_SIZE, PLT_FDE_SIZE, PLT_FDE_START_OFFSET, PLT_FDE_LEN_OFFSET, elf_s390x_eh_frame_plt): New .eh_frame template for .plt section. (elf_s390_link_hash_table): Add plt_eh_frame field. (elf_s390_create_dynamic_sections): New s390-specific wrapper around _bfd_elf_create_dynamic_sections. Create .eh_frame section for .plt section. (elf_backend_create_dynamic_sections): Register s390-specific elf_s390_create_dynamic_sections. (elf_s390_late_size_sections): Fill in .eh_frame section for .plt section. Write .plt section size into .eh_frame FDE covering .plt section. (elf_s390_finish_dynamic_sections): Write .plt section start into .eh_frame FDE covering .plt section. Call _bfd_elf_write_section_eh_frame on on htab->plt_eh_frame section. ld/ * NEWS: Add news entry. * emulparams/elf64_s390.sh: Include plt_unwind.sh. ld/testsuite/ * ld-s390/plt_64-1_eh.wf: New PLT .eh_frame generation test. * ld-s390/s390.exp: Link some existing test cases with --no-ld-generated-unwind-info so that they do not fail. Run new PLT .eh_frame generation test. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 dayss390: Add basic PLT generation testsJens Remus9-0/+316
ld/testsuite/ * ld-s390/plt_31_non-pic-1.pd: New non-PIC/PIE PLT generation test for 31-bit. * ld-s390/plt_31_pic-1.pd: New PIC/PIE PLT generation test for 31-bit. * ld-s390/plt_31-1.wf: New PLT generation test for 31-bit. * ld-s390/plt_64-1.pd: New PLT generation test for 64-bit. * ld-s390/plt_64-1.wf: Likewise. * ld-s390/plt-1.s: New PLT generation test for 31/64-bit. * ld-s390/pltlib.s: Likewise. * ld-s390/s390.exp: Run new PLT generation tests. Signed-off-by: Jens Remus <jremus@linux.ibm.com>
4 dayss390: Fix linker s390 emulation option parsingJens Remus1-3/+3
Append s390-specific emulation options to the shell variables instead of replacing their contents. ld/ * emultempl/s390.em (PARSE_AND_LIST_LONGOPTS, PARSE_AND_LIST_OPTIONS, PARSE_AND_LIST_ARGS_CASES): Append to emulation options instead of replacing them. Fixes: b4cbbe8f7294 ("S/390: Add support for pgste marker") Signed-off-by: Jens Remus <jremus@linux.ibm.com>
5 daysFix some broken links in docs and commentsYury Khrustalev1-3/+3
Reviewed-By Richard Earnshaw <richard.earnshaw@arm.com>
5 daysExclude libpthread from automatic export generationChristopher Wellons1-0/+2
Before this change, static linking libwinpthread, commonly distributed as part of Mingw-w64, while using automatic symbol exports would export the entire threading API, which is never wanted. This is always the case when static linking libstdc++ built against libpthread.
6 daysld-x86-64/pr19609-2d.d: Move "#pass" to the endH.J. Lu1-1/+1
* testsuite/ld-x86-64/pr19609-2d.d: Move "#pass" to the end. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
8 daysx86-64: tighten convert-load-reloc checkingJan Beulich3-0/+37
Even if the assembler avoids using relaxable relocations for inapplicable insns, such relocations can still appear for other reasons. Be more thorough in the opcode checking we do, to avoid bogusly altering other insns. Furthermore correct an opcode mask (even if with the added condition that's now fully benign).
8 daysx86/APX: widen @gotpcrel and @gottpoff support (incl to MOVRS)Jan Beulich13-185/+486
If legacy-encoded arithmetic insns are eligible for @gotpcrel relaxation, EVEX-encoded ones ought to be, too. Further anything that MOV-from-memory can be used for (and transformed from) should then also extend to MOVRS. While extending the apx-load* testcases add -mrelax-relocations=yes to the two ones which were missing this: Without this option the intended testing would not occur on configurations defaulting the option to off.
9 daysld: fix alignment issue for ARM thumb long branch stub using PureCode sectionTorbjörn SVENSSON4-1/+57
When pure-code option is activated. The linker creates for M-profile architecures a 2-bytes branch instruction. This causes the section alignment to be set to 2-byte alignment instead of 4-byte alignment. This is a problem for long branch stub without pure-code section as it contains a 32-bit address as data, which is expected to be 4-byte aligned. Hence creating a long branch stub for PureCode section followed by a long branch stub will result in a misalignment for the 32-bit address. An easy fix is to add a nop instruction after the branch to keep the section alignment to 4 bytes. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Co-authored-by: Guillaume VACHERIAS <guillaume.vacherias@st.com>
9 daysld plugin.c concat leaksAlan Modra3-38/+74
* ldlang.c: Whitespace. (stat_free, stat_concat): New functions. * ldlang.h (stat_free, stat_concat): Declare. * plugin.c (asymbol_from_plugin_symbol): Use stat_concat.
9 daysAnother ldelf_before_allocation leakAlan Modra1-8/+6
This fixes an even more obvious leak. * ldelf.c (ldelf_before_allocation): Free copied elf_dt_audit. Simplify loop.
9 daysMore ld testsuite fixesAlan Modra2-466/+459
* testsuite/ld-elf/indirect.exp: Run compiler capability checks using run_host_noleak. * testsuite/ld-ifunc/ifunc.exp: Don't exit without restoring ASFLAGS. Don't run ifuncmod5 twice.
9 daysld: fix bashism in scripttempl/elf.scSam James1-1/+1
ld/ PR ld/32580 * scripttempl/elf.sc: Fix '==' bashism.
10 daysld: replace another @progbits etc in an ELF testcaseJan Beulich1-5/+5
The canonical form (in the testsuite) is %progbits and alike.
11 daysMore updated translationsNick Clifton1-1804/+2006
11 daysasan ld builds without detect_leaks=0Alan Modra2-12/+28
I found that building binutils with -fsanitize=address,undefined results in much of the testsuite not being run. The problem is that running gcc results in linker plugin memory leaks which of course are errors, so the testsuite sees this as lack of compiler support. * testsuite/lib/ld-lib.exp (run_host_noleak): New proc. (check_compiler_available, check_lto_available), (check_lto_fat_available, check_lto_shared_available), (check_ifunc_available, check_ifunc_attribute_available), (check_libdl_available, check_gnu2_tls_available), (compile_one_cc): Use run_host_noleak. * testsuite/config/default.exp (compiler_supports): Likewise.
11 daysLD: Remove duplicate 2.44 NEWS markerMaciej W. Rozycki1-2/+0
Delete an extra 2.44 NEWS marker that has crept in by chance.
11 daysUpdate translations for various sub-directoriesNick Clifton3-6212/+7659
11 daysgas/NEWS,ld/NEWS: Announce LoongArch changes in 2.44Lulu Cai1-0/+2
12 daysldelf_before_allocation leakAlan Modra3-5/+5
ldelf_before_allocation is passed the audit and depaudit strings built from command line args, then possibly adds to the depaudit string, freeing the original. The new string isn't freed. Fix this leak by keeping the string attached to the static vars. * ldelf.c (ldelf_before_allocation): Pass char** for audit and depaudit. Adjust uses. * ldelf.h (ldelf_before_allocation): Update prototype. * gld${EMULATION_NAME}_before_allocation: Update call.
12 dayssec->alloced and freeing section contentsAlan Modra1-0/+1
This modifies _bfd_elf_free_cached_info to unmap/free section contents. To do that we need to *not* free sections where contents are bfd_alloc'd or point to constant strings or somesuch. I've chosen to implement this be adding another flag to struct bfd_section, "alloced" to say the section contents can't be freed. Most of the patch is about setting that flag in many places.
12 daysReplace xmalloc with stat_alloc in ld parserAlan Modra7-104/+74
A few place dealing with ld script handling made some attempt to free memory, but this was generally ignored and would be quite a lot of work to implement. Instead, use the stat_obstack rather than mallocing in many more cases. * ldexp.c (exp_get_fill): Use stat_alloc for fill. * ldfile.c (ldfile_try_open_bfd): Don't free yylval fields. * ldgram.y: Replace xmalloc with stat_alloc throughout. * ldlang.c (stat_memdup, stat_strdup): New functions. (ldirname): Use stat_memdup. Don't strdup ".". (output_section_callback_sort): Use stat_alloc. (output_section_callback_tree_to_list): Don't free. (lang_memory_region_lookup): Use stat_strdup. (lang_memory_region_alias): Likewise. (add_excluded_libs): Use stat_alloc and stat_memdup. (ldlang_add_undef, ldlang_add_require_defined): Use stat_strdup. (lang_add_nocrossref, lang_leave_overlay): Use stat_alloc. (realsymbol): Use stat_strdup for return value and always free symbol. (lang_new_vers_pattern, lang_new_vers_node): Use stat_alloc. (lang_finalize_version_expr_head): Don't free. Delete FIXME. (lang_register_vers_node): Don't free. (lang_add_vers_depend): Use stat_alloc. (lang_do_version_exports_section): Likewise. (lang_add_unique): Use stat_alloc and stat_strdup. (lang_append_dynamic_list): Use stat_alloc. * ldlang.h (stat_memdup, stat_strdup): Declare. * ldlex.l: Replace xstrdup with stat_strdup throughout. Replace xmemdup with stat_memdup too. * lexsup.c (parse_args): Don't free export list or dynamic list.
12 daysUse stat_alloc in pluginAlan Modra1-1/+1
We never free the tv array. * plugin.c (plugin_load_plugins): Use stat_alloc.
12 daysChange version to 2.44.50 and regenerate filesNick Clifton2-1814/+2043
13 daysAdd markers for bihnutils 2.44 branchNick Clifton2-0/+6
2025-01-17LoongArch: Allocate GOT entry for TLS DESC when -mno-relax is enabledLulu Cai5-0/+47
The type transition of TLSDESC is only done when -mrelax is enabled. So when -mno-relax is enabled, keep GOT_TLS_GDESC to allocate the GOT entry instead of just keeping GOT_TLS_IE.
2025-01-17cmdline_add_object_only_section leakAlan Modra1-7/+7
Free ofilename on error path. Don't bother testing "if (foo)" before "free (foo)".
2025-01-17buffer overflow in cmdline_add_object_only_sectionAlan Modra1-1/+1
Seen running ld-plugin/lto-4r-c on x86_64-w64-mingw32 * ldlang.c (cmdline_add_object_only_section): Allocate one more for output symbol buffer.
2025-01-17ld: Load the object only section when opening the mixed object fileH.J. Lu3-49/+74
Load the object only section when opening the mixed object file, instead of loading it after all other input files have been loaded. This fixed .../ld/collect-ld: /tmp/ccZAoUIW.obj-only.o: in function `main': .../ld/testsuite/ld-plugin/lto-10a.c:4: multiple definition of `main'; /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0x0): first defined here .../ld/collect-ld: /usr/x86_64-w64-mingw32/sys-root/mingw/lib/../lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o):(.text.startup+0xc5): undefined reference to `WinMain' collect2: error: ld returned 1 exit status ... FAIL: LTO 10 for x86_64-w64-mingw32 so that mixing LTO and non-LTO relocatable files for "ld -r" works for both ELF and non-ELF platforms. * ld.texi: Remove "On ELF platforms" from documentation of mixing LTO and non-LTO relocatable files for "ld -r". * ldlang.c (cmdline_load_object_only_section): New. (cmdline_check_object_only_section): Call it. * testsuite/ld-plugin/lto.exp: Enable mixed LTO and non-LTO relocatable output tests for all. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-17xtensa unnecessary freeAlan Modra1-1/+0
No path to "cleanup" label has internal_relocs malloc'd. * emultempl/xtensaelf.em (replace_insn_sec_with_prop_sec): Don't free internal_relocs in cleanup.
2025-01-17Re: ld parser buffer leakAlan Modra1-2/+2
Apparently reflex doesn't have yyalloc. * ldlex.l (yy_create_string_buffer): Revert last change.
2025-01-17plugin_get_ir_dummy_bfd leakAlan Modra1-6/+5
* plugin.c (plugin_get_ir_dummy_bfd): Free bfd filename.
2025-01-17ld parser buffer leakAlan Modra1-2/+3
* ldlex.l (<<EOF>>): yy_delete_buffer current. (yy_create_string_buffer): Use yyalloc.
2025-01-17write_build_id and write_package_metadata leaksAlan Modra1-18/+20
There isn't much sense in stashing contents in sec->contents after those contents have been written. * ldelf.c (write_build_id): Don't assign sec->contents. Free contents if malloc'd here. (write_package_metadata): Likewise.
2025-01-17ldelf_search_needed leakAlan Modra1-1/+4
* ldelf.c (ldelf_search_needed): Free filename before returning.
2025-01-17free ldfile search pathsAlan Modra3-7/+54
* ldfile.c (ldfile_remap_input_free): Make static, call from.. (ldfile_free): ..here. New function. (ldfile_library_path_free, ldfile_script_free), ( ldfile_arch_free): New functions. (ldfile_find_command_file): Free script_dir. Move script_search to file scope. (ldfile_open_command_file_1): Delete FIXME comment. * ldfile.h (ldfile_remap_input_free): Delete. (ldfile_free): Declare. * ldlang.c (lang_finish): Update.
2025-01-17output_section_statement leakAlan Modra1-0/+6
This frees output_section_statement data, which is currently only used by elf targets but doing so for all targets is simpler and more future proof than adding ths to ldelf_finish. (Doing it there requires moving the function to ldelfgen.c.) * ldemul.c (finish_default): Free os->data.
2025-01-17NEWS: Mention mixed LTO and non-LTO output support for ld -rH.J. Lu1-0/+2
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-15aarch64: GCS tests for linking issues with dynamic objectsMatthieu Longo18-0/+247
2025-01-15aarch64: check GCS feature in GNU properties of input dynamic objectsMatthieu Longo2-10/+54
The Guarded Control Stack (GCS) feature requires that two things: - at static link time, all the input objects of a link unit have to be compatible with GCS. - at runtime, the executable and the shared libraries which it depends on have to be compatible with GCS. Both of those criteria are checked with the GCS feature stored in the GNU property note. The previous patch, adding support for the GCS feature check in GNU note properties for input objects, ignored the input dynamic objects. Although this support was better than no check, it was still delaying the detection of compatibility issues up to the runtime linker. In order to help the developer in detecting such an incompatibility issue as early as possible, this patch adds a check for input dynamic objects lacking the GCS marking. This check can be controlled via the linker option '-z gcs-report-dynamic[=none|warning|error]'. By default, if the option is omitted, it inherits the value from '-z gcs-report'. However, the inherited value is capped to 'warning' as a user might want to only report errors in the currently built module, and not the shared dependencies. If a user also wants to error on GCS issues in the shared libraries, '-z gcs-report-dynamic=error' will have to be specified explicitly.
2025-01-15ld: Update gld${EMULATION_NAME}_place_orphan for PE/PEPH.J. Lu2-22/+42
Similar to ldelf_place_orphan, initialize hold from orig_hold at run-time in PE and PEP gld${EMULATION_NAME}_place_orphan. * emultempl/pe.em (orphan_init_done): Make it file scope. (gld${EMULATION_NAME}_finish): Set orphan_init_done to false for the object-only output. (gld${EMULATION_NAME}_place_orphan): Rename hold to orig_hold. Initialize hold from orig_hold at run-time. * emultempl/pep.em (orphan_init_done): Make it file scope. (gld${EMULATION_NAME}_finish): Set orphan_init_done to false for the object-only output. (gld${EMULATION_NAME}_place_orphan): Rename hold to orig_hold. Initialize hold from orig_hold at run-time. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-15ld: Correct ldelf_place_orphanH.J. Lu1-7/+5
Remove the extra for loop and if statement in ldelf_place_orphan. * ldelf.c (ldelf_place_orphan): Remove the extra for loop and if statement. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-15Re: elf: Add GNU_PROPERTY_MEMORY_SEAL gnu propertyAlan Modra9-40/+30
Don't run tests on targets without required support. Supply an explicit -z nomemory-seal rather then relying on the harness default, to lessen confusion for people looking at the test. Don't use numeric labels for the sake of hppa64*-hpux, and run the tests there. Remove incorrect comment about source editing. Also, xfail rather than notarget failing tests with a list of target triples so we check that the list is correct.
2025-01-15Re: ld: Add --enable-memory-seal configure optionAlan Modra1-3/+2
Commit 80dc29527ff9 accidentally removed an assignment to board_flags, resulting in tcl errors 'can't read "board_flags": no such variable' on sh4-linux-gnu. Fix that by calling [get_board_flags] in the condition rather than reinstating the removed line since it seems most configurations don't have a null STATIC_LDFLAGS. Do the same in another similar test too.
2025-01-15ld: Parse linker script only onceH.J. Lu3-40/+28
Parsing linker script twice caused FAIL: ld-plugin/lto-3r FAIL: ld-plugin/lto-5r FAIL: PR ld/19317 (2) for x86_64-w64-mingw32 with the linker error: ./ld-new:built in linker script:27 assignment to location counter invalid outside of SECTIONS ldscripts/i386pep.xr has 24 .rdata : 25 { 26 *(.rdata) 27 . = ALIGN(4); 28 /* .ctors & .dtors */ 29 /* .CRT */ 30 /* ___crt_xl_end__ is defined in the TLS Directory support code */ 31 } Remove ld_parse_linker_script to parse linker script only once. * ldlang.c (cmdline_emit_object_only_section): Don't call ld_parse_linker_script. * ldmain.c (main): Fold ld_parse_linker_script. (ld_parse_linker_script): Removed. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-15ld: Call cmdline_check_object_only_section only if plugin is enabledH.J. Lu1-1/+1
* ldmain.c (add_archive_element): Call cmdline_check_object_only_section only if BFD_SUPPORTS_PLUGINS is defined. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>