diff options
| author | Mark Wielaard <[email protected]> | 2018-07-24 23:34:19 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2018-07-27 14:09:21 +0200 |
| commit | 9718c94bbce0dabe0ce048efa3a2a6d1ea08bce5 (patch) | |
| tree | 469ba082b135e545cbc803353c2860775cf84318 /tests | |
| parent | 98ec9737922faef025ab10de15b9a653f46eaf53 (diff) | |
unstrip: Also check sh_size in compare_unalloc_sections.
compare_unalloc_sections only checked sh_flags and the section names.
This would cause stripped/debug section mismatches when there were
multiple sections with the same name and flags. Fix this by also checking
the size of the section matches.
Add a testcase that has two ".group" sections created on i386 with the
gcc annobin plugin.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ChangeLog | 6 | ||||
| -rw-r--r-- | tests/Makefile.am | 1 | ||||
| -rwxr-xr-x | tests/run-annobingroup.sh | 55 | ||||
| -rw-r--r-- | tests/testfile-annobingroup-i386.o.bz2 | bin | 0 -> 1387 bytes |
4 files changed, 62 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index 45844b14..2a20ffa5 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2018-07-24 Mark Wielaard <[email protected]> + + * run-annobingroup.sh: Add testfile-annobingroup-i386.o tests. + * testfile-annobingroup-i386.o.bz2: New test file. + * Makefile.am (EXTRA_DIST): Add testfile-annobingroup-i386.o.bz2. + 2018-07-21 Mark Wielaard <[email protected]> * run-annobingroup.sh: New test. diff --git a/tests/Makefile.am b/tests/Makefile.am index b7a0e173..29460834 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -195,6 +195,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ run-strip-test12.sh \ run-strip-nothing.sh run-strip-remove-keep.sh run-strip-g.sh \ run-annobingroup.sh testfile-annobingroup.o.bz2 \ + testfile-annobingroup-i386.o.bz2 \ run-strip-strmerge.sh run-strip-nobitsalign.sh \ testfile-nobitsalign.bz2 testfile-nobitsalign.strip.bz2 \ run-strip-reloc.sh hello_i386.ko.bz2 hello_x86_64.ko.bz2 \ diff --git a/tests/run-annobingroup.sh b/tests/run-annobingroup.sh index 5f08b35f..700df321 100755 --- a/tests/run-annobingroup.sh +++ b/tests/run-annobingroup.sh @@ -65,4 +65,59 @@ EOF testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup.o remerged.elf +# echo "void * __attribute__((cold)) foo (void) { return foo; }" +# > testfile-annobingroup-i386.c +# gcc -fpic -g -O2 -fplugin=annobin -c testfile-annobingroup-i386.c +testfiles testfile-annobingroup-i386.o + +testrun_compare ${abs_top_builddir}/src/readelf -g testfile-annobingroup-i386.o << EOF + +Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries: + [ 8] .gnu.build.attributes..text.unlikely + [ 9] .rel.gnu.build.attributes..text.unlikely + [10] .text.unlikely + +COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry: + [13] .text.__x86.get_pc_thunk.ax +EOF + +testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup-i386.o + +testrun_compare ${abs_top_builddir}/src/readelf -g stripped.elf << EOF + +Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries: + [ 8] .gnu.build.attributes..text.unlikely + [ 9] .rel.gnu.build.attributes..text.unlikely + [10] .text.unlikely + +COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry: + [13] .text.__x86.get_pc_thunk.ax +EOF + +testrun_compare ${abs_top_builddir}/src/readelf -g debugfile.elf << EOF + +Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries: + [ 8] .gnu.build.attributes..text.unlikely + [ 9] .rel.gnu.build.attributes..text.unlikely + [10] .text.unlikely + +COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry: + [13] .text.__x86.get_pc_thunk.ax +EOF + +testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf + +testrun_compare ${abs_top_builddir}/src/readelf -g remerged.elf << EOF + +Section group [ 1] '.group' with signature '.text.unlikely.group' contains 3 entries: + [ 8] .gnu.build.attributes..text.unlikely + [ 9] .rel.gnu.build.attributes..text.unlikely + [10] .text.unlikely + +COMDAT section group [ 2] '.group' with signature '__x86.get_pc_thunk.ax' contains 1 entry: + [13] .text.__x86.get_pc_thunk.ax +EOF + +testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup-i386.o remerged.elf + exit 0 diff --git a/tests/testfile-annobingroup-i386.o.bz2 b/tests/testfile-annobingroup-i386.o.bz2 Binary files differnew file mode 100644 index 00000000..798eefda --- /dev/null +++ b/tests/testfile-annobingroup-i386.o.bz2 |
