This adds an initial pac-ret gadget scanner to the llvm-bolt-binary-analysis-tool. The scanner is taken from the prototype that was published last year at https://github.com/llvm/llvm-project/compare/main...kbeyls:llvm-project:bolt-gadget-scanner-prototype, and has been discussed in RFC https://discourse.llvm.org/t/rfc-bolt-based-binary-analysis-tool-to-verify-correctness-of-security-hardening/78148 and in the EuroLLVM 2024 keynote "Does LLVM implement security hardenings correctly? A BOLT-based static analyzer to the rescue?" [Video](https://youtu.be/Sn_Fxa0tdpY) [Slides](https://llvm.org/devmtg/2024-04/slides/Keynote/Beyls_EuroLLVM2024_security_hardening_keynote.pdf) In the spirit of incremental development, this PR aims to add a minimal implementation that is "fully working" on its own, but has major limitations, as described in the bolt/docs/BinaryAnalysis.md documentation in this proposed commit. These and other limitations will be fixed in follow-on PRs, mostly based on code already existing in the prototype branch. I hope incrementally upstreaming will make it easier to review the code. Note that I believe that this could also form the basis of a scanner to analyze correct implementation of PAuthABI.
40 lines
1.7 KiB
Plaintext
40 lines
1.7 KiB
Plaintext
# This file tests error messages produced on invalid command line arguments.
|
|
# It also checks that help messages are generated as expected.
|
|
|
|
# Verify that an error message is provided if an input file is missing or incorrect
|
|
|
|
RUN: not llvm-bolt-binary-analysis 2>&1 | FileCheck -check-prefix=NOFILEARG %s
|
|
NOFILEARG: llvm-bolt-binary-analysis: Not enough positional command line arguments specified!
|
|
NOFILEARG-NEXT: Must specify at least 1 positional argument: See: {{.*}}llvm-bolt-binary-analysis --help
|
|
|
|
RUN: not llvm-bolt-binary-analysis non-existing-file 2>&1 | FileCheck -check-prefix=NONEXISTINGFILEARG %s
|
|
NONEXISTINGFILEARG: llvm-bolt-binary-analysis: 'non-existing-file': No such file or directory.
|
|
|
|
RUN: not llvm-bolt-binary-analysis %p/Inputs/dummy.txt 2>&1 | FileCheck -check-prefix=NOELFFILEARG %s
|
|
NOELFFILEARG: llvm-bolt-binary-analysis: '{{.*}}/Inputs/dummy.txt': The file was not recognized as a valid object file.
|
|
|
|
RUN: %clang %cflags -Wl,--emit-relocs %p/../../Inputs/asm_foo.s %p/../../Inputs/asm_main.c -o %t.exe
|
|
RUN: llvm-bolt-binary-analysis %t.exe 2>&1 | FileCheck -check-prefix=VALIDELFFILEARG --allow-empty %s
|
|
# Check that there are no BOLT-WARNING or BOLT-ERROR output lines
|
|
VALIDELFFILEARG: BOLT-INFO:
|
|
VALIDELFFILEARG-NOT: BOLT-WARNING:
|
|
VALIDELFFILEARG-NOT: BOLT-ERROR:
|
|
|
|
# Check --help output
|
|
|
|
RUN: llvm-bolt-binary-analysis --help 2>&1 | FileCheck -check-prefix=HELP %s
|
|
|
|
HELP: OVERVIEW: BinaryAnalysis
|
|
HELP-EMPTY:
|
|
HELP-NEXT: USAGE: llvm-bolt-binary-analysis [options] <executable>
|
|
HELP-EMPTY:
|
|
HELP-NEXT: OPTIONS:
|
|
HELP-EMPTY:
|
|
HELP-NEXT: BinaryAnalysis options:
|
|
HELP-EMPTY:
|
|
HELP-NEXT: --scanners=<value> - which gadget scanners to run
|
|
HELP-NEXT: =pacret - pac-ret
|
|
HELP-NEXT: =all - all
|
|
HELP-EMPTY:
|
|
HELP-NEXT: Generic Options:
|