summaryrefslogtreecommitdiffstats
path: root/lld/ELF/InputSection.cpp
diff options
context:
space:
mode:
authorEugene Leviant <eleviant@accesssoftek.com>2016-11-16 10:02:27 +0000
committerEugene Leviant <eleviant@accesssoftek.com>2016-11-16 10:02:27 +0000
commita96d9027a3cb8b65aa062e9cab74f00dba1c013a (patch)
treeccb7710e976e0b54f0b365cc97b46e3cf3afd043 /lld/ELF/InputSection.cpp
parent31055c6aceeaf0f2641ce44ca8b4ca3aa1cc7153 (diff)
downloadbcm5719-llvm-a96d9027a3cb8b65aa062e9cab74f00dba1c013a.tar.gz
bcm5719-llvm-a96d9027a3cb8b65aa062e9cab74f00dba1c013a.zip
[ELF] Convert RelocationSection to input section
Differential revision: https://reviews.llvm.org/D26669 llvm-svn: 287092
Diffstat (limited to 'lld/ELF/InputSection.cpp')
-rw-r--r--lld/ELF/InputSection.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 1cfb1f93629..28e1d71402d 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -104,8 +104,12 @@ template <class ELFT>
typename ELFT::uint InputSectionBase<ELFT>::getOffset(uintX_t Offset) const {
switch (kind()) {
case Regular:
- case Synthetic:
return cast<InputSection<ELFT>>(this)->OutSecOff + Offset;
+ case Synthetic:
+ // For synthetic sections we treat offset -1 as the end of the section.
+ // The same approach is used for synthetic symbols (DefinedSynthetic).
+ return cast<InputSection<ELFT>>(this)->OutSecOff +
+ (Offset == uintX_t(-1) ? getSize() : Offset);
case EHFrame:
// The file crtbeginT.o has relocations pointing to the start of an empty
// .eh_frame that is known to be the first in the link. It does that to
@@ -525,6 +529,11 @@ template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
if (this->Type == SHT_NOBITS)
return;
+ if (auto *S = dyn_cast<SyntheticSection<ELFT>>(this)) {
+ S->writeTo(Buf);
+ return;
+ }
+
// If -r is given, then an InputSection may be a relocation section.
if (this->Type == SHT_RELA) {
copyRelocations(Buf + OutSecOff, this->template getDataAs<Elf_Rela>());
@@ -535,11 +544,6 @@ template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
return;
}
- if (auto *S = dyn_cast<SyntheticSection<ELFT>>(this)) {
- S->writeTo(Buf);
- return;
- }
-
// Copy section contents from source object file to output file.
ArrayRef<uint8_t> Data = this->Data;
memcpy(Buf + OutSecOff, Data.data(), Data.size());
OpenPOWER on IntegriCloud