[cfe-dev] clang generating aliases to aliases and breaking llvm-link

Daniel Dunbar daniel at zuster.org
Sun Apr 18 08:35:27 PDT 2010


My opinion is that this is an llvm linker bug. Can you file a bugzilla
for it with a test case (ideally, a small set of .bc files that cause
it to fail)?

On Fri, Apr 16, 2010 at 1:31 PM, Adam Langley <agl at imperialviolet.org> wrote:
> (LLVM and Clang built from r101478)
>
> Background: I want to run ots[1], which parses and sanitises TrueType
> files, under KLEE.

Cool, I'd love to hear if this works, eventually.

 - Daniel

> My first step was to build it with clang:
>
> $ for x in $(ls *.cc) ; do clang++ -c -g -emit-llvm -I../include  $x; done
>
> And then try to link it:
>
> $ llvm-link -o out *.o
> llvm-link: LinkModules.cpp:767: bool LinkAlias(llvm::Module*, const
> llvm::Module*, std::map<const llvm::Value*, llvm::Value*,
> std::less<const llvm::Value*>, std::allocator<std::pair<const
> llvm::Value* const, llvm::Value*> > >&, std::string*): Assertion `VMI
> != ValueMap.end() && "Aliasee not linked"' failed.
> 0  llvm-link       0x000000000054a49f
> 1  llvm-link       0x000000000054c38a
> 2  libpthread.so.0 0x000000364b00f0f0
> 3  libc.so.6       0x000000364a8326d5 gsignal + 53
> 4  libc.so.6       0x000000364a833eb5 abort + 373
> 5  libc.so.6       0x000000364a82b7c5 __assert_fail + 245
> 6  llvm-link       0x000000000044546e
> 7  llvm-link       0x0000000000446e62
> 8  llvm-link       0x0000000000405d27 main + 327
> 9  libc.so.6       0x000000364a81eb1d __libc_start_main + 253
> 10 llvm-link       0x0000000000405009
> Stack dump:
> 0.      Program arguments: llvm-link -o out cff.o cmap.o cvt.o fpgm.o
> gasp.o glyf.o hdmx.o head.o head-test.o hhea.o hmtx.o kern.o loca.o
> ltsh.o maxp.o name.o os2.o ots.o post.o prep.o vdmx.o vorg.o
> Aborted (core dumped)
>
> By adding debugging to LinkModules.cpp, we find that the symbol that
> is causing it to explode is
> _ZNSt12_Vector_baseIN12_GLOBAL__N_118CMAPSubtableHeaderESaIS1_EE12_Vector_implD1Ev.
>
> >From running llvm-nm on some of the .o files, there are a couple of
> files with symbols that are marked as '?'. It's these symbols which
> kill llvm-link.
>
> Adding more debugging to llvm-nm (see patch below), it turns out that
> these symbols are aliases to aliases of functions, and aliases to
> aliases to aliases of functions:
>
>         T _ZNSt6vectorIN12_GLOBAL__N_118CMAPSubtableHeaderESaIS1_EED1Ev
>         { _ZNSt12_Vector_baseIN12_GLOBAL__N_118CMAPSubtableHeaderESaIS1_EE12_Vector_implD1Ev
>         ( _ZNSt12_Vector_baseIN12_GLOBAL__N_118CMAPSubtableHeaderESaIS1_EE12_Vector_implD2Ev
>         T _ZNSaIN12_GLOBAL__N_118CMAPSubtableHeaderEED2Ev
>
> Here my knowledge gives out. I'm not sure if clang is generating bad
> output, or if llvm-link should be able to handle it.
>
> Any ideas?
>
>
> Cheers
>
> AGL
>
>
> Index: tools/llvm-nm/llvm-nm.cpp
> ===================================================================
> --- tools/llvm-nm/llvm-nm.cpp   (revision 101478)
> +++ tools/llvm-nm/llvm-nm.cpp   (working copy)
> @@ -82,6 +82,16 @@
>     const GlobalValue *AliasedGV = GA->getAliasedGlobal();
>     if (isa<Function>(AliasedGV))                          return 'T';
>     if (isa<GlobalVariable>(AliasedGV))                    return 'D';
> +    if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(AliasedGV)) {
> +      const GlobalValue *AliasedGV = GA->getAliasedGlobal();
> +      if (isa<Function>(AliasedGV))                        return '(';
> +      if (isa<GlobalVariable>(AliasedGV))                  return ')';
> +      if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(AliasedGV)) {
> +        const GlobalValue *AliasedGV = GA->getAliasedGlobal();
> +        if (isa<Function>(AliasedGV))                      return '{';
> +        if (isa<GlobalVariable>(AliasedGV))                return '}';
> +      }
> +    }
>   }
>                                                            return '?';
>  }
>
>
>
> [1] http://code.google.com/p/ots/
>
> --
> Adam Langley agl at imperialviolet.org http://www.imperialviolet.org
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list