diff options
| author | Shankar Easwaran <shankare@codeaurora.org> | 2013-01-31 16:04:47 +0000 |
|---|---|---|
| committer | Shankar Easwaran <shankare@codeaurora.org> | 2013-01-31 16:04:47 +0000 |
| commit | fb8565a9c6f43b57ab1c646986c52ddbacfad7b4 (patch) | |
| tree | 03704b3abed1da84124e1e06b11bdd762bf08e70 | |
| parent | ad1e5ce8eaad119e112d10bcf4c4267657770a4e (diff) | |
| download | bcm5719-llvm-fb8565a9c6f43b57ab1c646986c52ddbacfad7b4.tar.gz bcm5719-llvm-fb8565a9c6f43b57ab1c646986c52ddbacfad7b4.zip | |
add support for assigning virtual addresses to TDATA/TBSS sections
llvm-svn: 174065
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/DefaultLayout.h | 8 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/SectionChunks.h | 1 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/SegmentChunks.h | 23 |
3 files changed, 24 insertions, 8 deletions
diff --git a/lld/lib/ReaderWriter/ELF/DefaultLayout.h b/lld/lib/ReaderWriter/ELF/DefaultLayout.h index 8b87a66fbe2..326019f9a31 100644 --- a/lld/lib/ReaderWriter/ELF/DefaultLayout.h +++ b/lld/lib/ReaderWriter/ELF/DefaultLayout.h @@ -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>::getSegmentType( 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>::hasOutputSegment(Section<ELFT> *section) { 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: diff --git a/lld/lib/ReaderWriter/ELF/SectionChunks.h b/lld/lib/ReaderWriter/ELF/SectionChunks.h index bb53ad7c524..101089dec22 100644 --- a/lld/lib/ReaderWriter/ELF/SectionChunks.h +++ b/lld/lib/ReaderWriter/ELF/SectionChunks.h @@ -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 diff --git a/lld/lib/ReaderWriter/ELF/SegmentChunks.h b/lld/lib/ReaderWriter/ELF/SegmentChunks.h index 12ced7036ac..efdfc655fd9 100644 --- a/lld/lib/ReaderWriter/ELF/SegmentChunks.h +++ b/lld/lib/ReaderWriter/ELF/SegmentChunks.h @@ -318,9 +318,13 @@ Segment<ELFT>::assignOffsets(uint64_t startOffset) { } /// \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(uint64_t &addr) { 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()); |

