From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9481 invoked by alias); 19 May 2011 04:31:58 -0000 Received: (qmail 9459 invoked by uid 22791); 19 May 2011 04:31:55 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,TW_BF,TW_BJ,TW_JC,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-iy0-f169.google.com (HELO mail-iy0-f169.google.com) (209.85.210.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 May 2011 04:31:41 +0000 Received: by iyh42 with SMTP id 42so2476705iyh.0 for ; Wed, 18 May 2011 21:31:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.220.136 with SMTP id hy8mr3242235icb.114.1305779500244; Wed, 18 May 2011 21:31:40 -0700 (PDT) Received: by 10.42.196.70 with HTTP; Wed, 18 May 2011 21:31:40 -0700 (PDT) In-Reply-To: References: <20110428005642.GG19947@bubble.grove.modra.org> <20110429003231.GO19947@bubble.grove.modra.org> <20110505003450.GD7018@bubble.grove.modra.org> <20110505035729.GF7018@bubble.grove.modra.org> <20110511071806.GD3625@bubble.grove.modra.org> Date: Thu, 19 May 2011 04:31:00 -0000 Message-ID: Subject: Re: some question about output section From: loody To: amodra@gmail.com, binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2011-05/txt/msg00279.txt.bz2 hi: 2011/5/18 loody : > hi > 2011/5/11 Alan Modra : >> On Wed, May 11, 2011 at 02:27:09PM +0800, loody wrote: >>> 2. I found if the LMA of 2 sections are quite close, the size of >>> objcopy will get small, script1. >>> But why if the LMA of third section is close to previous section, the >>> size will still get big, script2? >> >> Why do you think the LMAs are close? >> >> Your scripts are setting LMA of a section to the end VMA of the >> previous section. =A0I suspect that wasn't what you intended. >> See ld.info LOADADDR and SIZEOF. >> > > I finally figured out what you mean :) > > I use MEMORY command in my ld script, and I found the LMA of one > section will right behind previous one, even I didn't tell the script > to do so. > > below is some part of my ld script: > MEMORY > { > =A0 =A0 =A0 =A0region0 : org =3D 0xbfc00000, l =3D 24k > =A0 =A0 =A0 =A0region1 : org =3D 0xbfc06000, l =3D 26k > =A0 =A0 =A0 =A0region2 : org =3D 0xbfb04000, l =3D 14k > =A0 =A0 =A0 =A0region3 : org =3D 0x80000000, l =3D 64k > } > .... > .onlyText : =A0{ =A0 =A0 =A0 =A0lib1.a:*.o (*.text) =A0 =A0 =A0 =A0_eonly= text =3D > ABSOLUTE(.); =A0} >region2 AT>region0 > > =A0. =3D ALIGN(4); > =A0_fbss =3D .; > =A0.sbss : =A0 { =A0 =A0*(.sbss) =A0 =A0*(.scommon) =A0 =A0*(.bss) =A0 = =A0*(COMMON) =A0} >region2 > > ... > > > Below is the output of map: > .sbss =A0 =A0 =A0 =A0 =A0 0x00000000bfb05540 =A0 =A0 =A0 0x60 load addres= s 0x00000000bfc0187c > =A0*(.sbss) > =A0*(.scommon) > =A0.scommon =A0 =A0 =A0 0x00000000bfb05540 =A0 =A0 =A0 =A00x4 main.o > > > It seem ".sbss" adopt the same setting of .onlyText even I didn't at > AT>region0 at the end. > > appreciate your help, > miloody I do the following experimemts: 1. assign address directly instead of using MEMORY comamnd ".sbss" still adopt the same setting of .onlyText .onlyText 0x00000000bfb04000 0x70 load address 0x00000000bfc003= 0c Zebra*(.text) .text 0x00000000bfb04000 0x70 Zebra.o 0x00000000bfb04000 testmain1 0x00000000bfb04070 _eonlytext =3D ABSOLUTE (= .) 0x00000000bfb04070 . =3D ALIGN (0x4) 0x00000000bfb04070 _fbss =3D . .sbss 0x00000000bfb04070 0x4 load address 0x00000000bfc003= 7c *(.sbss) *(.scommon) 2. I purposely let the content of .onlyText be empty and ".sbss" will have the LMA that I expected. ---------------------------------------------------------------------------= --- .onlyText 0xbfb04000:AT(_etext) =A0{ =A0 =A0 =A0 /*=A0Zebra*(.text)*/ _eonlytext =3D ABSOLUTE(.); =A0} =A0. =3D ALIGN(4); =A0_fbss =3D .; =A0.sbss : =A0 { =A0 =A0*(.sbss) =A0 =A0*(.scommon) =A0 =A0*(.bss) =A0 =A0= *(COMMON) =A0} ---------------------------------------------------------------------------= ---- .onlyText 0x00000000bfb04000 0x0 load address 0x00000000bfc003= 80 0x00000000bfb04000 _eonlytext =3D ABSOLUTE (= .) 0x00000000bfb04000 . =3D ALIGN (0x4) 0x00000000bfb04000 _fbss =3D . .sbss 0x00000000bfb04000 0x4 *(.sbss) *(.scommon) .scommon 0x00000000bfb04000 0x4 main.o Why the attributes of .sbss is depended on the size of previous section? If I didn't assign the LMA address of .sbss, it should be reset instead of using the end of previous one, right? Thanks a lot,