[LLVMdev] static initialization
Hiesgen, Raphael
Raphael.Hiesgen at haw-hamburg.de
Thu Dec 18 07:13:47 PST 2014
Hi Tim,
sorry it took me so lang to reply.
>> Apparently it works in a similar way on clang, but remains silent on the details.
>
> The main issue I saw is that Clang doesn't supply a
> crtbegin.o/crtend.o. Actually, I think most of that bit is documenting
> the Linux platform ABI rather than any universal truths. When
> compiling for Linux, Clang uses GCC's version of those files.
>
> But it sounds like you're creating your own anyway, so it probably
> doesn't matter.
My target platform is OS X and later different embedded devices. For the gcc build it is indeed not necessary to provide the crt*.o files. I simply defined __init_array_{start, end} as extern and called all contained functions
>> Is there a more detailed documentation I have overlooked or could you give me a hint how to acquire function pointers?
>
> All the sections and so on are ABI details so they should be identical
> when targeting the same platform. Are you seeing some particular
> problem with the code emitted by Clang?
>
> Across CPUs main difference to watch out for is whether .init_array
> (newer systems) or .ctors (the traditional way) is being used
> primarily. But both Clang and GCC should agree in each case.
I have a newer system and .init_array is probably the section in use. I searched online for crt* files (and how to write or use them). While I found some, they did not work for or I used them wrong. I guess my understanding of how the whole thing is supposed to work is not that good yet.
Thanks
Raphael
More information about the llvm-dev
mailing list