llvm CFI seems not work well when compiling for a shared object and errors were reported during link time

When I try to protect both main binary and shared objects using llvm cfi, I firstly build a CFI protected shared object as blow:

clang++ -fsanitize=cfi -fvisibility=hidden -flto -fPIC -shared ./sharedobjsrc.cpp -o libsharedobj.so

Then I can assume

“Calls inside any instrumented DSO are fully protected.”

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:

clang++ -fsanitize=cfi -fvisibility=hidden -flto -fsanitize-cfi-cross-dso ./main.cpp ./libsharedobj.so -o target -Wl,-rpath,./

report like: ld-temp.o:function main.cfi: error: undefined reference to 'functionname()’ returns to screen

Even if I trace the instructions line by line according to https://github.com/llvm-mirror/compiler-rt/tree/master/test/cfi/cross-dso, I failed to manage it.

You can reproduce my operations with my attachment.

attachment.zip (2.15 KB)