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

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 21 18:58:03 PDT 2019


MaskRay added a comment.

In D59649#1438837 <https://reviews.llvm.org/D59649#1438837>, @smeenai wrote:

> In D59649#1438809 <https://reviews.llvm.org/D59649#1438809>, @MaskRay wrote:
>
> > In D59649#1438330 <https://reviews.llvm.org/D59649#1438330>, @smeenai wrote:
> >
> > > Thank you!
> > >
> > > If I'm understanding correctly, for the case where the relocation is not in the same object file as the discarded section, we'll still get the "undefined symbol" error message. I don't know if it would be possible to enhance that case to print the "relocation against discarded section" message as well. (gold does print that message in this case; it just doesn't print the additional information about the section group signature and prevailing definition.)
> >
> >
> > `Symbol` has the `File` field but not the section index (`st_shndx`). If the relocation is not in the same object as the discarded section, we can't get the defined section easily.
>
>
> Could we do so via symbol table lookup? Rui said in https://bugs.llvm.org/show_bug.cgi?id=41133 that "We already insert all symbols (including ones for discarded sections) to the symbol table".


We do insert all symbols into the symbol table (`InputFiles.cpp:ObjFile<ELFT>::initializeSymbols()`), however, `Symbol` does not encode all fields of `Elf_Sym`. `Symbol` has several derived classes, among them, only `Defined` keeps `st_shndx`, `Undefined` doesn't. Symbols defined in discarded COMDAT sections are represented by `Undefined` so the section index is lost. I think I can probably add `SectionBase *Sec` to `Undefined` so that we do not have the limitation.


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