diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-10-13 05:18:13 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2020-10-13 05:18:24 -0700 |
commit | 6bf4a34047452f882c5cc66bd85812ee1bb5a41c (patch) | |
tree | 2d96b0c8ef59de1d9e026497798470bc9504bb08 /gold/testsuite | |
parent | aac1d94f19492fb6bea7193497bce599952c429d (diff) | |
download | fsf-binutils-gdb-6bf4a34047452f882c5cc66bd85812ee1bb5a41c.zip fsf-binutils-gdb-6bf4a34047452f882c5cc66bd85812ee1bb5a41c.tar.gz fsf-binutils-gdb-6bf4a34047452f882c5cc66bd85812ee1bb5a41c.tar.bz2 |
gold: Properly align the NT_GNU_PROPERTY_TYPE_0 note
The NT_GNU_PROPERTY_TYPE_0 note should be aligned to 8 bytes for 64-bit
ELF as specified by gABI. A note section can be only placed in a PT_NOTE
segment with the same alignment.
PR gold/22914
PR gold/23535
* layout.cc (Layout::attach_allocated_section_to_segment): Place
a note section in a PT_NOTE segment with the same alignment. Set
the alignment of the PT_NOTE segment from the alignment of the
note section.
(Layout::create_note): Align the NT_GNU_PROPERTY_TYPE_0 note to 8
bytes for 64-bit ELF.
(Layout::segment_precedes): Place segments with larger alignments
first.
* output.cc (Output_segment::Output_segment): Initialize align_.
* output.h (Output_segment): Add align, set_align and align_.
* testsuite/Makefile.am (gnu_property_test.stdout): Pass -lhSWn
to $(TEST_READELF).
(gnu_property_test): Pass --build-id to ld.
* testsuite/Makefile.in: Regenerated.
* testsuite/gnu_property_test.sh (check_alignment): New.
Use check_alignment to check the NT_GNU_PROPERTY_TYPE_0 note
alignment. Verify that there are 2 PT_NOTE segments.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 4 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 4 | ||||
-rwxr-xr-x | gold/testsuite/gnu_property_test.sh | 20 |
3 files changed, 24 insertions, 4 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 0644e23..026d101 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -3306,9 +3306,9 @@ check_SCRIPTS += gnu_property_test.sh check_DATA += gnu_property_test.stdout MOSTLYCLEANFILES += gnu_property_test gnu_property_test.stdout: gnu_property_test - $(TEST_READELF) -n $< >$@ + $(TEST_READELF) -lhSWn $< >$@ gnu_property_test: gcctestdir/ld gnu_property_a.o gnu_property_b.o gnu_property_c.o - gcctestdir/ld -o $@ gnu_property_a.o gnu_property_b.o gnu_property_c.o + gcctestdir/ld --build-id -o $@ gnu_property_a.o gnu_property_b.o gnu_property_c.o gnu_property_main.o: gnu_property_main.c $(COMPILE) -c -o $@ $< gnu_property_a.o: gnu_property_a.S diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index dfcafcd..35c442e 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -9525,9 +9525,9 @@ uninstall-am: @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_2.o: exception_test_2.cc gcctestdir/as @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -Wa,-madd-bnd-prefix -o $@ $< @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_test.stdout: gnu_property_test -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -n $< >$@ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -lhSWn $< >$@ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_test: gcctestdir/ld gnu_property_a.o gnu_property_b.o gnu_property_c.o -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld -o $@ gnu_property_a.o gnu_property_b.o gnu_property_c.o +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld --build-id -o $@ gnu_property_a.o gnu_property_b.o gnu_property_c.o @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_main.o: gnu_property_main.c @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -o $@ $< @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@gnu_property_a.o: gnu_property_a.S diff --git a/gold/testsuite/gnu_property_test.sh b/gold/testsuite/gnu_property_test.sh index 4a2d217..1806d34 100755 --- a/gold/testsuite/gnu_property_test.sh +++ b/gold/testsuite/gnu_property_test.sh @@ -53,8 +53,28 @@ check_count() fi } +check_alignment () +{ + if egrep -q "Class:[ \t]+ELF64" "$1" + then + align=8 + else + align=4 + fi + if ! egrep -q ".note.gnu.property[ \t]+NOTE.*$align$" "$1" + then + echo "Wrong .note.gnu.property alignment in $1:" + egrep ".note.gnu.property[ \t]+NOTE.*$align" "$1" + exit 1 + fi +} + +check_alignment gnu_property_test.stdout + check_count gnu_property_test.stdout "GNU\s*0x[0-9a-f]*\s*NT_GNU_PROPERTY_TYPE_0" 1 +check_count gnu_property_test.stdout "^ NOTE" 2 + check gnu_property_test.stdout "stack size: 0x111100" check gnu_property_test.stdout "no copy on protected" check gnu_property_test.stdout "x86 ISA used: i486, SSE2, SSE4_2, AVX512CD" |