Error compilingLLVMFuzzerTestOneInput DWARF error: invalid or unhandled FORM value: 0x25

109 views Asked by At

My Project consists of the following

XPDF:

build with
wget https://dl.xpdfreader.com/old/xpdf-3.02.tar.gz
tar -xvzf xpdf-3.02.tar.gz
sudo apt update && sudo apt install -y build-essential gcc
cd $HOME/fuzzing_xpdf/xpdf-3.02/
CC=$HOME/AFLplusplus/afl-clang-fast CXX=$HOME/AFLplusplus/afl-clang-fast++ ./configure --prefix="$HOME/fuzzing_xpdf/install/"
make
make install

MyProject: -xpdf-3.02: Folder with XPDF -xpdf files -harness.cc -AFLplusplus: Folder with AFL++

harness.cc:

#include <fstream>
#include <iostream>
#include <stdint.h>
#include "PDFDoc.h"
#include "goo/gtypes.h"
#include "XRef.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    int lastPage = 0;

    GString *user_pw = NULL;
    GString *owner_pw = NULL;
    GString *filename = NULL;

    Object obj;
    obj.initNull();

    // stream is cleaned up when doc's destructor fires
    MemStream *stream = new MemStream((char *)data, 0, size, &obj);

    PDFDoc *doc = new PDFDoc(stream, owner_pw, user_pw);

    if (doc->isOk() && doc->okToCopy()) {
        lastPage = doc->getNumPages();
    }

    if (doc) { delete doc; }

    return 0;
}

Compile Call:

~/AFLplusplus/afl-clang-fast++ -I goo -I fofi -I splash  -I xpdf -I . -o fuzzer harness.cc */*.a -L/home/user/test_projekt/xpdf-3.02/goo -L/home/user/test_projekt/xpdf-3.02/fofi -L/home/user/test_projekt/xpdf-3.02/splash -lGoo -lfofi -lsplash -lm -ldl -lpthread -lstdc++ -lgcc -lutil -lrt

Error Code:

afl-cc++4.10c by Michal Zalewski, Laszlo Szekeres, Marc Heuse - mode: LLVM-PCGUARD
Ubuntu clang version 17.0.6 (++20231208085846+6009708b4367-1~exp1~20231208085949.74)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-17/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/lib/llvm-17/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir fuzzer- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name harness.cc -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/user/test_projekt/xpdf-3.02 -resource-dir /usr/lib/llvm-17/lib/clang/17 -I goo -I fofi -I splash -I xpdf -I . -D __AFL_COMPILER=1 -D FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1 -D "__AFL_COVERAGE()=int __afl_selective_coverage = 1;extern \"C\" void __afl_coverage_discard();extern \"C\" void __afl_coverage_skip();extern \"C\" void __afl_coverage_on();extern \"C\" void __afl_coverage_off();" -D "__AFL_COVERAGE_START_OFF()=int __afl_selective_coverage_start_off = 1;" -D __AFL_COVERAGE_ON()=__afl_coverage_on() -D __AFL_COVERAGE_OFF()=__afl_coverage_off() -D __AFL_COVERAGE_DISCARD()=__afl_coverage_discard() -D __AFL_COVERAGE_SKIP()=__afl_coverage_skip() -D __AFL_HAVE_MANUAL_CONTROL=1 -D "__AFL_FUZZ_INIT()=int __afl_sharedmem_fuzzing = 1;extern unsigned int *__afl_fuzz_len;extern unsigned char *__afl_fuzz_ptr;unsigned char __afl_fuzz_alt[1048576];unsigned char *__afl_fuzz_alt_ptr = __afl_fuzz_alt;" -D "__AFL_FUZZ_TESTCASE_BUF=(__afl_fuzz_ptr ? __afl_fuzz_ptr : __afl_fuzz_alt_ptr)" -D "__AFL_FUZZ_TESTCASE_LEN=(__afl_fuzz_ptr ? *__afl_fuzz_len : (*__afl_fuzz_len = read(0, __afl_fuzz_alt_ptr, 1048576)) == 0xffffffff ? 0 : *__afl_fuzz_len)" -D "__AFL_LOOP(_A)=({ static volatile const char *_B __attribute__((used,unused));  _B = (const char*)\"##SIG_AFL_PERSISTENT##\"; extern __attribute__((visibility(\"default\"))) int __afl_connected;__attribute__((visibility(\"default\"))) int _L(unsigned int) __asm__(\"__afl_persistent_loop\"); _L(__afl_connected ? _A : 1); })" -D "__AFL_INIT()=do { static volatile const char *_A __attribute__((used,unused));  _A = (const char*)\"##SIG_AFL_DEFER_FORKSRV##\"; __attribute__((visibility(\"default\"))) void _I(void) __asm__(\"__afl_manual_init\"); _I(); } while (0)" -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward -internal-isystem /usr/lib/llvm-17/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -Wno-unused-command-line-argument -fdeprecated-macro -fdebug-compilation-dir=/home/user/test_projekt/xpdf-3.02 -ferror-limit 19 -funroll-loops -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -fpass-plugin=/home/user/AFLplusplus/SanitizerCoveragePCGUARD.so -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/harness-c1b88a.o -x c++ harness.cc
clang -cc1 version 17.0.6 based upon LLVM 17.0.6 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/9/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 goo
 fofi
 splash
 xpdf
 .
 /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9
 /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/x86_64-linux-gnu/c++/9
 /usr/lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/backward
 /usr/lib/llvm-17/lib/clang/17/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
SanitizerCoveragePCGUARD++4.10c
Note: Found constructor function _GLOBAL__sub_I_harness.cc with prio 65535, we will not instrument this, putting it into a block list.
[+] Instrumented 5 locations with no collisions (non-hardened mode) of which are 0 handled and 0 unhandled selects.
 "/usr/bin/ld" -pie -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o fuzzer /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginS.o -L/home/user/test_projekt/xpdf-3.02/goo -L/home/user/test_projekt/xpdf-3.02/fofi -L/home/user/test_projekt/xpdf-3.02/splash -L/usr/lib/gcc/x86_64-linux-gnu/9 -L/usr/lib/gcc/x86_64-linux-gnu/9/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/harness-c1b88a.o AFLplusplus/libFuzzingEngine.a fofi/libfofi.a goo/libGoo.a splash/libsplash.a -lGoo -lfofi -lsplash -lm -ldl -lpthread -lstdc++ -lgcc -lutil -lrt /home/user/AFLplusplus/afl-compiler-rt.o --dynamic-list=/home/user/AFLplusplus/dynamic_list.txt -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/9/crtendS.o /lib/x86_64-linux-gnu/crtn.o
/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x25
/home/user/AFLplusplus/afl-compiler-rt.o: in function `__afl_trace':
afl-compiler-rt.o.c:(.text+0x0): multiple definition of `__afl_trace'; /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x25
AFLplusplus/libFuzzingEngine.a(afl-compiler-rt.o):afl-compiler-rt.o.c:(.text+0x0): first defined here
/usr/bin/ld: /home/user/AFLplusplus/afl-compiler-rt.o:(.tbss+0x0): multiple definition of `__afl_prev_loc'; AFLplusplus/libFuzzingEngine.a(afl-compiler-rt.o):(.tbss+0x0): first defined here 

...

/usr/bin/ld: /home/user/AFLplusplus/afl-compiler-rt.o:(.tbss+0x60): multiple definition of `__afl_prev_ctx'; AFLplusplus/libFuzzingEngine.a(afl-compiler-rt.o):(.tbss+0x60): first defined here
/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x25
/tmp/harness-c1b88a.o: in function `LLVMFuzzerTestOneInput':
harness.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x55): undefined reference to `MemStream::MemStream(char*, unsigned int, unsigned int, Object*)'
/usr/bin/ld: harness.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x74): undefined reference to `PDFDoc::PDFDoc(BaseStream*, GString*, GString*, void*)'
/usr/bin/ld: harness.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x9d): undefined reference to `XRef::okToCopy(int)'
/usr/bin/ld: harness.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0xbb): undefined reference to `PDFDoc::~PDFDoc()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I know think that it must be a problem with the libraries, but i don't know how to fix it. Thanks in advance for looking at the problem.

0

There are 0 answers