[lld] r176970 - [ELF][X86_64][Hexagon] order plt/got entries properly and fix test
Shankar Easwaran
shankare at codeaurora.org
Wed Mar 13 13:30:11 PDT 2013
Author: shankare
Date: Wed Mar 13 15:30:11 2013
New Revision: 176970
URL: http://llvm.org/viewvc/llvm-project?rev=176970&view=rev
Log:
[ELF][X86_64][Hexagon] order plt/got entries properly and fix test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
lld/trunk/test/elf/x86-64-dynamic.test
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp?rev=176970&r1=176969&r2=176970&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp Wed Mar 13 15:30:11 2013
@@ -79,21 +79,21 @@ public:
_PLT0->setOrdinal(ordinal++);
mf.addAtom(*_PLT0);
}
- for (const auto &plt : _pltMap) {
- plt.second->setOrdinal(ordinal++);
- mf.addAtom(*plt.second);
+ for (auto &plt : _pltVector) {
+ plt->setOrdinal(ordinal++);
+ mf.addAtom(*plt);
}
if (_null) {
_null->setOrdinal(ordinal++);
mf.addAtom(*_null);
}
- if (_PLT0) {
+ if (_got0) {
_got0->setOrdinal(ordinal++);
mf.addAtom(*_got0);
}
- for (const auto &got : _gotMap) {
- got.second->setOrdinal(ordinal++);
- mf.addAtom(*got.second);
+ for (auto &got : _gotVector) {
+ got->setOrdinal(ordinal++);
+ mf.addAtom(*got);
}
}
@@ -107,6 +107,10 @@ protected:
/// \brief Map Atoms to their PLT entries.
llvm::DenseMap<const Atom *, PLTAtom *> _pltMap;
+ /// \brief the list of GOT/PLT atoms
+ std::vector<GOTAtom *> _gotVector;
+ std::vector<PLTAtom *> _pltVector;
+
/// \brief GOT entry that is always 0. Used for undefined weaks.
GOTAtom *_null;
@@ -134,6 +138,8 @@ public:
#ifndef NDEBUG
_got0->_name = "__got0";
#endif
+ DEBUG_WITH_TYPE("PLT", llvm::dbgs() << "[ PLT0/GOT0 ] "
+ << "Adding plt0/got0 \n");
return _PLT0;
}
@@ -154,9 +160,14 @@ public:
ga->_name += a->name();
pa->_name = "__plt_";
pa->_name += a->name();
+ DEBUG_WITH_TYPE("PLT", llvm::dbgs() << "[" << a->name() << "] "
+ << "Adding plt/got: " << pa->_name
+ << "/" << ga->_name << "\n");
#endif
_gotMap[a] = ga;
_pltMap[a] = pa;
+ _gotVector.push_back(ga);
+ _pltVector.push_back(pa);
return pa;
}
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp?rev=176970&r1=176969&r2=176970&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64TargetInfo.cpp Wed Mar 13 15:30:11 2013
@@ -128,6 +128,8 @@ protected:
#endif
_gotMap[da] = ga;
_pltMap[da] = pa;
+ _gotVector.push_back(ga);
+ _pltVector.push_back(pa);
return pa;
}
@@ -153,6 +155,7 @@ protected:
g->_name += atom->name();
#endif
_gotMap[atom] = g;
+ _gotVector.push_back(g);
return g;
}
return got->second;
@@ -187,6 +190,7 @@ protected:
g->_name += da->name();
#endif
_gotMap[da] = g;
+ _gotVector.push_back(g);
return g;
}
return got->second;
@@ -227,9 +231,9 @@ public:
_PLT0->setOrdinal(ordinal++);
mf.addAtom(*_PLT0);
}
- for (const auto &plt : _pltMap) {
- plt.second->setOrdinal(ordinal++);
- mf.addAtom(*plt.second);
+ for (auto &plt : _pltVector) {
+ plt->setOrdinal(ordinal++);
+ mf.addAtom(*plt);
}
if (_null) {
_null->setOrdinal(ordinal++);
@@ -241,9 +245,9 @@ public:
mf.addAtom(*_got0);
mf.addAtom(*_got1);
}
- for (const auto &got : _gotMap) {
- got.second->setOrdinal(ordinal++);
- mf.addAtom(*got.second);
+ for (auto &got : _gotVector) {
+ got->setOrdinal(ordinal++);
+ mf.addAtom(*got);
}
}
@@ -257,6 +261,10 @@ protected:
/// \brief Map Atoms to their PLT entries.
llvm::DenseMap<const Atom *, PLTAtom *> _pltMap;
+ /// \brief the list of GOT/PLT atoms
+ std::vector<GOTAtom *> _gotVector;
+ std::vector<PLTAtom *> _pltVector;
+
/// \brief GOT entry that is always 0. Used for undefined weaks.
GOTAtom *_null;
@@ -339,6 +347,8 @@ public:
#endif
_gotMap[a] = ga;
_pltMap[a] = pa;
+ _gotVector.push_back(ga);
+ _pltVector.push_back(pa);
return pa;
}
@@ -370,6 +380,7 @@ public:
g->_name += sla->name();
#endif
_gotMap[sla] = g;
+ _gotVector.push_back(g);
return g;
}
return got->second;
Modified: lld/trunk/test/elf/x86-64-dynamic.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/x86-64-dynamic.test?rev=176970&r1=176969&r2=176970&view=diff
==============================================================================
--- lld/trunk/test/elf/x86-64-dynamic.test (original)
+++ lld/trunk/test/elf/x86-64-dynamic.test Wed Mar 13 15:30:11 2013
@@ -26,16 +26,6 @@ CHECK: alignment: 2^3
CHECK: section-choice: custom-required
CHECK: section-name: .got.plt
CHECK: permissions: rw-
- - name: __got_i
-CHECK: type: got
-CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
-CHECK: section-choice: custom-required
-CHECK: section-name: .got.dyn
-CHECK: permissions: rw-
-CHECK: references:
-CHECK: - kind: R_X86_64_GLOB_DAT
-CHECK: offset: 0
-CHECK: target: i
- name: __got_foo
CHECK: type: got
CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
@@ -51,6 +41,16 @@ CHECK: - kind: R_X86_64_
CHECK: offset: 0
target: __plt_foo
CHECK: addend: 6
+ - name: __got_i
+CHECK: type: got
+CHECK: content: [ 00, 00, 00, 00, 00, 00, 00, 00 ]
+CHECK: section-choice: custom-required
+CHECK: section-name: .got.dyn
+CHECK: permissions: rw-
+CHECK: references:
+CHECK: - kind: R_X86_64_GLOB_DAT
+CHECK: offset: 0
+CHECK: target: i
CHECK: - name: main
CHECK: scope: global
More information about the llvm-commits
mailing list