When compiling with GCC (-flto) it does introduce new symbols to binary to prevent collusion . I was looking at the LLVM source code to find out whether there are a similar mechanism in LLVM too or not? I noticed there are duplicate symbols like this:
# compiled with llvm-12 and (-flto) $ readelf --wide --symbols executable | grep "FUNC" | grep -i "close_file" 75: 000000000048a800 37 FUNC LOCAL DEFAULT 13 close_file 76: 000000000048ad10 34 FUNC LOCAL DEFAULT 13 close_file.614 77: 000000000048b320 34 FUNC LOCAL DEFAULT 13 close_file.622 78: 000000000048b420 22 FUNC LOCAL DEFAULT 13 close_file.634 79: 000000000048e120 713 FUNC LOCAL DEFAULT 13 close_file.641 80: 0000000000490690 485 FUNC LOCAL DEFAULT 13 close_file.663
But I am not sure is this same thing or different. 1) Why does LLVM needs to duplicate/rename symbols? 2) Where can I read more about this in the documentation or source code?