Locally imported symbols are a very surprising linker feature. link.exe
warns for them, and we should warn too.
Details
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
COFF/SymbolTable.cpp | ||
---|---|---|
102 | I definitely want to report the object file which is importing the symbol (link.exe does even better and reports the function that's doing the import, but I believe reporting the object file is the best we can do). As far as I can tell, the only way to figure out the object file(s) that are doing the import is to loop through the symbols in Config->GCRoot and every object file, as is done below (in the loops I've modified). I could duplicate those loops here to inline the warning, but it seemed better to avoid the duplication and reuse the existing loops. | |
test/COFF/locally-imported.test | ||
6 | The file in which the symbol is defined and the file in which it's imported would normally be different. If you want, I can change the test so that the symbol is defined and imported in different object files (or perhaps add a different test case which does that), to demonstrate the different filenames. |
COFF/SymbolTable.cpp | ||
---|---|---|
102 | I thought Sym would be the original (undefined) symbol, and D would be the corresponding defined local symbol. The pointer values are definitely different in my testing, and e.g. Sym->getFile() is NULL even after the replaceSymbol call. |
COFF/SymbolTable.cpp | ||
---|---|---|
102 | Why don't you do LocalImports[Sym] = D? |
COFF/SymbolTable.cpp | ||
---|---|---|
102 | I forgot about that form. Updated. |
I'd name this LocalImports.