Reputation: 3463
I have some variables in my C code that are declared with __attribute__((section(".data.mystuff")))
. I would like to define two symbols, mystuff_start
and mystuff_size
that have the position and size of the section. It looks like ld
's LOADADDR
and SIZEOF
will do what I want, but I don't want to write the whole linker script. I can't figure out how to use INSERT AFTER
to do what I want either.
Upvotes: 3
Views: 1188
Reputation: 141
The easiest thing to do is to put them into a section that has a valid C identifier as it's name. For example, use:
__attribute__((section("mystuff")))
and you'll have automagic variables __start_mystuff
and __stop_mystuff
which will give you the start and end addresses of the section which you can declare in your source as extern variables.
EDIT: this is completely GCC specific!
Upvotes: 6