[lld] r192939 - [ELF] Set ordinals properly to all atoms.
Shankar Easwaran
shankare at codeaurora.org
Thu Oct 17 19:12:17 PDT 2013
Author: shankare
Date: Thu Oct 17 21:12:17 2013
New Revision: 192939
URL: http://llvm.org/viewvc/llvm-project?rev=192939&view=rev
Log:
[ELF] Set ordinals properly to all atoms.
Added:
lld/trunk/test/elf/X86_64/Inputs/rodata.c
lld/trunk/test/elf/X86_64/Inputs/rodata.o
lld/trunk/test/elf/X86_64/Inputs/rodata.s
lld/trunk/test/elf/X86_64/rodata.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Atoms.h
lld/trunk/lib/ReaderWriter/ELF/File.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=192939&r1=192938&r2=192939&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Thu Oct 17 21:12:17 2013
@@ -516,7 +516,7 @@ public:
_referenceEndIndex = _referenceList.size();
}
- void setOrdinal(uint64_t ord) { _ordinal = ord; }
+ virtual void setOrdinal(uint64_t ord) { _ordinal = ord; }
private:
const ELFFile<ELFT> &_owningFile;
@@ -561,7 +561,7 @@ public:
virtual uint64_t offset() const { return _offset; }
- void setOrdinal(uint64_t ord) { _ordinal = ord; }
+ virtual void setOrdinal(uint64_t ord) { _ordinal = ord; }
virtual uint64_t ordinal() const { return _ordinal; }
@@ -645,9 +645,7 @@ public:
return _ordinal;
}
- void setOrdinal(uint64_t ord) {
- _ordinal = ord;
- }
+ virtual void setOrdinal(uint64_t ord) { _ordinal = ord; }
virtual uint64_t size() const {
return _symbol->st_size;
Modified: lld/trunk/lib/ReaderWriter/ELF/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/File.h?rev=192939&r1=192938&r2=192939&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/File.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/File.h Thu Oct 17 21:12:17 2013
@@ -302,7 +302,7 @@ public:
} else if (isCommonSymbol(&*SymI)) {
auto *newAtom = new (_readerStorage)
ELFCommonAtom<ELFT>(*this, *symbolName, &*SymI);
- newAtom->setOrdinal(_ordinal++);
+ newAtom->setOrdinal(++_ordinal);
_definedAtoms._atoms.push_back(newAtom);
_symbolToAtomMapping.insert(std::make_pair(&*SymI, newAtom));
} else {
@@ -361,6 +361,7 @@ public:
ELFDefinedAtom<ELFT> *newAtom = createSectionAtom(
section, *sectionName, secCont);
_definedAtoms._atoms.push_back(newAtom);
+ newAtom->setOrdinal(++_ordinal);
continue;
}
@@ -408,6 +409,7 @@ public:
*this, symbolName, *sectionName, &**si, section, symbolData,
_references.size(), _references.size(), _references);
_definedAtoms._atoms.push_back(definedMergeAtom);
+ definedMergeAtom->setOrdinal(++_ordinal);
}
continue;
}
Added: lld/trunk/test/elf/X86_64/Inputs/rodata.c
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/Inputs/rodata.c?rev=192939&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/Inputs/rodata.c (added)
+++ lld/trunk/test/elf/X86_64/Inputs/rodata.c Thu Oct 17 21:12:17 2013
@@ -0,0 +1,3 @@
+const char _nl_default_default_domain[] __attribute__ ((visibility ("hidden"))) = "messages";
+const char *_nl_current_default_domain __attribute__ ((visibility ("hidden"))) = _nl_default_default_domain;
+const char _nl_default_default_dirname[] = "/usr/local";
Added: lld/trunk/test/elf/X86_64/Inputs/rodata.o
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/Inputs/rodata.o?rev=192939&view=auto
==============================================================================
Binary files lld/trunk/test/elf/X86_64/Inputs/rodata.o (added) and lld/trunk/test/elf/X86_64/Inputs/rodata.o Thu Oct 17 21:12:17 2013 differ
Added: lld/trunk/test/elf/X86_64/Inputs/rodata.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/Inputs/rodata.s?rev=192939&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/Inputs/rodata.s (added)
+++ lld/trunk/test/elf/X86_64/Inputs/rodata.s Thu Oct 17 21:12:17 2013
@@ -0,0 +1,24 @@
+ .file "x.c"
+ .hidden _nl_default_default_domain
+ .globl _nl_default_default_domain
+ .section .rodata._nl_default_default_domain,"ams", at progbits,1
+ .type _nl_default_default_domain, @object
+ .size _nl_default_default_domain, 9
+_nl_default_default_domain:
+ .string "messages"
+ .hidden _nl_current_default_domain
+ .globl _nl_current_default_domain
+ .section .data._nl_current_default_domain,"aw", at progbits
+ .align 8
+ .type _nl_current_default_domain, @object
+ .size _nl_current_default_domain, 8
+_nl_current_default_domain:
+ .quad _nl_default_default_domain
+ .globl _nl_default_default_dirname
+ .section .rodata._nl_default_default_dirname,"ams", at progbits,1
+ .type _nl_default_default_dirname, @object
+ .size _nl_default_default_dirname, 11
+_nl_default_default_dirname:
+ .string "/usr/local"
+ .ident "GCC: (Ubuntu 4.8.1-2ubuntu1~10.04.1) 4.8.1"
+ .section .note.GNU-stack,"", at progbits
Added: lld/trunk/test/elf/X86_64/rodata.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/rodata.test?rev=192939&view=auto
==============================================================================
--- lld/trunk/test/elf/X86_64/rodata.test (added)
+++ lld/trunk/test/elf/X86_64/rodata.test Thu Oct 17 21:12:17 2013
@@ -0,0 +1,9 @@
+# This tests that the ordinals for all merge atoms and defined atoms have been
+# set properly
+
+RUN: lld -flavor gnu -target x86_64 %p/Inputs/rodata.o --noinhibit-exec \
+RUN: --merge-strings -static -o %t1
+RUN: llvm-nm -n %t1 | FileCheck %s
+
+CHECK: {{[0-9a-f]+}} R _nl_default_default_domain
+CHECK: {{[0-9a-f]+}} R _nl_default_default_dirname
More information about the llvm-commits
mailing list