diff options
| author | Shankar Easwaran <shankare@codeaurora.org> | 2013-10-11 01:50:04 +0000 |
|---|---|---|
| committer | Shankar Easwaran <shankare@codeaurora.org> | 2013-10-11 01:50:04 +0000 |
| commit | bcf36560fdfb491afa91e555b1fc4957b73c3a93 (patch) | |
| tree | ee171d16a1a6d2635008bbe25ab21d869411593e | |
| parent | 04a8bab0477b9b916a6d6d04df6b8ebd55b4f721 (diff) | |
| download | bcm5719-llvm-bcf36560fdfb491afa91e555b1fc4957b73c3a93.tar.gz bcm5719-llvm-bcf36560fdfb491afa91e555b1fc4957b73c3a93.zip | |
[ELF] Fix Atoms in the same file had overlapping ordinals.
This also reverts the LayoutPass to use std::sort as all files
have an ordinal now.
llvm-svn: 192409
| -rw-r--r-- | lld/lib/Passes/LayoutPass.cpp | 4 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/File.h | 3 | ||||
| -rw-r--r-- | lld/test/elf/ifunc.test | 16 |
3 files changed, 11 insertions, 12 deletions
diff --git a/lld/lib/Passes/LayoutPass.cpp b/lld/lib/Passes/LayoutPass.cpp index 983667c63f0..dd8056cd765 100644 --- a/lld/lib/Passes/LayoutPass.cpp +++ b/lld/lib/Passes/LayoutPass.cpp @@ -111,6 +111,8 @@ bool LayoutPass::CompareAtoms::operator()(const DefinedAtom *left, DEBUG(llvm::dbgs() << "Unordered\n"); + llvm_unreachable("Atoms with Same Ordinal!"); + return false; } @@ -527,7 +529,7 @@ void LayoutPass::perform(MutableFile &mergedFile) { }); // sort the atoms - std::stable_sort(atomRange.begin(), atomRange.end(), _compareAtoms); + std::sort(atomRange.begin(), atomRange.end(), _compareAtoms); DEBUG({ llvm::dbgs() << "sorted atoms:\n"; diff --git a/lld/lib/ReaderWriter/ELF/File.h b/lld/lib/ReaderWriter/ELF/File.h index 51f1b3bffa8..9811f80267e 100644 --- a/lld/lib/ReaderWriter/ELF/File.h +++ b/lld/lib/ReaderWriter/ELF/File.h @@ -278,7 +278,6 @@ public: if (SymI != SymE) ++SymI; - int commonOrd = 0; for (; SymI != SymE; ++SymI) { const Elf_Shdr *section = _objFile->getSection(&*SymI); @@ -303,7 +302,7 @@ public: } else if (isCommonSymbol(&*SymI)) { auto *newAtom = new (_readerStorage) ELFCommonAtom<ELFT>(*this, *symbolName, &*SymI); - newAtom->setOrdinal(commonOrd++); + newAtom->setOrdinal(_ordinal++); _definedAtoms._atoms.push_back(newAtom); _symbolToAtomMapping.insert(std::make_pair(&*SymI, newAtom)); } else { diff --git a/lld/test/elf/ifunc.test b/lld/test/elf/ifunc.test index 5521ae3b1c8..d91876e723c 100644 --- a/lld/test/elf/ifunc.test +++ b/lld/test/elf/ifunc.test @@ -25,19 +25,19 @@ PLT: references: PLT: kind: R_X86_64_IRELATIVE PLT: target: hey -PLT: name: main +PLT: name: plt PLT: scope: global PLT: references: -PLT: kind: R_X86_64_PC32 +PLT: kind: R_X86_64_PC32 PLT: target: [[PLTNAME:[-a-zA-Z0-9_]+]] +PLT: kind: layout-before +PLT: target: __hey_1 -PLT: name: plt +PLT: name: main PLT: scope: global PLT: references: -PLT: kind: R_X86_64_PC32 +PLT: kind: R_X86_64_PC32 PLT: target: [[PLTNAME]] -PLT: kind: layout-before -PLT: target: __hey_1 // Make sure the target of main's relocation is a stub with a PC32 relocation. // This relocation is to the got atom, but you can't really write that check in @@ -60,12 +60,10 @@ BIN-NEXT: {{[0-9a-f]+}} 00000000 00000000 RELATIVEADDEND: Relocations [ RELATIVEADDEND-NEXT: Section (1) .rela.plt { -RELATIVEADDEND-NEXT: 0x401000 R_X86_64_IRELATIVE - 0x4000FC +RELATIVEADDEND-NEXT: 0x401000 R_X86_64_IRELATIVE - 0x4000E0 RELATIVEADDEND-NEXT: } RELATIVEADDEND-NEXT: ] SHARED: shared-library-atoms SHARED: name: hey SHARED-NOT: data - -XFAIL: darwin |

