This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Create section on linker script

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);
  } > 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.


It's always sad when the fleas leave, because that means your dog is dead.    
                                                      - Wesley T. Williams

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]