ld script help

View: New views
5 Messages — Rating Filter:   Alert me  

ld script help

by Hans Schwarz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am using binutils 2.18 and am having problems with the linker script. I am somewhat new to linker scripting and the problem is that the binary file being created by ld is too big. My linker script is as follows:

OUTPUT_FORMAT("binary")
ENTRY(_start)
SECTIONS
{
  .text 0x100000 : {
    code = .; _code = .; __code = .;
    *(.text)
    . = ALIGN(4096);
  }
  .data  : {
    data = .; _data = .; __data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss  :
  {
    bss = .; _bss = .; __bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .; _end = .; __end = .;
}

It seems that the binary file does put everything in "proper" place, like the code at 0x100000, but with previous ld versions the binary was getting around 50k and this version is building a 1mb+ binary. I don't know what I am missing here, can someone help me? Is there some kind of compression the ld should do?

Re: ld script help

by Hans Schwarz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Lighbringer wrote:
I am using binutils 2.18 and am having problems with the linker script. I am somewhat new to linker scripting and the problem is that the binary file being created by ld is too big. My linker script is as follows:

OUTPUT_FORMAT("binary")
ENTRY(_start)
SECTIONS
{
  .text 0x100000 : {
    code = .; _code = .; __code = .;
    *(.text)
    . = ALIGN(4096);
  }
  .data  : {
    data = .; _data = .; __data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss  :
  {
    bss = .; _bss = .; __bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .; _end = .; __end = .;
}

It seems that the binary file does put everything in "proper" place, like the code at 0x100000, but with previous ld versions the binary was getting around 50k and this version is building a 1mb+ binary. I don't know what I am missing here, can someone help me? Is there some kind of compression the ld should do?
One other thing, my calling linker line is
ld  -T script.ld -o foo.o <input files>

There's a working workaround, that creates the file I was expecting like this
ld --oformat binary -o foo.o <input files> -Ttext 0x100000

But I would really like to put things in the script.

Re: ld script help

by Daniel Jacobowitz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 26, 2007 at 07:41:47AM -0700, Lighbringer wrote:
>
> I am using binutils 2.18 and am having problems with the linker script. I am
> somewhat new to linker scripting and the problem is that the binary file
> being created by ld is too big. My linker script is as follows:

Use -Map to see what is being placed where.  There are probably some
sections that you did not assign locations to and they're probably
being placed at 0.

--
Daniel Jacobowitz
CodeSourcery

Re: ld script help

by Hans Schwarz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Daniel Jacobowitz-2 wrote:
On Fri, Oct 26, 2007 at 07:41:47AM -0700, Lighbringer wrote:

Use -Map to see what is being placed where.  There are probably some
sections that you did not assign locations to and they're probably
being placed at 0.

--
Daniel Jacobowitz
CodeSourcery
There's no -Map flag at ld.

Re: ld script help

by Daniel Jacobowitz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, Oct 27, 2007 at 07:43:42AM -0700, Lighbringer wrote:
> There's no -Map flag at ld.

I suggest you read the ld manual; you are incorrect.

--
Daniel Jacobowitz
CodeSourcery