public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Klaus Rudolph <lts-rudolph@gmx.de>
To: Erik Christiansen <erik@dd.nec.com.au>,  ramana.venkat83@gmail.com
Cc: binutils@sourceware.org
Subject: Re: execute code in ram, linker script
Date: Fri, 03 Aug 2007 05:28:00 -0000	[thread overview]
Message-ID: <46B2BDB6.9000806@gmx.de> (raw)
In-Reply-To: <20070803004600.GA8463@dd.nec.com.au>

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
> 

  reply	other threads:[~2007-08-03  5:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-30 19:15 Klaus Rudolph
2007-08-03  0:38 ` Erik Christiansen
2007-08-03  5:28   ` Klaus Rudolph [this message]
2007-08-01 11:07 Ramana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46B2BDB6.9000806@gmx.de \
    --to=lts-rudolph@gmx.de \
    --cc=binutils@sourceware.org \
    --cc=erik@dd.nec.com.au \
    --cc=ramana.venkat83@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).