diff options
| author | Mark Wielaard <[email protected]> | 2025-08-26 14:51:54 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2025-08-28 18:13:52 +0200 |
| commit | 88d06525a723925f5209f14b4adaa4777c7b64dd (patch) | |
| tree | 606e2bb82e79e28232ee1d885dd40a25c2308f60 /tests | |
| parent | cc459edfe10f2e76b82cccb8543c2f264f478209 (diff) | |
elfclassify: Add --any-ar-member option to classify archive member
To determine whether an ELF archive contains a member of a particular
type add a new input option to eu-elfclassify --any-ar-member.
eu-elfclassify will match if a given file is an ELF archive and the
classification options apply to at least one of the members.
This can be used for example to check whether an ELF archive file
contains ELF members that can be stripped by using:
eu-elfclassify --ar-member --unstripped <ar-file>
* src/elfclassify.c (current_path): Drop const.
(flag_ar_member): New static bool.
(classify_flag_ar_member): new enum member.
(parse_opt): Handle classify_flag_ar_member.
(check_checks): New function taken from...
(process_current_path): ...here.
(check_ar_members): New function.
(main): Add ar-member to options. Update argp.doc.
* tests/run-elfclassify.sh: Add various --any-ar-member tests.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/run-elfclassify.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/run-elfclassify.sh b/tests/run-elfclassify.sh index fb14139d..a9b4ad76 100755 --- a/tests/run-elfclassify.sh +++ b/tests/run-elfclassify.sh @@ -325,3 +325,30 @@ testrun ${abs_top_builddir}/src/elfclassify --debug-only $debug_files testrun_compare ${abs_top_builddir}/src/elfclassify --debug-only --print $debug_files <<EOF $(echo $debug_files | sed -e "s/ /\n/g") EOF + +testfiles testarchive64.a test-ar-duplicates.a + +echo "any-ar-member unstripped" +# Both archives contain object files with symtabs +testrun_compare ${abs_top_builddir}/src/elfclassify --any-ar-member --unstripped --print testarchive64.a test-ar-duplicates.a <<EOF +testarchive64.a +test-ar-duplicates.a +EOF + +echo "any-ar-member not-unstripped" +# Empty (opposite of above) +testrun_compare ${abs_top_builddir}/src/elfclassify --any-ar-member --not-unstripped --print testarchive64.a test-ar-duplicates.a <<EOF +EOF + +echo "any-ar-member executable" +# Only test-ar-duplicates.a contains executables +testrun_compare ${abs_top_builddir}/src/elfclassify --any-ar-member --executable --print testarchive64.a test-ar-duplicates.a <<EOF +test-ar-duplicates.a +EOF + +echo "any-ar-member not-executable" +# All members in test-ar-duplicates.a are executables +# So only testarchive64.a has no-executable member(s) +testrun_compare ${abs_top_builddir}/src/elfclassify --any-ar-member --not-executable --print testarchive64.a test-ar-duplicates.a <<EOF +testarchive64.a +EOF |
