Create section on linker script
Erik Christiansen
dvalin@internode.on.net
Mon Jan 13 11:43:00 GMT 2014
On 13.01.14 11:09, João Pires wrote:
> Hi, I'm interested in create sections during the link phase.
> These sections will have no data and will have two symbols.
> At the moment I have the follow code.
>
> .foo :
> {
> foo_begin = ORIGIN(.foo);
> foo_end = ORIGIN(.foo) + SIZEOF(.foo);
> }
>
> This code creates the two symbols, but don't create the section .foo
> My question is there are any way to do this?
The easiest way is to put something in it, so there is something to
create, I figure.
Incidentally, the above example generates:
warning: memory region `.foo' not declared
because ORIGIN refers to a memory region, not a section.
So s/ORIGIN/ADDR on both script lines to fix that.
However, since .foo is defined to always be empty, both symbols must be
the same, raising the question; what is it that you'd like "created",
and where?
If the "creation" were to involve populating the section with one or
more of those variables, e.g.:
.foo :
{
foo_begin = ADDR(.foo);
foo_end = ADDR(.foo) + SIZEOF(.foo);
LONG(foo_begin);
} > text
then the section pops into existence as expected:
2 .foo 00000004 00007ce4 00007ce4 00007d98 2**0
CONTENTS, ALLOC, LOAD, DATA
populated with:
0x00007ce4 0x4 LONG 0x7ce4 foo_begin
If what you'd like "created" is something else, then a bit more
information would help.
Erik
--
It's always sad when the fleas leave, because that means your dog is dead.
- Wesley T. Williams
More information about the Binutils
mailing list