public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: loody <miloody@gmail.com>
To: amodra@gmail.com, binutils@sourceware.org
Subject: Re: some question about output section
Date: Wed, 11 May 2011 06:27:00 -0000	[thread overview]
Message-ID: <BANLkTikOGSufJC8JT9CaVmL1SJ0O06UMzA@mail.gmail.com> (raw)
In-Reply-To: <20110505035729.GF7018@bubble.grove.modra.org>

hi:

2011/5/5 Alan Modra <amodra@gmail.com>:
> On Thu, May 05, 2011 at 11:00:01AM +0800, loody wrote:
>>   .onlyText 0x80000000 : {  lib2.a:*.o (*.text)  }
>
> So this tells ld where to put lib2.a object files,
>
>> mipsel-linux-gnu-ld -Bstatic -T ./link.xn -o TEST_LINK.elf -Map
>> TEST_LINK.map --oformat elf32-tradlittlemips lib2.a
>
> and the above says to extract files from lib2.a if they satisfy
> undefined references at the point where lib2.a is searched in the link
> process.  That is the way archives work.  You don't have any other
> object files or -u command line options, so no undefined symbol
> references!  You'll need --whole-archive to have the entire contents
> of the archive extracted.
>
It did work after I add some object files to let linker to find the
undefined references when lib2.a searched. :P

Meanwhile:
I have some questions below:
1. I found if the address between 2 sections is too large, the objcopy will
automatically fill the gap and the size of final binary file will quite big.

There is a thread below mention about this:
http://sourceware.org/ml/binutils/2008-11/msg00316.html

does that mean the only way I can to do is outputting each section one
by one and merge them by myself?

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?

/*script 1 */
OUTPUT_ARCH(mips)
SECTIONS
{
  .text 0xbfc00000:
  {	*(EXCLUDE_FILE (*.a) .text)  } = 0
	_etext = ABSOLUTE(.);
  .onlyText 0x80000000:    AT( _etext )   {	lib1.a:*.o (*.text)
	_eonlytext = ABSOLUTE(.);  } =0
}

/*script 2*/
OUTPUT_ARCH(mips)
SECTIONS
{
  .text 0xbfc00000:{	*(EXCLUDE_FILE (*.a) .text)  } = 0
	_etext = ABSOLUTE(.);
  .onlyText 0x80000000:    AT( _etext )   {	lib1.a:*.o
(*.text)	_eonlytext = ABSOLUTE(.);  } =0
  .onlyData :  AT(_eonlytext)  {    lib1.a:*.o (*.data)  }
}


Appreciate your kind help :-)

  reply	other threads:[~2011-05-11  6:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 15:29 loody
2011-04-28  0:57 ` Alan Modra
2011-04-28 16:17   ` loody
2011-04-29  0:32     ` Alan Modra
2011-05-01 13:21       ` loody
2011-05-04 15:51         ` loody
2011-05-05  0:35           ` Alan Modra
2011-05-05  3:00             ` loody
2011-05-05  3:57               ` Alan Modra
2011-05-11  6:27                 ` loody [this message]
2011-05-11  7:18                   ` Alan Modra
2011-05-11  8:12                     ` loody
2011-05-18  5:32                     ` loody
2011-05-19  4:31                       ` loody

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=BANLkTikOGSufJC8JT9CaVmL1SJ0O06UMzA@mail.gmail.com \
    --to=miloody@gmail.com \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /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).