[LLVMdev] [lld] Allow atoms with empty name in the RefNameBuilder::buildDuplicateNameMap()

Rui Ueyama ruiu at google.com
Tue Feb 4 15:54:31 PST 2014


I'm not opposed to remove the assertion from the file, as I believe a
symbol with empty name is a valid symbol. Not 100% sure what the ELF spec
says, though.


On Tue, Feb 4, 2014 at 2:19 PM, Simon Atanasyan <simon at atanasyan.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140204/f9249c27/attachment.html>


More information about the llvm-dev mailing list