From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29486 invoked by alias); 3 Aug 2007 05:28:29 -0000 Received: (qmail 29476 invoked by uid 22791); 3 Aug 2007 05:28:27 -0000 X-Spam-Check-By: sourceware.org Received: from mail.gmx.net (HELO mail.gmx.net) (213.165.64.20) by sourceware.org (qpsmtpd/0.31) with SMTP; Fri, 03 Aug 2007 05:28:20 +0000 Received: (qmail invoked by alias); 03 Aug 2007 05:28:17 -0000 Received: from pD9E61D78.dip.t-dialin.net (EHLO [192.168.16.77]) [217.230.29.120] by mail.gmx.net (mp036) with SMTP; 03 Aug 2007 07:28:17 +0200 X-Authenticated: #3762177 Message-ID: <46B2BDB6.9000806@gmx.de> Date: Fri, 03 Aug 2007 05:28:00 -0000 From: Klaus Rudolph User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Erik Christiansen , ramana.venkat83@gmail.com CC: binutils@sourceware.org Subject: Re: execute code in ram, linker script References: <20070730181532.127240@gmx.net> <20070803004600.GA8463@dd.nec.com.au> In-Reply-To: <20070803004600.GA8463@dd.nec.com.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-08/txt/msg00048.txt.bz2 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 >