How do you get the start and end addresses of a custom ELF section?

前端 未结 5 567
粉色の甜心
粉色の甜心 2020-12-05 02:57

I\'m working in C on Linux. I\'ve seen the usage of of the gcc __section__ attribute (especially in the Linux kernel) to collect data (usually function pointers) into custom

5条回答
  •  有刺的猬
    2020-12-05 03:32

    So the answer above, __start_SECTION and __stop_SECTION will work, however for the program to be able to use the information from the linker you to need to declare those variables as extern char* __start_SECTION. Enjoy!

    extern char * __start_blobby;
    
    ...
    printf("This section starts at %p\n", (unsigned int)&__start_blobby);
    ...
    

提交回复
热议问题