diff options
author | Alan Modra <amodra@gmail.com> | 2021-03-01 08:22:49 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-03-01 17:28:03 +1030 |
commit | 8ee10e86093150c70360d9e26b29e6d9b6398f33 (patch) | |
tree | d9b022e21486a83064279ec452009a394b62a8b0 /ld/testsuite/ld-gc | |
parent | 7824c1d22fcab8a68162634d4293f4a6666ca43e (diff) | |
download | gdb-8ee10e86093150c70360d9e26b29e6d9b6398f33.zip gdb-8ee10e86093150c70360d9e26b29e6d9b6398f33.tar.gz gdb-8ee10e86093150c70360d9e26b29e6d9b6398f33.tar.bz2 |
PR27451, -z start_stop_gc
When --gc-sections is in effect, a reference from a retained section
to __start_SECNAME or __stop_SECNAME causes all input sections named
SECNAME to also be retained, if SECNAME is representable as a C
identifier and either __start_SECNAME or __stop_SECNAME is synthesized
by the linker. Add an option to disable that feature, effectively
ignoring any relocation that references a synthesized linker defined
__start_ or __stop_ symbol.
PR 27451
include/
* bfdlink.h (struct bfd_link_info): Add start_stop_gc.
bfd/
* elflink.c (_bfd_elf_gc_mark_rsec): Ignore synthesized linker
defined start/stop symbols when start_stop_gc.
(bfd_elf_gc_mark_dynamic_ref_symbol): Likewise.
(bfd_elf_define_start_stop): Don't modify ldscript_def syms.
* linker.c (bfd_generic_define_start_stop): Likewise.
ld/
* emultempl/elf.em: Handle -z start-stop-gc and -z nostart-stop-gc.
* lexsup.c (elf_static_list_options): Display help for them. Move
help for -z stack-size to here from elf_shlib_list_options. Add
help for -z start-stop-visibility and -z undefs.
* ld.texi: Document -z start-stop-gc and -z nostart-stop-gc.
* NEWS: Mention -z start-stop-gc.
* testsuite/ld-gc/start2.s,
* testsuite/ld-gc/start2.d: New test.
* testsuite/ld-gc/gc.exp: Run it.
Diffstat (limited to 'ld/testsuite/ld-gc')
-rw-r--r-- | ld/testsuite/ld-gc/gc.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-gc/start2.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-gc/start2.s | 7 |
3 files changed, 18 insertions, 0 deletions
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp index b3245bb..ad3bc2e 100644 --- a/ld/testsuite/ld-gc/gc.exp +++ b/ld/testsuite/ld-gc/gc.exp @@ -89,6 +89,7 @@ test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func" run_dump_test "noent" run_dump_test "abi-note" run_dump_test "start" +run_dump_test "start2" run_dump_test "stop" run_dump_test "pr19167" if { [is_elf_format] } then { diff --git a/ld/testsuite/ld-gc/start2.d b/ld/testsuite/ld-gc/start2.d new file mode 100644 index 0000000..480dc74 --- /dev/null +++ b/ld/testsuite/ld-gc/start2.d @@ -0,0 +1,10 @@ +#name: --gc-sections with -z start-stop-gc +#ld: --gc-sections -e _start -z start-stop-gc +#nm: -n +#target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi +#xfail: bfin-*-*linux* frv-*-* + +#failif +#... +[0-9a-f]+ D +__start__foo +#... diff --git a/ld/testsuite/ld-gc/start2.s b/ld/testsuite/ld-gc/start2.s new file mode 100644 index 0000000..b0084a1 --- /dev/null +++ b/ld/testsuite/ld-gc/start2.s @@ -0,0 +1,7 @@ +.globl _start +_start: + .weak __start__foo + .dc.a __start__foo + .section _foo,"aw",%progbits +foo: + .long 1 |