[llvm] [BOLT] Account for stubs with symbols in plt (PR #192716)

Hemant Kulkarni via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 11:58:26 PDT 2026


================
@@ -1041,8 +1041,11 @@ void RewriteInstance::discoverFileObjects() {
 
     FileSymRefs.emplace(SymbolAddress, Symbol);
 
-    // Skip section symbols that will be registered by disassemblePLT().
-    if (SymbolType == SymbolRef::ST_Debug) {
+    // Skip symbols in PLT sections that will be registered by disassemblePLT().
+    // ST_Debug covers section markers (lld/GNU ld), ST_Function covers
+    // explicit stub symbols emitted by mold (e.g., malloc$plt).
+    if (SymbolType == SymbolRef::ST_Debug ||
----------------
awshkulkar wrote:

Not every ST_Debug (STT_SECTION in ELFObjectFile)  is plt symbol, the loop is basically narrowing the number of symbols for linear comparisons to all known names of plt sections "iplt", "plt" etc in getPLTSectionInfo() and deciding if the section that belongs should be later handled by disassemblePLT() to prevent duplicate BF.

We still want to create binary functions for other kind of sections that have no function symbols in them like .init/.fini or stubs in Linux kernel. 

However all of this was with assumption that we will not have symbols in .plt, now symbols inside the .plt created by mold also face same issue -  disassemblePLT will again explicitly make PBF for these (correct place) but duplicate the incorrectly created BF during normal function creation phase.

https://github.com/llvm/llvm-project/pull/192716


More information about the llvm-commits mailing list