This is an archive of the discontinued LLVM Phabricator instance.

Fix wrong TLS symbol values.
ClosedPublic

Authored by ruiu on Feb 27 2017, 7:49 PM.

Details

Summary

I do not fully understand why we had these values in the tests, but
the new value matches what ld.bfd and ld.gold set, so I guess that
was just a mistake.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Feb 27 2017, 7:49 PM
grimar accepted this revision.Feb 28 2017, 2:35 AM

LGTM

lld/ELF/SyntheticSections.cpp
1399 ↗(On Diff #89964)

At least for non-mips part (gc-debuginfo-tls.s), this code does not look correct.

ELF spec says:
"In dynamic executables and shared objects, the st_value field of a STT_TLS symbol contains the assigned TLS offset for defined symbols. "
That is not what we see in gc-debuginfo-tls.s before this patch. Mips part seems have similar issue.

getSymVA, called inside Body->getVA() handled TLS specially:

if (D.isTls() && !Config->Relocatable) {
  if (!Out::TlsPhdr)
    fatal(toString(D.File) +
          " has a STT_TLS symbol but doesn't have a PT_TLS section");
  return VA - Out::TlsPhdr->p_vaddr;
}

The rest of logic looks almost similar to what happens for DefinedRegular inside getVA() called at line 1388. So I also feel that code doesn't make sense.

This revision is now accepted and ready to land.Feb 28 2017, 2:35 AM
This revision was automatically updated to reflect the committed changes.