diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2024-11-07 12:39:19 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2024-11-11 19:47:44 +0800 |
commit | 023e60ced0c850aa32ac4a948877d25592d44401 (patch) | |
tree | a720cbf8beb8b78268919c896718a11e7c1f383f | |
parent | c0a07e7d48801c7cffaf825545fc05024a7c686e (diff) | |
download | binutils-023e60ced0c850aa32ac4a948877d25592d44401.zip binutils-023e60ced0c850aa32ac4a948877d25592d44401.tar.gz binutils-023e60ced0c850aa32ac4a948877d25592d44401.tar.bz2 |
ld: Move note sections after .rodata section
Move note sections after .rodata section so that note sections are
placed in the same PT_LOAD segment together with .rodata section,
instead of a separate PT_LOAD segment.
PR ld/32341
* scripttempl/misc-sections.sc: Move note sections to ...
* scripttempl/elf.sc: Here, after .rodata section.
* testsuite/ld-elf/pr32341.d: New file.
* testsuite/ld-elf/pr32341.s: Likewise.
Co-Authored-By: Nick Clifton <nickc@redhat.com>
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
-rw-r--r-- | ld/scripttempl/elf.sc | 11 | ||||
-rw-r--r-- | ld/scripttempl/misc-sections.sc | 11 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr32341.d | 15 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/pr32341.s | 26 |
4 files changed, 52 insertions, 11 deletions
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index 6ef93dc..84b4332 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -668,6 +668,17 @@ cat <<EOF .exception_ranges ${RELOCATING-0} : ONLY_IF_RO { *(.exception_ranges${RELOCATING+*}) } ${TEXT_PLT+${PLT_NEXT_DATA+${PLT} ${OTHER_PLT_SECTIONS}}} + /* Various note sections. Placed here so that they are included in the + read-only segment, and so that they are not treated as orphan sections. */ + .note.build-id : { *(.note.build-id) } ${RELOCATING+${REGION}} + .note.GNU-stack : { *(.note.GNU-stack) } ${RELOCATING+${REGION}} + .note.gnu-property : { *(.note.gnu-property) } ${RELOCATING+${REGION}} + .note.ABI-tag : { *(.note.ABI-tag) } ${RELOCATING+${REGION}} + .note.package : { *(.note.package) } ${RELOCATING+${REGION}} + .note.dlopen : { *(.note.dlopen) } ${RELOCATING+${REGION}} + .note.netbsd.ident : { *(.note.netbsd.ident) } ${RELOCATING+${REGION}} + .note.openbsd.ident : { *(.note.openbsd.ident) } ${RELOCATING+${REGION}} + ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (__${ETEXT_NAME} = .);}} ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (_${ETEXT_NAME} = .);}} ${RELOCATING+${ETEXT_LAST_IN_RODATA_SEGMENT+PROVIDE (${ETEXT_NAME} = .);}} diff --git a/ld/scripttempl/misc-sections.sc b/ld/scripttempl/misc-sections.sc index 71b1a6b..93ce9b2 100644 --- a/ld/scripttempl/misc-sections.sc +++ b/ld/scripttempl/misc-sections.sc @@ -30,15 +30,4 @@ cat <<EOF .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) } - /* Various note sections. Placed here so that they do not get - treated as orphan sections. */ - .note.build-id : { *(.note.build-id) } ${RELOCATING+${REGION}} - .note.GNU-stack : { *(.note.GNU-stack) } ${RELOCATING+${REGION}} - .note.gnu-property : { *(.note.gnu-property) } ${RELOCATING+${REGION}} - .note.ABI-tag : { *(.note.ABI-tag) } ${RELOCATING+${REGION}} - .note.package : { *(.note.package) } ${RELOCATING+${REGION}} - .note.dlopen : { *(.note.dlopen) } ${RELOCATING+${REGION}} - .note.netbsd.ident : { *(.note.netbsd.ident) } ${RELOCATING+${REGION}} - .note.openbsd.ident : { *(.note.openbsd.ident) } ${RELOCATING+${REGION}} - EOF diff --git a/ld/testsuite/ld-elf/pr32341.d b/ld/testsuite/ld-elf/pr32341.d new file mode 100644 index 0000000..eb76c3a --- /dev/null +++ b/ld/testsuite/ld-elf/pr32341.d @@ -0,0 +1,15 @@ +#ld: --build-id -z separate-code -z relro --rosegment +#readelf: -l --wide +#target: *-*-linux-gnu *-*-gnu* *-*-nacl* arm*-*-uclinuxfdpiceabi +#xfail: ![check_relro_support] + +#failif +#... +[ ]+LOAD[ ]+0x[0-9a-f x]+.* +#... +[ ]+LOAD[ ]+0x[0-9a-f x]+.* +#... +[ ]+LOAD[ ]+0x[0-9a-f x]+.* +#... +[ ]+LOAD[ ]+0x[0-9a-f x]+.* +#... diff --git a/ld/testsuite/ld-elf/pr32341.s b/ld/testsuite/ld-elf/pr32341.s new file mode 100644 index 0000000..11f31b7 --- /dev/null +++ b/ld/testsuite/ld-elf/pr32341.s @@ -0,0 +1,26 @@ + .text + .type start,"function" + .global start +start: + .type _start,"function" + .global _start +_start: + .type __start,"function" + .global __start +__start: + .type main,"function" + .global main +main: + .type _main,"function" + .global _main +_main: + .dc.a 0 + .section .rodata,"a" + .zero 8 + .bss + .zero 8 + .section .note.ABI-tag,"a" + .align 4 + .zero 32 + .ident "GCC: (GNU) 14.2.1" + .section .note.GNU-stack,"",%progbits |