[LLVMdev] [lld] Allow atoms with empty name in the RefNameBuilder::buildDuplicateNameMap()
Simon Atanasyan
simon at atanasyan.com
Tue Feb 4 14:19:16 PST 2014
Hi,
Method RefNameBuilder::buildDuplicateNameMap() has an assert which
blocks atoms with empty name. In general it looks reasonable but some
toolchains (for example Sourcery CodeBench in both MIPS and ARM
editions) can generate an object file contains absolute STT_FILE
symbols with empty name. Moreover crt1.o object file from this
toolchain has such symbol. I do not know is it a feature or bug but
that behavior exists for a long time.
Here is the reproduction script:
[[
$ cat test.c
void foo() {}
$ mips-linux-gnu-gcc -c test.c
$ mips-linux-gnu-gcc -r -nostdlib test.o
$ readelf -s a.out | grep FILE
9: 00000000 0 FILE LOCAL DEFAULT ABS test.c
10: 00000000 0 FILE LOCAL DEFAULT ABS
]]
I suggest to remove assert from the
RefNameBuilder::buildDuplicateNameMap() method. I think we do not
break anything in that case.
Any objections, comments, suggestions?
[[
--- a/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
+++ b/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
@@ -101,7 +101,6 @@ public:
}
void buildDuplicateNameMap(const lld::Atom &atom) {
- assert(!atom.name().empty());
NameToAtom::iterator pos = _nameMap.find(atom.name());
if (pos != _nameMap.end()) {
// Found name collision, give each a unique ref-name.
]]
--
Simon Atanasyan
More information about the llvm-dev
mailing list