In assembly language I use .section directive to tell the assembler what section to output to 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?
The default executable output of gcc is "a.out", which can be run by typing ./a.out. It is also possible to specify a name for the executable file at the command line by using the syntax -o outputfile , as shown in the following example: gcc filename -o outputfile. Again, you can run your program with "./outputfile".
The option -fno-gnu89-inline explicitly tells GCC to use the C99 semantics for inline when in C99 or gnu99 mode (i.e., it specifies the default behavior).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With