[llvm-dev] __cxx_global_var_init rearranged by lld

David Blaikie via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 22 21:32:24 PDT 2020


Guessing in the dark here - I'd say your programs are relying on
unspecified behavior on the order of certain global constructors, and
should be changed to not do that.

But if you have a reduced test case that shows the difference in
behavior we can take a closer look and verify whether that's actually
what's happening.

On Mon, Jun 22, 2020 at 7:04 PM Moshtaghi, Alireza via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hi
>
> I’m working on replacing our linker (ld 2.24) with lld however, seems like some of the template ctors are not placed in the same order by lld and we end up with some null pointers and I believe it has to do with the order of initializations of.
>
> I used nm -n to compare the symbols in the output of ld vs lld and found that many symbols are placed differently…
>
> When I grep the symbols to only see __cxx_global_var_init… I see that some are placed by lld differently than ld
>
> Question:
>
> The __cxx_global_var_initN symbols usually have a unique number (N) at the end but for my case there are few that do not have the unique number and some don’t even have any number (Just __cxx_global_var_init) because they are originated from different compilation units so I can’t use  --symbol-ordering-file to tell lld to place them in the order I like. How can I force these symbols to have unique number so there is no confusion ?
>
>
>
> Has anyone else had the same kind of problem before? And how did you fix it?
>
>
>
> Thanks
>
> A
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list