This is the mail archive of the binutils@sourceware.org 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: execute code in ram, linker script


Thanks a lot for your help,

yes, in between I was able to found "my" problems.
I did not know that I had to have manually collect the sections .ctors .dtors in my rom section. I copied an available ld script from the net but this was wrong. The command (CONSTRUCTORS) was not made for my elf target. My mistake was to believe the constructors will catched by that command but this was not the reality :-)
And it was very misterious that a got a lot of "internal linker errors" will digging through the writing of ld scripts.


And the trouble continous after linking some external libraries, because 2 additional sections came into the build which I had also overseen :-)

But now it builds and the objdump -h looks well. But I have not tested the solution on the target. I will check for global constructors and my ram code. If it works, the work done! I hope it works :-)

Thanks
 Klaus





On Mon, Jul 30, 2007 at 08:15:32PM +0200, Klaus Rudolph wrote:
Hi again,

I need a section in a linker script which should put my code to the
flash and give my the addresses like linked in ram. My startup code
should move the code from flash to ram. Absolutly normal I hope.

Yes, if you look in some crt0.S (more generally crt[01].[Sc]), e.g. from newlib (not so much ELDK, or the linux kernel), you can see an elementary copy loop for .data, and zero initialisation loop for .bss. But as you say, there's no magic at all.

But I am not find the correct way to do it.

Please help!

4 sections needed (.text, .data, .bss and my stupied Flash->RAM section)

Except that .bss is not copied, naturally. :-)


Could someone give me an example. I also need the symbol definition for the copy routine.

OK, it looks like it's the symbol definitions which have you tricked, so here's a quickly cobbled example:

MEMORY
{
   ROM :  org = 0x00100000, len = 0x00100000
   RAM :  org = 0x00000000, len = 0x00080000
}

SECTIONS
{
   VectorsInROM = 0x00140000 ;                  /* Just something to show a */
   .vectors 0x0 : AT (VectorsInROM) {           /* way to abut .data, below */
      *(.vectors)
   } > RAM

__data_rom = VectorsInROM + SIZEOF(.vectors); /* To abut sections in flash. */

/* RAM Flash */
/* | | */
.data 0x00012000 : AT (__data_rom) { /* Terminology = VMA: AT LMA */ __data_start = ABSOLUTE(.); /* Symbol for copy loop. */
*(.data*)
/* More input sections, maybe. */
__data_end = ABSOLUTE(.); /* Symbol for copy loop. */
} > RAM
}


Obviously, if you use a symbol instead of 0x00012000 for VMA, then it's
easier to re-use for the copy loop destination.

But maybe you've managed to research as much by now?  :-)
("info ld" is a goldmine)

Good luck,

Erik



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