[llvm] [llvm-profgen] Loading binary functions from .symtab when DWARF info is incomplete (PR #163654)

Haohai Wen via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 01:24:16 PDT 2025


================
@@ -482,6 +483,10 @@ inline uint64_t SymbolRef::getCommonSize() const {
   return getObject()->getCommonSymbolSize(getRawDataRefImpl());
 }
 
+inline uint64_t SymbolRef::getSize() const {
+  return getObject()->getCommonSymbolSizeImpl(getRawDataRefImpl());
----------------
HaohaiWen wrote:

getCommonSymbolSize is used for common symbol.
You can use -fcommon to explicitly generate them. e.g. for a simple global variable `int cval;`
```
ELF:
  Symbol {
    Name: cval (35)
    Value: 0x4
    Size: 4
    Binding: Global (0x1)
    Type: Object (0x1)
    Other: 0
    Section: Common (0xFFF2)
  }
COFF:
  Symbol {
    Name: cval
    Value: 4
    Section: IMAGE_SYM_UNDEFINED (0)
    BaseType: Null (0x0)
    ComplexType: Null (0x0)
    StorageClass: External (0x2)
    AuxSymbolCount: 0
  }
```
For ELF, there's `size` filed. `size` and `Value` of common symbol are all its size.
For COFF, there's no `size` field , the symbol's value is its size. I think COFF's implementation is correct.

Regarding function symbol's size.
For ELF, It is the function's size. I think you can use ELFSymbolRef::getSize() safely.
For COFF, it does not support it currently. I think we should use value 0.

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


More information about the llvm-commits mailing list