I want to compile nginx with CFI enforced by LLVM. I modify the Makefile in the objs directory. The modification includs: 1. change the compiler:cc--> clang 2. add parameters related with CFI: -flto -fvisibility=hidden -fsanitize=cfi The modified Makefile is illusrated below
CC = clang
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -flto -fvisibility=hidden -fsanitize=cfi
CPP = cc -E
LINK = $(CC)
The compilation process is passed. However, there are some errors are reported during the link process:
/usr/bin/ld: unrecognized option '-plugin'
/usr/bin/ld: use the --help option for usage information
clang-6.0: error: linker command failed with exit code 1 (use -v to see invocation)
According to the document of clang 6.0.0, the CFI schemes relies on link-time optimization(LTO), and the linker used must support LTO (such as gold plugin). There are some materials about LTO:
http://llvm.org/docs/GoldPlugin.html
I still do not know how to deal with this problem, Any one could give me some suggestion?