[lld] r192409 - [ELF] Fix Atoms in the same file had overlapping ordinals.
Shankar Easwaran
shankare at codeaurora.org
Thu Oct 10 18:50:05 PDT 2013
Author: shankare
Date: Thu Oct 10 20:50:04 2013
New Revision: 192409
URL: http://llvm.org/viewvc/llvm-project?rev=192409&view=rev
Log:
[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.
Modified:
lld/trunk/lib/Passes/LayoutPass.cpp
lld/trunk/lib/ReaderWriter/ELF/File.h
lld/trunk/test/elf/ifunc.test
Modified: lld/trunk/lib/Passes/LayoutPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Passes/LayoutPass.cpp?rev=192409&r1=192408&r2=192409&view=diff
==============================================================================
--- lld/trunk/lib/Passes/LayoutPass.cpp (original)
+++ lld/trunk/lib/Passes/LayoutPass.cpp Thu Oct 10 20:50:04 2013
@@ -111,6 +111,8 @@ bool LayoutPass::CompareAtoms::operator(
DEBUG(llvm::dbgs() << "Unordered\n");
+ llvm_unreachable("Atoms with Same Ordinal!");
+
return false;
}
@@ -527,7 +529,7 @@ void LayoutPass::perform(MutableFile &me
});
// sort the atoms
- std::stable_sort(atomRange.begin(), atomRange.end(), _compareAtoms);
+ std::sort(atomRange.begin(), atomRange.end(), _compareAtoms);
DEBUG({
llvm::dbgs() << "sorted atoms:\n";
Modified: lld/trunk/lib/ReaderWriter/ELF/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=192409&r1=192408&r2=192409&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Thu Oct 10 20:50:04 2013
@@ -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 {
Modified: lld/trunk/test/elf/ifunc.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/ifunc.test?rev=192409&r1=192408&r2=192409&view=diff
==============================================================================
--- lld/trunk/test/elf/ifunc.test (original)
+++ lld/trunk/test/elf/ifunc.test Thu Oct 10 20:50:04 2013
@@ -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 0000000
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
More information about the llvm-commits
mailing list