[lld] r174065 - add support for assigning virtual addresses to TDATA/TBSS sections
Shankar Easwaran
shankare at codeaurora.org
Thu Jan 31 08:04:47 PST 2013
Author: shankare
Date: Thu Jan 31 10:04:47 2013
New Revision: 174065
URL: http://llvm.org/viewvc/llvm-project?rev=174065&view=rev
Log:
add support for assigning virtual addresses to TDATA/TBSS sections
Modified:
lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h
Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=174065&r1=174064&r2=174065&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Thu Jan 31 10:04:47 2013
@@ -63,6 +63,8 @@ public:
ORDER_RODATA = 100,
ORDER_EH_FRAME = 110,
ORDER_EH_FRAMEHDR = 120,
+ ORDER_TDATA = 124,
+ ORDER_TBSS = 128,
ORDER_CTORS = 130,
ORDER_DTORS = 140,
ORDER_INIT_ARRAY = 150,
@@ -353,6 +355,10 @@ Layout::SegmentType DefaultLayout<ELFT>:
case ORDER_FINI_ARRAY:
return llvm::ELF::PT_LOAD;
+ case ORDER_TDATA:
+ case ORDER_TBSS:
+ return llvm::ELF::PT_TLS;
+
default:
return llvm::ELF::PT_NULL;
}
@@ -376,6 +382,8 @@ bool DefaultLayout<ELFT>::hasOutputSegme
case ORDER_RODATA:
case ORDER_EH_FRAME:
case ORDER_EH_FRAMEHDR:
+ case ORDER_TDATA:
+ case ORDER_TBSS:
case ORDER_NOTE:
case ORDER_DYNAMIC:
case ORDER_CTORS:
Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=174065&r1=174064&r2=174065&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Thu Jan 31 10:04:47 2013
@@ -81,7 +81,6 @@ public:
for (auto &ai : _atoms) {
ai->_virtualAddr = addr + ai->_fileOffset;
}
- addr += this->memSize();
}
/// \brief Set the file offset of each Atom in the section. This routine
Modified: lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h?rev=174065&r1=174064&r2=174065&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h Thu Jan 31 10:04:47 2013
@@ -318,9 +318,13 @@ Segment<ELFT>::assignOffsets(uint64_t st
}
/// \brief Assign virtual addresses to the slices
-template<class ELFT>
-void
-Segment<ELFT>::assignVirtualAddress(uint64_t &addr) {
+template <class ELFT> void Segment<ELFT>::assignVirtualAddress(uint64_t &addr) {
+ // Check if the segment is of type TLS
+ // The sections that belong to the TLS segment have their
+ // virtual addresses that are relative To TP
+ bool isTLSSegment = (segmentType() == llvm::ELF::PT_TLS);
+ uint64_t tlsStartAddr = 0;
+
for (auto slice : slices()) {
// Align to a page
addr = llvm::RoundUpToAlignment(addr, this->_targetInfo.getPageSize());
@@ -331,15 +335,20 @@ Segment<ELFT>::assignVirtualAddress(uint
for (auto section : slice->sections()) {
// Align the section address
addr = llvm::RoundUpToAlignment(addr, section->align2());
+ tlsStartAddr = (isTLSSegment) ?
+ llvm::RoundUpToAlignment(tlsStartAddr, section->align2()):0;
if (!virtualAddressSet) {
slice->setVAddr(addr);
virtualAddressSet = true;
}
section->setVAddr(addr);
- if (auto s = dyn_cast<Section<ELFT>>(section))
- s->assignVirtualAddress(addr);
- else
- addr += section->memSize();
+ if (auto s = dyn_cast<Section<ELFT> >(section)) {
+ if (isTLSSegment)
+ s->assignVirtualAddress(tlsStartAddr);
+ else
+ s->assignVirtualAddress(addr);
+ }
+ addr += section->memSize();
section->setMemSize(addr - section->virtualAddr());
}
slice->setMemSize(addr - slice->virtualAddr());
More information about the llvm-commits
mailing list