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: some question about output section


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 :-)


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