Age | Commit message (Collapse) | Author | Files | Lines |
|
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>
|
|
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>
|
|
Reviewed-By Richard Earnshaw <richard.earnshaw@arm.com>
|
|
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.
|
|
* testsuite/ld-x86-64/pr19609-2d.d: Move "#pass" to the end.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
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).
|
|
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.
|
|
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>
|
|
* 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.
|
|
This fixes an even more obvious leak.
* ldelf.c (ldelf_before_allocation): Free copied elf_dt_audit.
Simplify loop.
|
|
* 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.
|
|
ld/
PR ld/32580
* scripttempl/elf.sc: Fix '==' bashism.
|
|
The canonical form (in the testsuite) is %progbits and alike.
|
|
|
|
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.
|
|
Delete an extra 2.44 NEWS marker that has crept in by chance.
|
|
|
|
|
|
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.
|
|
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.
|
|
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.
|
|
We never free the tv array.
* plugin.c (plugin_load_plugins): Use stat_alloc.
|
|
|
|
|
|
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.
|
|
Free ofilename on error path. Don't bother testing "if (foo)" before
"free (foo)".
|
|
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.
|
|
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>
|
|
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.
|
|
Apparently reflex doesn't have yyalloc.
* ldlex.l (yy_create_string_buffer): Revert last change.
|
|
* plugin.c (plugin_get_ir_dummy_bfd): Free bfd filename.
|
|
* ldlex.l (<<EOF>>): yy_delete_buffer current.
(yy_create_string_buffer): Use yyalloc.
|
|
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.
|
|
* ldelf.c (ldelf_search_needed): Free filename before returning.
|
|
* 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.
|
|
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.
|
|
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
|
|
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.
|
|
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>
|
|
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>
|
|
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.
|
|
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.
|
|
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>
|
|
* 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>
|
|
80dc29527ff9b5179741c360418e77e5064f2b69 contained some changes from
non-vanilla autoconf. Regenerate.
ChangeLog:
* config.in: Regenerate.
* configure: Regenerate.
|
|
Add --enable-memory-seal linker configure option to enable memory
sealing (GNU_PROPERTY_MEMORY_SEAL) by default.
Change-Id: I4ce4ff33657f0f09b1ceb06210b6fcaa501f1799
|
|
The GNU_PROPERTY_MEMORY_SEAL gnu property is a way to mark binaries
to be memory sealed by the loader, to avoid further changes of
PT_LOAD segments (such as unmapping or change permission flags).
This is done along with Linux kernel (the mseal syscall [1]), and
C runtime supports to instruct the kernel on the correct time during
program startup (for instance, after RELRO handling). This support
is added along the glibc support to handle the new gnu property [2].
This is a opt-in security features, like other security hardening
ones like NX-stack or RELRO.
The new property is ignored if present on ET_REL objects, and only
added on ET_EXEC/ET_DYN if the linker option is used. A gnu property
is used instead of DT_FLAGS_1 flag to allow memory sealing to work
with ET_EXEC without PT_DYNAMIC support (at least on glibc some ports
still do no support static-pie).
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8be7258aad44b5e25977a98db136f677fa6f4370
[2] https://sourceware.org/pipermail/libc-alpha/2024-September/160291.html
Change-Id: Id47fadabecd24be0e83cff45653f7ce9a900ecf4
|
|
Since mixed LTO and non-LTO relocatable output is only supported on ELF
platforms, limit these tests to ELF targets. Since powerpc64 elfv1
defines a function symbol on its procedure descriptor, which is in a
data section, rather than on the code for that function, allow both D
and T for nm test on mixed object.
* testsuite/ld-plugin/lto.exp: Limits mixed LTO and non-LTO
relocatable output tests to ELF targets. Allow both D and T for
nm test on mixed object.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
* ldfile.c (ldfile_try_open_bfd): Call
cmdline_check_object_only_section only if BFD_SUPPORTS_PLUGINS
is defined.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|