Skip to content

Commit

Permalink
OSS-fuzz compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamas K Lengyel authored and el-tipton committed Apr 5, 2024
1 parent ae13585 commit f5d6051
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions HBFA/UefiHostTestTools/RunLibFuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ def updateBuildFlags(SanitizerFlags, buildProfraw):

profrawCcCovFlag = rb'-fprofile-instr-generate -fcoverage-mapping'
profrawLdCovFlag = rb'-fprofile-instr-generate -fcoverage-mapping'
LIB_FUZZING_ENGINE = os.getenv('LIB_FUZZING_ENGINE')
CXXFLAGS = os.getenv('CXXFLAGS')

# Patch with appropriate coverage and sanitizer
if buildProfraw:
Expand Down Expand Up @@ -354,20 +356,26 @@ def updateBuildFlags(SanitizerFlags, buildProfraw):
rb'GCC:*_LIBFUZZER_*_CC_FLAGS = '
rb'"-DTEST_WITH_LIBFUZZER=TRUE" -O1'
rb' -fsanitize=fuzzer' +
SanitizerFlags.encode(), raw)
SanitizerFlags.encode() +
rb' ' +
CXXFLAGS.encode(), raw)
raw = re.sub(rb'GCC:\*_LIBFUZZER_\*_DLINK2_FLAGS = -fsanitize='
rb'fuzzer,address',
rb'GCC:*_LIBFUZZER_*_DLINK2_FLAGS = -fsanitize=fuzzer'
+ SanitizerFlags.encode(), raw)
+ SanitizerFlags.encode() +
rb' ' +
LIB_FUZZING_ENGINE.encode(), raw)
raw = re.sub(rb'GCC:\*_CLANG8_\*_CC_FLAGS = -O1 -fsanitize=address'
rb' -fprofile-arcs -ftest-coverage',
rb'GCC:*_CLANG8_*_CC_FLAGS = -O1 -fsanitize='
+ SanitizerFlags[1::].encode() +
rb' -fprofile-arcs -ftest-coverage', raw)
rb' -fprofile-arcs -ftest-coverage ' +
CXXFLAGS.encode(), raw)
raw = re.sub(rb'GCC:\*_CLANG8_\*_DLINK2_FLAGS = -fsanitize=address'
rb' --coverage', rb'GCC:*_CLANG8_*_DLINK2_FLAGS = '
rb'-fsanitize=' + SanitizerFlags[1::].encode() +
rb' --coverage', raw)
rb' --coverage ' +
LIB_FUZZING_ENGINE.encode(), raw)

# Write out file
fws = open(OutputBuildOptionFile, 'wb')
Expand Down

0 comments on commit f5d6051

Please sign in to comment.