[llvm] [COFF] Do not expose WinCOFFWriter to llvm namespace (PR #100505)
Haohai Wen via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 25 03:55:45 PDT 2024
HaohaiWen wrote:
Requirements:
1. Can make_unique<WinCOFFObjectWriter>(...) in any place.
2. Don't expose WinCOFFWriter to llvm namespace.
I checked code of `recordRelocations` and `executePostLayoutBinding ` and tried to defer the action of defining COFFSymbol and COFFSection to writeObject. It's too complicated since compute fixup value in recordRelocations requires known of defined COFFSymbol. I don't have much time to refactor whole code and since that is not NFC and may cause bug. Therefor we'd better to keep the original logic:
1. Collect/Define COFFSymbol/COFFSection in `executePostLayoutBinding`.
2. Check and compute MCFixup in `recordRelocations`.
3. writeObject.
Therefore, to keep `WinCOFFWritter` to be same life range as `WinCOFFObjectWritter` is necessary so we need to keep the unique_ptr of ObjWriter and DwoWriter. The question is what type they should be.
>From header view, compiler don't need to know much about WinCOFFWritter, but it should be a complete type.
Using void * and reinterpret_cast is workable but this is too ugly.
If not use reinterpret_cast, type of ObjWriter should have the ability to execute `executePostLayoutBinding`, `recordRelocations`, `reset` and they should be virtual. That's why I prefer to split MCObjectWriterBase from MCObjectWriter.
Those works for this issue, but introduced new vtab and is bad for performance....
https://github.com/llvm/llvm-project/pull/100505
More information about the llvm-commits
mailing list