<div dir="ltr"><div><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">When I try to protect both main binary and shared objects using llvm cfi, I firstly build a CFI protected shared object as blow:</div><div style="margin:8px 0px;font-size:0.8125rem"><br></div><p class="gmail-p1" style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">clang++ -fsanitize=cfi -fvisibility=hidden -flto -fPIC -shared<span class="gmail-Apple-converted-space"><span style="font-family:"PingFang SC";background-color:rgb(255,255,0)"><font color="#ff0000"> ./sharedobjsrc.cpp</font></span> -o <span style="font-family:"PingFang SC";background-color:rgb(255,255,0)"><font color="#ff0000">libsharedobj.so</font></span></span></p><p class="gmail-p1" style="margin:8px 0px;font-size:16px;font-family:"PingFang SC""><br></p><p class="gmail-p1" style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">Then I can assume </p><p class="gmail-p1" style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">    "Calls inside any instrumented DSO are fully protected."</p><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px"><br></div><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">In the next step, I try to compile the main.cpp, and dynamically link main.o with libsharedobj.so. By no means can I succeed with command like that:</div><p class="gmail-p1" style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">clang++ -fsanitize=cfi -fvisibility=hidden -flto -fsanitize-cfi-cross-dso<font color="#ff0000" style="background-color:rgb(255,255,0)"> ./main.cpp ./libsharedobj.so </font>-o target -Wl,-rpath,./</p><div style="margin:8px 0px;font-size:0.8125rem"><br></div><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">report like: ld-temp.o:function main.cfi: error: undefined reference to 'functionname()’ returns to screen</div><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px"><br></div><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">Even if I trace the instructions line by line according to <a href="https://github.com/llvm-mirror/compiler-rt/tree/master/test/cfi/cross-dso" style="cursor: pointer; overflow-wrap: break-word; text-decoration-skip-ink: none;">https://github.com/llvm-mirror/compiler-rt/tree/master/test/cfi/cross-dso</a>, I failed to manage it.</div><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px"><br></div><div style="margin:8px 0px;color:rgb(0,0,0);font-family:Arial;font-size:16px">You can reproduce my operations with my attachment.</div></div></div>