[llvm-dev] [libLTO] accessing llvm.global_ctors
Steven Wu via llvm-dev
llvm-dev at lists.llvm.org
Mon Jul 26 13:03:03 PDT 2021
> On Jul 26, 2021, at 10:59 AM, Wael Yehia <wyehia at ca.ibm.com> wrote:
>
>
>
>
> -----"Steven Wu" <stevenwu at apple.com> wrote: -----
> To: "Wael Yehia" <wyehia at ca.ibm.com>
> From: "Steven Wu" <stevenwu at apple.com>
> Date: 07/26/2021 12:22PM
> Cc: "Fangrui Song" <maskray at google.com>, llvm-dev at lists.llvm.org
> Subject: [EXTERNAL] Re: [llvm-dev] [libLTO] accessing llvm.global_ctors
>
>> It also sounds like that you just need to know if the object file has constructor or not, but don't really care anything more than that?
> yes
>
>
>> Can you read the section name from the IRSymtab to figure out if that is a constructor/destructor or not?
> Is this a suggestion of how to implement the query I'm after?
> My initial thought was to simply check for the presence of the symbols `llvm.global_ctors` and `llvm.global_dtors` in the ModuleSymbolTable in the LTOModule.
The reason why I don't want to do that is because they are not real symbols and linker do not know how to resolve them. You could stamp a different attribute on them but the old linker will not be able to understand them.
If the only thing you care about is checking the existence of ctors and dtors, and all you need is using fullLTO with libLTO, reading intrinsics is probably fine. ThinLTO or using the new C++ LTO interface doesn't really use ModuleSymbolTable. Also trying to read what the constructors are will be quite expensive from those functions because they needs to be materialized so you don't want to do that when you just querying the symbol names
>
>
>>> Certain linker flag forces it to include all archive members that have a constructor or destructor. I agree it's strange.
>>
>> Is it possible to disclose what linker and what platform that is? You don't have to but it would be easier to maintain if you can document this behavior that is unique to the platform you are looking at.
> The linker is the system linker on AIX, and the option is -bcdtors:all (documented here: https://www.ibm.com/docs/en/aix/7.2?topic=l-ld-command)
>
Looks reasonable. Just remember to mention that in your patch.
Steven
More information about the llvm-dev
mailing list