Global Variable with ELF Custom Section

Hi everyone,

I have created a custom section in an ELF file with the following code:

GlobalVariable* glob = new GlobalVariable(*mod, type, true, GlobalValue::ExternalLinkage, “test", “myGlobal”);
glob->setSection(“.custom”);

This works great but I have two questions:

  • Can I pass more parameters to the section (like the elf type, the elf flag, etc.). In a macho, you can add information like cstring_literals or no_dead_strip. I did not find anything like it for ELF.
  • When i used the flag -Wl,—gc-sections on Linux, my section is deleted, can I bypass this?

Greetings,

Johan