summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2018-10-13 10:27:47 +0200
committerMark Wielaard <[email protected]>2018-10-17 13:49:53 +0200
commitc06ab0bbb4761a69d2f188675d21d1a9131e9ecb (patch)
treecf6bc383262aaed1029562f2364893acfa38ddd6 /tests
parent2876b3b648f665736ac9c879d34de5e3866ba8f9 (diff)
strip, unstrip: Handle SHT_GROUP correctly.
The usage of annobin in Fedora showed a couple of bugs when using eu-strip and eu-unstrip on ET_REL files that contain multiple group sections. When stripping we should not remove the SHF_GROUP flag from sections even if the group section itself might be removed. Either the section itself gets removed, and so the flag doesn't matter. Or it gets moved together with the group section into the debug file, and then it still needs to have the flag set. Also we would "renumber" the section group flag field (which isn't a section index, and so shouldn't be changed). Often the group sections have the exact same name (".group"), flags (none) and sometimes the same sizes. Which makes matching them hard. Extract the group signature and compare those when comparing two group sections. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog6
-rw-r--r--tests/Makefile.am1
-rwxr-xr-xtests/run-annobingroup.sh33
-rw-r--r--tests/testfile-annobingroup-x86_64.o.bz2bin0 -> 1437 bytes
4 files changed, 40 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 04eeb4ac..c5f0d774 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2018-09-12 Mark Wielaard <[email protected]>
+
+ * run-annobingroup.sh: Add x86_64 ET_REL testcase.
+ * testfile-annobingroup-x86_64.o.bz2: New test file.
+ * Makefile.am (EXTRA_DIST): Add testfile-annobingroup-x86_64.o.bz2.
+
2018-09-18 Mark Wielaard <[email protected]>
* backtrace-dwarf.c (thread_callback): Only error when
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 74c477e5..15b429b7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -199,6 +199,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.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 \
+ testfile-annobingroup-x86_64.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 700df321..fd36e4ac 100755
--- a/tests/run-annobingroup.sh
+++ b/tests/run-annobingroup.sh
@@ -120,4 +120,37 @@ EOF
testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup-i386.o remerged.elf
+# echo "void * foo (void) { return foo; }" > testfile-annobingroup-x86_64.c
+# gcc -g -O2 -fplugin=annobin -c testfile-annobingroup-x86_64.c
+testfiles testfile-annobingroup-x86_64.o
+
+testrun_compare ${abs_top_builddir}/src/readelf -g testfile-annobingroup-x86_64.o << EOF
+
+Section group [ 1] '.group' with signature '.text.hot.group' contains 3 entries:
+ [11] .text.hot
+ [12] .gnu.build.attributes.hot
+ [13] .rela.gnu.build.attributes.hot
+
+Section group [ 2] '.group' with signature '.text.unlikely.group' contains 3 entries:
+ [14] .text.unlikely
+ [15] .gnu.build.attributes.unlikely
+ [16] .rela.gnu.build.attributes.unlikely
+
+Section group [ 3] '.group' with signature '.text.hot..group' contains 1 entry:
+ [26] .text.hot
+
+Section group [ 4] '.group' with signature '.text.unlikely..group' contains 1 entry:
+ [27] .text.unlikely
+EOF
+
+testrun ${abs_top_builddir}/src/strip -o stripped.elf -f debugfile.elf testfile-annobingroup-x86_64.o
+
+# This would/should work, except for the unknown NOTEs.
+# testrun ${abs_top_builddir}/src/elflint --gnu stripped.elf
+# testrun ${abs_top_builddir}/src/elflint --gnu --debug debugfile.elf
+
+testrun ${abs_top_builddir}/src/unstrip -o remerged.elf stripped.elf debugfile.elf
+
+testrun ${abs_top_builddir}/src/elfcmp testfile-annobingroup-x86_64.o remerged.elf
+
exit 0
diff --git a/tests/testfile-annobingroup-x86_64.o.bz2 b/tests/testfile-annobingroup-x86_64.o.bz2
new file mode 100644
index 00000000..ec389db2
--- /dev/null
+++ b/tests/testfile-annobingroup-x86_64.o.bz2
Binary files differ