linker_private* linkage


I'm trying to understand better how linker_private (and friends) work.
From what I can understand from the manual (LLVM Language Reference Manual — LLVM 16.0.0git documentation), it seems that a linker_private function cannot be removed by the optimizers. Only the linker can discard the symbol. However, I tested with 'opt -O1' and a function with *no users* is removed. Same thing happens with the other linker_private_* linkage types.

Is my reading of the documentation correct (i.e., is this a bug in LLVM)?


The point behind private symbols for a linker is usually so that people cannot disassemble or in some other way misuse the final image that you create.

I don't think this has anything to do with the optimizer.

So after the shared object or executable is created, you can't find anymore, by name, where the code or data for that symbol resides.

In the case of shared objects, it means that you cannot write code that does a dllopen and tries to find the entrypoint by name.