return _relocationTable;
}
+ uint64_t getTLSSize() const {
+ for (const auto &phdr : *_programHeader)
+ if (phdr->p_type == llvm::ELF::PT_TLS)
+ return phdr->p_memsz;
+ return 0;
+ }
+
private:
SectionMapT _sectionMap;
MergedSectionMapT _mergedSectionMap;
return ".text";
if (name.startswith(".rodata"))
return ".rodata";
+ if (name.startswith(".tdata"))
+ return ".tdata";
+ if (name.startswith(".tbss"))
+ return ".tbss";
return name;
}
case R_X86_64_TPOFF64:
case R_X86_64_DTPOFF32:
case R_X86_64_TPOFF32: {
- // Get the start and end of the TLS segment.
- if (_tlsSize == 0) {
- auto tdata = _targetInfo.getTargetHandler<X86_64ELFType>().targetLayout()
- .findOutputSection(".tdata");
- auto tbss = _targetInfo.getTargetHandler<X86_64ELFType>().targetLayout()
- .findOutputSection(".tbss");
- // HACK: The tdata and tbss sections end up together to from the TLS
- // segment. This should actually use the TLS program header entry.
- if (tdata)
- _tlsSize = tdata->memSize();
- if (tbss)
- _tlsSize += tbss->memSize();
- }
+ _tlsSize = _targetInfo.getTargetHandler<X86_64ELFType>().targetLayout()
+ .getTLSSize();
if (ref.kind() == R_X86_64_TPOFF32 || ref.kind() == R_X86_64_DTPOFF32) {
int32_t result = (int32_t)(targetVAddress - _tlsSize);
*reinterpret_cast<llvm::support::little32_t *>(location) = result;