mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-27 03:51:15 +08:00
ld: Ignore .note.gnu.build-id when placing orphaned notes
The commits:e8e10743f7
Add --rosegment option to BFD linker to stop the '-z separate-code' from generating two read-only segments.bf6d7087de
ld: Move the .note.build-id section to near the start of the memory map place .note.gnu.build-id before text sections when --rosegment is used. Ignore .note.gnu.build-id when placing orphaned notes if --rosegment and -z separate-code are used together to avoid putting any note sections between .note.gnu.build-id and text sections in the same PT_LOAD segment. PR ld/32191 * ldlang.c (lang_insert_orphan): Ignore .note.gnu.build-id when placing orphaned notes. * testsuite/ld-elf/pr23658-1a.d: Pass --no-rosegment to ld. * testsuite/ld-elf/pr23658-1c.d: Likewise. * testsuite/ld-elf/pr23658-1e.d: New file. * testsuite/ld-elf/pr23658-1f.d: Likewise. * testsuite/ld-i386/i386.exp: Run PR ld/32191 test. * testsuite/ld-i386/pr32191.d: New file. * testsuite/ld-x86-64/lam-u48.rd: Updated. * testsuite/ld-x86-64/lam-u57.rd: Likewise. * testsuite/ld-x86-64/pr32191-x32.d: New file. * testsuite/ld-x86-64/pr32191.d: Likewise. * testsuite/ld-x86-64/pr32191.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run PR ld/32191 tests. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
parent
174e5e38b9
commit
052940eba6
14
ld/ldlang.c
14
ld/ldlang.c
@ -2047,13 +2047,25 @@ lang_insert_orphan (asection *s,
|
||||
place orphan note section after non-note sections. */
|
||||
|
||||
first_orphan_note = NULL;
|
||||
|
||||
/* NB: When --rosegment is used, the .note.gnu.build-id
|
||||
section is placed before text sections. Ignore the
|
||||
.note.gnu.build-id section if -z separate-code and
|
||||
--rosegment are used together to avoid putting any
|
||||
note sections between the .note.gnu.build-id section
|
||||
and text sections in the same PT_LOAD segment. */
|
||||
bool ignore_build_id = (link_info.separate_code
|
||||
&& link_info.one_rosegment);
|
||||
|
||||
for (sec = link_info.output_bfd->sections;
|
||||
(sec != NULL
|
||||
&& !bfd_is_abs_section (sec));
|
||||
sec = sec->next)
|
||||
if (sec != snew
|
||||
&& elf_section_type (sec) == SHT_NOTE
|
||||
&& (sec->flags & SEC_LOAD) != 0)
|
||||
&& (sec->flags & SEC_LOAD) != 0
|
||||
&& (!ignore_build_id
|
||||
|| strcmp (sec->name, ".note.gnu.build-id") != 0))
|
||||
{
|
||||
if (!first_orphan_note)
|
||||
first_orphan_note = sec;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#source: pr23658-1c.s
|
||||
#source: pr23658-1d.s
|
||||
#source: start.s
|
||||
#ld: --build-id
|
||||
#ld: --build-id --no-rosegment
|
||||
#readelf: -l --wide
|
||||
# Since generic linker targets don't place SHT_NOTE sections as orphan,
|
||||
# SHT_NOTE sections aren't grouped nor sorted.
|
||||
|
@ -3,7 +3,7 @@
|
||||
#source: pr23658-1c.s
|
||||
#source: pr23658-1d.s
|
||||
#source: start.s
|
||||
#ld: --build-id -shared
|
||||
#ld: --build-id --no-rosegment -shared
|
||||
#readelf: -l --wide
|
||||
#target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi
|
||||
#xfail: ![check_shared_lib_support]
|
||||
|
23
ld/testsuite/ld-elf/pr23658-1e.d
Normal file
23
ld/testsuite/ld-elf/pr23658-1e.d
Normal file
@ -0,0 +1,23 @@
|
||||
#source: pr23658-1a.s
|
||||
#source: pr23658-1b.s
|
||||
#source: pr23658-1c.s
|
||||
#source: pr23658-1d.s
|
||||
#source: start.s
|
||||
#ld: --build-id -z separate-code --rosegment
|
||||
#readelf: -l --wide
|
||||
# Since generic linker targets don't place SHT_NOTE sections as orphan,
|
||||
# SHT_NOTE sections aren't grouped nor sorted. .note.gnu.build-id is
|
||||
# placed before text sections and there should no other note sections
|
||||
# between .note.gnu.build-id and text sections.
|
||||
#xfail: [uses_genelf]
|
||||
#xfail: m68hc12-*
|
||||
# The following targets don't support --build-id.
|
||||
#xfail: cr16-* crx-* visium-*
|
||||
# The following targets place .note.gnu.build-id in unusual places.
|
||||
#xfail: pru-*
|
||||
|
||||
#...
|
||||
+[0-9]+ +\.note.gnu.build-id +
|
||||
+[0-9]+ +\.note\.4 \.note\.1 +
|
||||
+[0-9]+ +\.note\.2 \.note\.3 +
|
||||
#pass
|
17
ld/testsuite/ld-elf/pr23658-1f.d
Normal file
17
ld/testsuite/ld-elf/pr23658-1f.d
Normal file
@ -0,0 +1,17 @@
|
||||
#source: pr23658-1a.s
|
||||
#source: pr23658-1b.s
|
||||
#source: pr23658-1c.s
|
||||
#source: pr23658-1d.s
|
||||
#source: start.s
|
||||
#ld: --build-id -z separate-code --rosegment -shared
|
||||
# .note.gnu.build-id is placed before text sections and there should
|
||||
# no other note sections between .note.gnu.build-id and text sections.
|
||||
#readelf: -l --wide
|
||||
#target: *-*-linux* *-*-gnu* arm*-*-uclinuxfdpiceabi
|
||||
#xfail: ![check_shared_lib_support]
|
||||
|
||||
#...
|
||||
+[0-9]+ +\.note.gnu.build-id +
|
||||
+[0-9]+ +\.note\.4 \.note\.1 +
|
||||
+[0-9]+ +\.note\.2 \.note\.3 +
|
||||
#pass
|
@ -514,6 +514,7 @@ run_dump_test "pr28870"
|
||||
run_dump_test "pr28894"
|
||||
run_dump_test "pr30787"
|
||||
run_dump_test "pr31047"
|
||||
run_dump_test "pr32191"
|
||||
|
||||
if { !([istarget "i?86-*-linux*"]
|
||||
|| [istarget "i?86-*-gnu*"]
|
||||
|
9
ld/testsuite/ld-i386/pr32191.d
Normal file
9
ld/testsuite/ld-i386/pr32191.d
Normal file
@ -0,0 +1,9 @@
|
||||
#source: ../ld-x86-64/pr32191.s
|
||||
#as: --32 -mx86-used-note=yes
|
||||
#ld: -shared -m elf_i386 -z separate-code --build-id --rosegment
|
||||
#readelf: -lW
|
||||
|
||||
#...
|
||||
+[0-9]+ +\.note\.gnu\.build-id \.text
|
||||
+[0-9]+ +\..* \.note\.gnu\.property .*
|
||||
#pass
|
@ -1,3 +1,4 @@
|
||||
#...
|
||||
Displaying notes found in: .note.gnu.property
|
||||
[ ]+Owner[ ]+Data size[ ]+Description
|
||||
GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
|
||||
|
@ -1,3 +1,4 @@
|
||||
#...
|
||||
Displaying notes found in: .note.gnu.property
|
||||
[ ]+Owner[ ]+Data size[ ]+Description
|
||||
GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0
|
||||
|
9
ld/testsuite/ld-x86-64/pr32191-x32.d
Normal file
9
ld/testsuite/ld-x86-64/pr32191-x32.d
Normal file
@ -0,0 +1,9 @@
|
||||
#source: pr32191.s
|
||||
#as: --x32 -mx86-used-note=yes
|
||||
#ld: -shared -m elf32_x86_64 -z separate-code --build-id --rosegment
|
||||
#readelf: -lW
|
||||
|
||||
#...
|
||||
+[0-9]+ +\.note\.gnu\.build-id \.text
|
||||
+[0-9]+ +\..* \.note\.gnu\.property .*
|
||||
#pass
|
9
ld/testsuite/ld-x86-64/pr32191.d
Normal file
9
ld/testsuite/ld-x86-64/pr32191.d
Normal file
@ -0,0 +1,9 @@
|
||||
#source: pr32191.s
|
||||
#as: --64 -mx86-used-note=yes
|
||||
#ld: -shared -m elf_x86_64 -z separate-code --build-id --rosegment
|
||||
#readelf: -lW
|
||||
|
||||
#...
|
||||
+[0-9]+ +\.note\.gnu\.build-id \.text
|
||||
+[0-9]+ +\..* \.note\.gnu\.property .*
|
||||
#pass
|
5
ld/testsuite/ld-x86-64/pr32191.s
Normal file
5
ld/testsuite/ld-x86-64/pr32191.s
Normal file
@ -0,0 +1,5 @@
|
||||
.text
|
||||
.global foo
|
||||
foo:
|
||||
.nops 4
|
||||
.section .note.GNU-stack,"",@progbits
|
@ -541,6 +541,8 @@ run_dump_test "tlsie5"
|
||||
run_dump_test "tlsdesc3"
|
||||
run_dump_test "tlsdesc4"
|
||||
run_dump_test "tlsdesc5"
|
||||
run_dump_test "pr32191"
|
||||
run_dump_test "pr32191-x32"
|
||||
|
||||
if { ![skip_sframe_tests] } {
|
||||
run_dump_test "sframe-simple-1"
|
||||
|
Loading…
Reference in New Issue
Block a user