diff options
author | Shankar Easwaran <shankare@codeaurora.org> | 2014-11-30 22:36:29 +0000 |
---|---|---|
committer | Shankar Easwaran <shankare@codeaurora.org> | 2014-11-30 22:36:29 +0000 |
commit | a0184368d63d04000ae7e19f5640f442c31423e4 (patch) | |
tree | aa785db605b5053d1326612ae3fabcf813fe0b15 | |
parent | ad5074df0c1b9dfce7ff7094ca2b7ec7d4b2167f (diff) | |
download | bcm5719-llvm-a0184368d63d04000ae7e19f5640f442c31423e4.tar.gz bcm5719-llvm-a0184368d63d04000ae7e19f5640f442c31423e4.zip |
[ELF] Fix layout of output sections.
The AtomSections were improperly merging sections from various input files. This
patch fixes the problem, with an updated test that was provided by Simon.
Thanks to Simon Atanasyan for catching this issue.
llvm-svn: 222982
-rw-r--r-- | lld/lib/ReaderWriter/ELF/DefaultLayout.h | 8 | ||||
-rw-r--r-- | lld/test/elf/Mips/ctors-order.test | 5 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/ELF/DefaultLayout.h b/lld/lib/ReaderWriter/ELF/DefaultLayout.h index 9a30f41629b..b89e7e444dd 100644 --- a/lld/lib/ReaderWriter/ELF/DefaultLayout.h +++ b/lld/lib/ReaderWriter/ELF/DefaultLayout.h @@ -547,7 +547,11 @@ template <class ELFT> AtomSection<ELFT> *DefaultLayout<ELFT>::getSection( StringRef sectionName, int32_t contentType, DefinedAtom::ContentPermissions permissions) { - const SectionKey sectionKey(sectionName, permissions); + // FIXME: We really need the file path here in the SectionKey, when that + // is available, replace the sectionKey that has outputSectionName to the + // inputSectionName. + StringRef outputSectionName = getOutputSectionName(sectionName); + const SectionKey sectionKey(outputSectionName, permissions); auto sec = _sectionMap.find(sectionKey); if (sec != _sectionMap.end()) return sec->second; @@ -555,7 +559,7 @@ AtomSection<ELFT> *DefaultLayout<ELFT>::getSection( getSectionOrder(sectionName, contentType, permissions); AtomSection<ELFT> *newSec = createSection(sectionName, contentType, permissions, sectionOrder); - newSec->setOutputSectionName(getOutputSectionName(sectionName)); + newSec->setOutputSectionName(outputSectionName); newSec->setOrder(sectionOrder); _sections.push_back(newSec); _sectionMap.insert(std::make_pair(sectionKey, newSec)); diff --git a/lld/test/elf/Mips/ctors-order.test b/lld/test/elf/Mips/ctors-order.test index bded11a0a2b..b8bf0126f69 100644 --- a/lld/test/elf/Mips/ctors-order.test +++ b/lld/test/elf/Mips/ctors-order.test @@ -5,6 +5,9 @@ # RUN: yaml2obj -format=elf -docnum 3 %s > %t-obj.o # RUN: lld -flavor gnu -target mipsel -shared --output-filetype=yaml \ # RUN: %t-crtbeginS.o %t-obj.o %t-crtendS.o | FileCheck %s +# RUN: lld -flavor gnu -target mipsel -shared -o %t.so \ +# RUN: %t-crtbeginS.o %t-obj.o %t-crtendS.o +# RUN: llvm-objdump -s %t.so | FileCheck -check-prefix=RAW %s # CHECK: defined-atoms: # CHECK-NEXT: - ref-name: L000 @@ -52,6 +55,8 @@ # CHECK-NEXT: section-choice: custom-required # CHECK-NEXT: section-name: .ctors +# RAW: Contents of section .ctors: +# RAW-NEXT: 2000 ffffffff 11111111 22222222 00000000 # crtbeginS.o --- FileHeader: |