Skip to content

differences between GCC and LLVM with __attribute__((constructor)) __attribute__((destructor)) #133246

Open
@LukeSTM

Description

@LukeSTM

demo:

void __attribute__((constructor)) kkk2()
{
        __asm__ volatile ("":::);
}

void __attribute__ ((destructor)) foo()
{
        __asm__ volatile ("":::);
}

https://godbolt.org/z/7shvxT3hY

There are differences in the behavior of __attribute__((constructor)) __attribute__((destructor)) between GCC and LLVM. GCC places functions with the __attribute__((constructor)) attribute in the .text.startup section, and places functions with the __attribute__((destructor)) attribute in the .text.exit section,but LLVM does not. Why is this the case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions