使用 AFL++ 工具编译 CUPS:“在制作 PIE 对象时不能使用针对 ... 的重定位 R_X86_64_32;使用 -fPIE 重新编译”

问题描述 投票:0回答:1

我正在尝试使用 AFL++ 工具编译 CUPS 版本 2.4.2,按照此处 AFL++ 文档 (e) 部分中的说明进行操作:https://aflplus.plus/docs/fuzzing_in_depth/#e-instrumenting-the-target .

我将发布我用来构建的命令以及我得到的错误。

这是我用来构建代码的:

$ export LLVM_CONFIG="llvm-config-11"
$ CC=afl-clang-fast CXX=afl-clang-fast++ ./configure --disable-shared

$ make

这是产生的错误:

Linking ippevepcl...
afl-cc ++3.00c by Michal Zalewski, Laszlo Szekeres, Marc Heuse - mode: LLVM-PCGUARD
/usr/bin/ld: ippevepcl.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(raster-stubs.o): relocation R_X86_64_32 against `.text.cups_write_fd' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(raster-stream.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(string.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(transcode.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(array.o): relocation R_X86_64_32S against symbol `strcmp@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(globals.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(http.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(http-addr.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(http-addrlist.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(http-support.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(langprintf.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(language.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(options.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(request.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(tls.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(usersys.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(auth.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(file.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(hash.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(ipp.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(ipp-support.o): relocation R_X86_64_32S against `.rodata.ippAttributeString' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: ../cups/libcups.a(md5.o): relocation R_X86_64_32 against `.rodata' can not be used when making a PIE object; recompile with -fPIE
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:170: ippevepcl] Error 1
make: *** [Makefile:45: all] Error 1

这些是根据“make”命令的输出正在使用的实际标志:

DEBUG- MFLAGS=-s
Using ARCHFLAGS=
Using ALL_CFLAGS=-I.. -D_CUPS_SOURCE -D_FORTIFY_SOURCE=2  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT  -Wall -Wunused -Wno-char-subscripts -W
no-deprecated-declarations -Wno-format-y2k -Wno-switch -Wno-unused-result
Using ALL_CXXFLAGS=-I.. -D_CUPS_SOURCE -D_FORTIFY_SOURCE=2  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT  -Wall -Wunused -Wno-char-subscripts 
-Wno-deprecated-declarations -Wno-format-y2k -Wno-switch -Wno-unused-result
Using CC=afl-clang-fast
Using CXX=afl-clang-fast
Using DSOFLAGS=
Using LDFLAGS=
Using LIBS=  -lssl -lcrypto -lz -lpthread -lm -lcrypt   -lz

我是 AFL++ 的新手,说实话,对从源代码构建不太熟悉。在过去的几天里,我在同一系统(6.6.9-arch1-1)上成功地使用 AFL++ 工具编译了其他程序。

如果有人看到我做错了什么,我们将不胜感激。如果我遗漏了任何重要信息,请告诉我。

我还尝试使用“afl-clang-lto”编译器进行编译,如我上面链接的 AFL++ 文档的 (e) 部分所示,如下所示:

$ CC=afl-clang-lto CXX=afl-clang-fast++ ./configure --disable-shared

$ make

这也失败了,但有一个不同的错误:

Linking ppdc...
afl-cc ++3.00c by Michal Zalewski, Laszlo Szekeres, Marc Heuse - mode: LLVM-PCGUARD
/usr/bin/ld: ../cups/libcups.a: error adding symbols: archive has no index; run ranlib to add one
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:199: ppdc] Error 1
make: *** [Makefile:45: all] Error 1

此外,该程序使用常规 GCC 编译也没有问题。

fuzzing afl-fuzz
1个回答
0
投票

我最终回答了我自己的问题,我只是将答案发布在这里,以防对其他人有帮助。诀窍是在运行“./configure”脚本时使用“--enable-static”标志。

这些是使用 ASAN 和 afl-clang-fast 成功编译 CUPS 2.4.2 的命令。我认为这也可能适用于其他程序:

 $ make distclean

 $ make clean

 $ CC=afl-clang-fast CXX=afl-clang-fast++ ./configure --disable-shared --enable-static

 $ AFL_USE_ASAN=1 make

另请注意,我无法在 afl-cc++ 3.0 上使用它。不过,它对我使用 afl-cc+ 4.09 有效

© www.soinside.com 2019 - 2024. All rights reserved.