<div dir="ltr">Hi all,<div>  The documentation of `@llvm.used` says:</div><div><br></div><div>"<span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px">If a symbol appears in the </span><code class="gmail-docutils gmail-literal gmail-notranslate" style="font-family:Consolas,"Deja Vu Sans Mono","Bitstream Vera Sans Mono",monospace;font-size:0.95em;color:rgb(0,0,0)"><span class="gmail-pre" style="hyphens: none;">@llvm.used</span></code><span style="color:rgb(0,0,0);font-family:"Lucida Grande","Lucida Sans Unicode",Geneva,Verdana,sans-serif;font-size:14px"> list, then the compiler, assembler, and linker are required to treat the symbol as if there is a reference to the symbol that it cannot see (which is why they have to be named)."</span></div><div><br></div><div>We've always understood this as: the symbol will survive into the final executable, also when it is in its own section and with `--gc-sections`. But I think that's not true.</div><div>My understanding now is that `@llvm.used` is completely ignored by the linker when creating a final whole-program binary. That is, the symbol is emitted by the compiler into the object file, so not stripped e.g. by DCE. But when the linker combines multiple object files into the final executable, the symbol will be removed by `--gc-sections` when the linker sees no reference to it.</div><div>It appears that the only way to keep an unreferenced symbol while linking with `--gc-sections` (compiling with `-f{function,data}-sections`) is to put it in a segment that is kept as specified by the linkerscript (`KEEP`).</div><div><br></div><div>I hope someone can tell me that my current understanding is correct, and that we have to use another way to keep a symbol until the very end (tips welcome, without modifying the system default linker script...).</div><div><br></div><div>Thanks!</div><div>  Johan</div><div><br></div></div>