Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

undefined reference to MemStream::MemStream.... #4

Open
mzs555557 opened this issue Sep 27, 2022 · 1 comment
Open

undefined reference to MemStream::MemStream.... #4

mzs555557 opened this issue Sep 27, 2022 · 1 comment

Comments

@mzs555557
Copy link

when I use libfuzzer in libafl to fuzz xpdf4.04. there are some issues:( , how can i solve it?
the build command is

./target/release/libafl_cxx ./fuzz_JBIG2.cc ./xpdf-4.04/build/*/*.a -I ./xpdf-4.04/xpdf/ -I xpdf-4.04/goo -I xpdf-4.04/fofi/ -I xpdf-4.04/splash/ -I xpdf-4.04/ -I xpdf-4.04/build/ -o fuzzer_pdfload -lm -ldl -lpthread -lstdc++ -lgcc -lutil -lrt

the issue report is :

/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x25
/tmp/fuzz_JBIG2-84770a.o: in function `LLVMFuzzerTestOneInput':
fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0xa7): undefined reference to `MemStream::MemStream(char*, unsigned int, unsigned int, Object*)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0xbe): undefined reference to `GlobalParams::GlobalParams(char const*)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0xd1): undefined reference to `globalParams'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0xe1): undefined reference to `GlobalParams::setErrQuiet(int)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0xf7): undefined reference to `GlobalParams::setupBaseFonts(char const*)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x10c): undefined reference to `GlobalParams::setEnableFreeType(char*)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x125): undefined reference to `GlobalParams::setErrQuiet(int)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x139): undefined reference to `PDFDoc::PDFDoc(BaseStream*, GString*, GString*, PDFCore*)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x18e): undefined reference to `XRef::fetch(int, int, Object*, int)'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x20b): undefined reference to `globalParams'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x223): undefined reference to `Object::free()'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x239): undefined reference to `PDFDoc::~PDFDoc()'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x259): undefined reference to `GlobalParams::~GlobalParams()'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x3b2): undefined reference to `PDFDoc::~PDFDoc()'
/usr/bin/ld: fuzz_JBIG2.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x3d7): undefined reference to `globalParams'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@epi052
Copy link
Owner

epi052 commented Sep 29, 2022

try this (note the reordering of arguments so includes are first, and static libs follow the .cc)

./target/release/libafl_cxx -I ./xpdf-4.04/xpdf/ -I xpdf-4.04/goo -I xpdf-4.04/fofi/ -I xpdf-4.04/splash/ -I xpdf-4.04/ -I xpdf-4.04/build/ -o fuzzer_pdfload ./fuzz_JBIG2.cc ./xpdf-4.04/build/*/*.a -lm -ldl -lpthread -lstdc++ -lgcc -lutil -lrt

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants