x86: Skip __[start|stop]_SECNAME for --gc-sections -z start-stop-gc
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 1 Dec 2021 12:55:24 +0000 (04:55 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Dec 2021 11:55:10 +0000 (03:55 -0800)
commit794f2bba0f338d467bbf9c55b5aba415ecd5e138
treeb36f058ec24e9f353d9dae0589fcd3d4f8a83dee
parentc808def421f383a226198751d93239ded2b0d21d
x86: Skip __[start|stop]_SECNAME for --gc-sections -z start-stop-gc

Don't convert memory load to immediate load on __start_SECNAME and
__stop_SECNAME for --gc-sections -z start-stop-gc if all SECNAME
sections been garbage collected.

bfd/

PR ld/27491
* elf32-i386.c (elf_i386_convert_load_reloc): Skip __start_SECNAME
and __stop_SECNAME for --gc-sections -z start-stop-gc if the input
section been garbage collected.
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise.
* elfxx-x86.h (elf_x86_start_stop_gc_p): New function.

ld/
PR ld/27491
* testsuite/ld-i386/i386.exp: Run PR ld/27491 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr27491-1.s: New file.
* testsuite/ld-i386/pr27491-1a.d: Likewise.
* testsuite/ld-i386/pr27491-1b.d: Likewise.
* testsuite/ld-i386/pr27491-1c.d: Likewise.
* testsuite/ld-i386/pr27491-2.d: Likewise.
* testsuite/ld-i386/pr27491-2.s: Likewise.
* testsuite/ld-i386/pr27491-3.d: Likewise.
* testsuite/ld-i386/pr27491-3.s: Likewise.
* testsuite/ld-i386/pr27491-4.d: Likewise.
* testsuite/ld-i386/pr27491-4a.s: Likewise.
* testsuite/ld-i386/pr27491-4b.s: Likewise.
* testsuite/ld-x86-64/pr27491-1.s: Likewise.
* testsuite/ld-x86-64/pr27491-1a.d: Likewise.
* testsuite/ld-x86-64/pr27491-1b.d: Likewise.
* testsuite/ld-x86-64/pr27491-1c.d: Likewise.
* testsuite/ld-x86-64/pr27491-2.d: Likewise.
* testsuite/ld-x86-64/pr27491-2.s: Likewise.
* testsuite/ld-x86-64/pr27491-3.d: Likewise.
* testsuite/ld-x86-64/pr27491-3.s: Likewise.
* testsuite/ld-x86-64/pr27491-4.d: Likewise.
* testsuite/ld-x86-64/pr27491-4a.s: Likewise.
* testsuite/ld-x86-64/pr27491-4b.s: Likewise.
27 files changed:
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.h
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr27491-1.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-1a.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-1b.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-1c.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-2.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-2.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-3.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-3.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-4.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-4a.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr27491-4b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1a.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1b.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-1c.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-2.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-2.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-3.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-3.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-4.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-4a.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr27491-4b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp