[PATCH] D59649: [ELF] Improve error message for relocations to symbols defined in discarded sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 01:42:33 PDT 2019


MaskRay added a comment.

> I wonder if we can do this without that variable. ... you can scan through object file's symbol table to find an undefined symbol, for example. What do you think?

I have thought about this option. I believe that will make code slower and more complex.

We use `Undefined` for two purposes: 1) undefined symbol 2) symbol in a discarded section (has only one occurrence: `InputFiles.cpp: ObjFile<ELFT>::createSymbol`). (I added some comments in this patch).

If we don't store `Undefined::DiscardedSecIdx`, we can iterate the symbol table of `Symbol::File` to figure out the section index and then check if the section is discarded. That would repeat some work done by `ObjFile<ELFT>::createSymbol`. Because we may emit many `maybeReportUndefined` errors, we don't want symbol table iterating to be too slow. We may end up with some cache. I think that is more complex than an extra `DiscardedSecIdx`.

If `/*DiscardedSecIdx=0*/` looks too messy, it can be made a default argument.
That is simpler than having two member functions `SymbolTable::addSymbolInDiscarded` and `SymbolTable::addUndefined`.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59649/new/

https://reviews.llvm.org/D59649





More information about the llvm-commits mailing list