define a program section in C code (GCC)

The C standard doesn’t say anything about “sections” in the sense that you mean, so you’ll need to use extensions specific to your compiler.

With GCC, you will want to use the section attribute:

extern void foobar(void) __attribute__((section("bar")));

There is some limited documentation here, including a warning:

Some file formats do not support
arbitrary sections so the section
attribute is not available on all
platforms. If you need to map the
entire contents of a module to a
particular section, consider using the
facilities of the linker instead.

Leave a Comment