Page MenuHomePhabricator

Do not emit a corrupt symbol table entry for .rela_iplt_{start,end}.
ClosedPublic

Authored by ruiu on Fri, Jan 11, 4:57 PM.

Details

Summary

If .rela.iplt does not exist, we used to emit a corrupt symbol table
that contains two symbols, .rela_iplt_{start,end}, pointing to a
nonexisting section.

This patch fixes the issue by setting section index 0 to the symbols
if .rel.iplt section does not exist.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

ruiu created this revision.Fri, Jan 11, 4:57 PM
grimar added inline comments.Sat, Jan 12, 3:17 AM
lld/ELF/Writer.cpp
961 ↗(On Diff #181398)

Will it be better to do in the same way we do for ElfSym::GlobalOffsetTable (lines 943-950 right above).
ElfSym::GlobalOffsetTable is created with Out::ElfHeader initially and then the appropriate section is set,
it seems to be a bit more convenient/simple way. So the code would be something like:

  ElfSym::RelaIpltStart =
      addOptionalRegular(S, **Out::ElfHeader**, 0, STV_HIDDEN, STB_WEAK);
...
  ElfSym::RelaIpltEnd =
      addOptionalRegular(S, **Out::ElfHeader**, 0, STV_HIDDEN, STB_WEAK);
if (ElfSym::RelaIpltStart && !In.RelaIplt->empty()) {
  ElfSym::RelaIpltStart->Section = In.RelaIplt;
  ElfSym::RelaIpltEnd->Section = In.RelaIplt;
  ElfSym::RelaIpltEnd->Value = In.RelaIplt->getSize();
}
ruiu updated this revision to Diff 181642.Mon, Jan 14, 1:38 PM
  • apply code review suggestion
ruiu marked an inline comment as done.Mon, Jan 14, 1:38 PM
ruiu added inline comments.
lld/ELF/Writer.cpp
961 ↗(On Diff #181398)

Thanks. I applied that suggested change.

grimar accepted this revision.Tue, Jan 15, 12:59 AM

LGTM.

This revision is now accepted and ready to land.Tue, Jan 15, 12:59 AM
This revision was automatically updated to reflect the committed changes.