[lld] r181622 - [lld][ELF] set ordinals for mergeAtoms and fix testcase
Shankar Easwaran
shankare at codeaurora.org
Fri May 10 11:52:29 PDT 2013
Author: shankare
Date: Fri May 10 13:52:29 2013
New Revision: 181622
URL: http://llvm.org/viewvc/llvm-project?rev=181622&view=rev
Log:
[lld][ELF] set ordinals for mergeAtoms and fix testcase
Modified:
lld/trunk/lib/ReaderWriter/ELF/Atoms.h
lld/trunk/lib/ReaderWriter/ELF/File.h
lld/trunk/test/elf/mergeatoms.objtxt
Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=181622&r1=181621&r2=181622&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Fri May 10 13:52:29 2013
@@ -520,6 +520,8 @@ public:
virtual uint64_t offset() const { return _offset; }
+ void setOrdinal(uint64_t ord) { _ordinal = ord; }
+
virtual uint64_t ordinal() const { return _ordinal; }
virtual uint64_t size() const { return _contentData.size(); }
Modified: lld/trunk/lib/ReaderWriter/ELF/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=181622&r1=181621&r2=181622&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Fri May 10 13:52:29 2013
@@ -122,7 +122,7 @@ public:
ELFFile(const ELFTargetInfo &ti, std::unique_ptr<llvm::MemoryBuffer> MB,
llvm::error_code &EC)
: File(MB->getBufferIdentifier(), kindObject), _elfTargetInfo(ti),
- _doStringsMerge(false) {
+ _ordinal(0), _doStringsMerge(false) {
llvm::OwningPtr<llvm::object::Binary> binaryFile;
EC = createBinary(MB.release(), binaryFile);
if (EC)
@@ -261,6 +261,7 @@ public:
const MergeSectionKey mergedSectionKey(tai->_shdr, tai->_offset);
if (_mergedSectionMap.find(mergedSectionKey) == _mergedSectionMap.end())
_mergedSectionMap.insert(std::make_pair(mergedSectionKey, mergeAtom));
+ mergeAtom->setOrdinal(++_ordinal);
_definedAtoms._atoms.push_back(mergeAtom);
_mergeAtoms.push_back(mergeAtom);
}
@@ -332,8 +333,6 @@ public:
/// \brief Create individual atoms
bool createAtoms(llvm::error_code &EC) {
- int64_t ordinal = 0;
-
// Cached value of the targetHandler
TargetHandler<ELFT> &targetHandler =
_elfTargetInfo.template getTargetHandler<ELFT>();
@@ -368,7 +367,7 @@ public:
sectionContents.size());
auto newAtom = new (_readerStorage) ELFDefinedAtom<ELFT>(
*this, "", sectionName, sym, i.first, content, 0, 0, _references);
- newAtom->setOrdinal(++ordinal);
+ newAtom->setOrdinal(++_ordinal);
_definedAtoms._atoms.push_back(newAtom);
continue;
}
@@ -441,7 +440,7 @@ public:
ArrayRef<uint8_t>(
(uint8_t *)sectionContents.data() + (*si)->st_value,
contentSize));
- anonAtom->setOrdinal(++ordinal);
+ anonAtom->setOrdinal(++_ordinal);
// If this is the last atom, lets not create a followon
// reference
@@ -479,7 +478,7 @@ public:
auto newAtom = createDefinedAtomAndAssignRelocations(
symbolName, sectionName, *si, i.first, symbolData);
- newAtom->setOrdinal(++ordinal);
+ newAtom->setOrdinal(++_ordinal);
// If the atom was a weak symbol, lets create a followon
// reference to the anonymous atom that we created
@@ -720,6 +719,8 @@ private:
/// \brief Sections that have merge string property
std::vector<const Elf_Shdr *> _mergeStringSections;
+ int64_t _ordinal;
+
/// \brief the cached options relevant while reading the ELF File
bool _doStringsMerge : 1;
};
Modified: lld/trunk/test/elf/mergeatoms.objtxt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/mergeatoms.objtxt?rev=181622&r1=181621&r2=181622&view=diff
==============================================================================
--- lld/trunk/test/elf/mergeatoms.objtxt (original)
+++ lld/trunk/test/elf/mergeatoms.objtxt Fri May 10 13:52:29 2013
@@ -3,4 +3,4 @@ RUN: lld -flavor gnu --merge-strings -o
RUN: %p/Inputs/foo.o.x86-64 %p/Inputs/bar.o.x86-64 -e bar1
RUN: llvm-objdump -s %t1 | FileCheck -check-prefix=mergeAtoms %s
-mergeAtoms: 666f6f00 62617200 foo.bar.
+mergeAtoms: 62617200 666f6f00 bar.foo.
More information about the llvm-commits
mailing list