开发者

How do I specify output sections in C files compiled using GCC?

In assembly language I use .section directive to tell the assembler what section to output to开发者_Go百科 e.g

.section init

Is there a way to do the same in C files. I want the code for some files to go into different section so I can load it to different memory address. I know I can create a script for ld and specify sections there but I dont want to do that. Is there some compiler switch or .section directive kind of thing for C files that will do this?


There is:

__attribute__((section("section_name")))

So, for example:

void foo() __attribute__((section(".text_foo")));

....

void foo() {}

Would place foo in .text_foo

See here for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜