summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-02-26 15:39:26 +0000
committerRui Ueyama <ruiu@google.com>2016-02-26 15:39:26 +0000
commit72acaa1d177e7ffcd4f10773fb814da2e962ab67 (patch)
tree75a457c444c76f00a9ceea887f56adca7f715bda
parent9a31b3b07a95e000a7b6689223dce8322d563265 (diff)
downloadbcm5719-llvm-72acaa1d177e7ffcd4f10773fb814da2e962ab67.tar.gz
bcm5719-llvm-72acaa1d177e7ffcd4f10773fb814da2e962ab67.zip
Add comment on AMDGPU that the difference has no obvious reason.
llvm-svn: 262026
-rw-r--r--lld/ELF/OutputSections.cpp7
-rw-r--r--lld/ELF/Symbols.cpp6
2 files changed, 9 insertions, 4 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 472eda96d8a..f17d7051fe7 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -1456,8 +1456,11 @@ void SymbolTableSection<ELFT>::writeLocalSymbols(uint8_t *&Buf) {
const OutputSectionBase<ELFT> *OutSec = Section->OutSec;
ESym->st_shndx = OutSec->SectionIndex;
VA = Section->getOffset(*Sym);
- // Symbol offsets for AMDGPU need to be the offset in bytes of the
- // symbol from the beginning of the section.
+
+ // Symbol offsets for AMDGPU are the offsets in bytes of the
+ // symbols from the beginning of the section. There seems to be no
+ // reason for that deviation -- it's just that the definition of
+ // st_value field in AMDGPU's ELF is odd.
if (Config->EMachine != EM_AMDGPU)
VA += OutSec->getVA();
}
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index bd6f6b467d7..125e6c7a7b6 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -44,10 +44,12 @@ typename ELFFile<ELFT>::uintX_t SymbolBody::getVA() const {
return D->Sym.st_value;
assert(SC->Live);
- // Symbol offsets for AMDGPU need to be the offset in bytes of the symbol
- // from the beginning of the section.
+ // Symbol offsets for AMDGPU are the offsets in bytes of the symbols
+ // from the beginning of the section. Note that this part of AMDGPU's
+ // ELF spec is odd and not in line with the standard ELF.
if (Config->EMachine == EM_AMDGPU)
return SC->getOffset(D->Sym);
+
if (D->Sym.getType() == STT_TLS)
return SC->OutSec->getVA() + SC->getOffset(D->Sym) -
Out<ELFT>::TlsPhdr->p_vaddr;
OpenPOWER on IntegriCloud