[lld] [llvm] RFC: [LLD] [COFF] Fix linking MSVC generated implib header objects (PR #122811)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 04:19:21 PST 2025


================
@@ -219,7 +219,9 @@ class DefinedRegular : public DefinedCOFF {
     return s->kind() == DefinedRegularKind;
   }
 
-  uint64_t getRVA() const { return (*data)->getRVA() + sym->Value; }
+  uint64_t getRVA() const {
+    return (*data)->getRVA() + (sym->Value != 0xC0000040 ? sym->Value : 0);
----------------
mstorsjo wrote:

Yes, we most probably should avoid hardcoding it, especially like this; this was my mildly provocative PoC to show where/how we may need to work around it :-)

Indeed, ignoring the offset when handling `isEmptySectionDeclaration` probably is good, but that's apparently not entirely enough either. Note this section symbol:
```
  - Name:            '.idata$2'
    Value:           3221225536
    SectionNumber:   1
    SimpleType:      IMAGE_SYM_TYPE_NULL
    ComplexType:     IMAGE_SYM_DTYPE_NULL
    StorageClass:    IMAGE_SYM_CLASS_SECTION
```

So apparently we should ignore the `Value` entirely, for any section type symbol it seems? I haven't quite yet had time to work out the logic around this, how binutils and link.exe operate around this.

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


More information about the llvm-commits mailing list