summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2025-08-27 14:57:44 +0200
committerMark Wielaard <[email protected]>2025-08-28 18:32:58 +0200
commit1c23d5929a2f52986b2452fe0e9d34b12b39b313 (patch)
tree76a5f3677f351709e349e178f43c6175ccad73f7 /tests
parent88d06525a723925f5209f14b4adaa4777c7b64dd (diff)
elfclassify: Add --has-debug-sections classification option
There is --unstripped but that is whether the ELF file can be stripped (further) by removing any .[z]debug_* sections or symbol table (.symtab section). The --has-debug-sections option only checks whether there are .[z]debug sections present. * src/elfclassify.c (is_has_debug_sections): New function. (enum classify_check): Add classify_has_debug_sections. (check_checks): Add and print (if verbose) classify_has_debug_sections value. (main): Add ar-member to options. Update argp.doc to explain different debug options (--unstripped, --has-debug-section and --debug-only). * tests/run-elfclassify.sh: Add various --has-debug-sections tests. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run-elfclassify.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/run-elfclassify.sh b/tests/run-elfclassify.sh
index a9b4ad76..7835fc97 100755
--- a/tests/run-elfclassify.sh
+++ b/tests/run-elfclassify.sh
@@ -254,6 +254,12 @@ testrun_compare ${abs_top_builddir}/src/elfclassify --unstripped --print $kmod_f
$(echo $kmod_files | sed -e "s/ /\n/g")
EOF
+echo "kmods are have debug sections"
+testrun ${abs_top_builddir}/src/elfclassify --has-debug-sections $kmod_files
+testrun_compare ${abs_top_builddir}/src/elfclassify --has-debug-sections --print $kmod_files <<EOF
+$(echo $kmod_files | sed -e "s/ /\n/g")
+EOF
+
echo "kmods are not debug-only"
testrun ${abs_top_builddir}/src/elfclassify --not-debug-only $kmod_files
testrun_compare ${abs_top_builddir}/src/elfclassify --not-debug-only --print $kmod_files <<EOF
@@ -299,6 +305,12 @@ testrun_compare ${abs_top_builddir}/src/elfclassify --unstripped --print $debug_
$(echo $debug_files | sed -e "s/ /\n/g")
EOF
+echo "debug-only files have debug sections"
+testrun ${abs_top_builddir}/src/elfclassify --has-debug-sections $debug_files
+testrun_compare ${abs_top_builddir}/src/elfclassify --has-debug-sections --print $debug_files <<EOF
+$(echo $debug_files | sed -e "s/ /\n/g")
+EOF
+
echo "debug-only files are not programs"
testrun ${abs_top_builddir}/src/elfclassify --not-program $debug_files
testrun_compare ${abs_top_builddir}/src/elfclassify --not-program --print $debug_files <<EOF
@@ -352,3 +364,16 @@ echo "any-ar-member not-executable"
testrun_compare ${abs_top_builddir}/src/elfclassify --any-ar-member --not-executable --print testarchive64.a test-ar-duplicates.a <<EOF
testarchive64.a
EOF
+
+echo "any-ar-member has-debug-sections"
+# Neither has members with actual debug sections. They both do have
+# members that have symtab so are unstripped (see above).
+testrun_compare ${abs_top_builddir}/src/elfclassify --any-ar-member --has-debug-sections --print testarchive64.a test-ar-duplicates.a <<EOF
+EOF
+
+echo "any-ar-member not-has-debug-sections"
+# Noth match (opposite of above)
+testrun_compare ${abs_top_builddir}/src/elfclassify --any-ar-member --not-has-debug-sections --print testarchive64.a test-ar-duplicates.a <<EOF
+testarchive64.a
+test-ar-duplicates.a
+EOF