[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
Thu Jan 16 05:53:58 PST 2025


mstorsjo wrote:

> Should we add a `DefinedRegular` subclass which ignores the offset? That's maybe the most efficient way around it, without needing to litter `DefinedRegular` with a condition in e.g. the `getRVA()` method. (Alternatively, `DefinedRegular` would need a flag about whether to ignore the `Value` offset or not.)

I made an attempt at this now, but adding a `DefinedRegular` subclass also is a bit messy; `DefinedRegular::getValue()` is not virtual (the whole class hierarchy in `Symbols.h` is quite tweaked not to use regular C++ inheritance facilities), so e.g. the offset does appear e.g. in the map file (see the updated test). Alternatively `DefinedSection` could inherit directly from `DefinedCOFF`, but then these symbols are omitted from the map file entirely (as they don't hit `dyn_cast<DefinedRegular>()`) - we have lots of code all over the place that operate on/around `DefinedRegular`, so making it not hit that may be problematic; we also have switches that operate directly on `s->kind()`.

Or should we create a synthetic `coff_symbol_generic` with a zero `Value`?

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


More information about the llvm-commits mailing list