* ld scripting help
@ 2007-09-10 19:08 Davis, Clayton
2007-09-17 12:36 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: Davis, Clayton @ 2007-09-10 19:08 UTC (permalink / raw)
To: binutils
I am trying to link a file in a specific way and need help understanding how to write the linker script.
I know that the order of the sections needs to be.
SECTIONS
}
.text
.syscall
.fixaddr
.fixtype
.intercall
.interfunc
.rodata
.secinfo
.data
.bss
}
And I know that the application needs to start at 0x00000000.
I tried
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm","elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SEARCH_DIR("/scratch/paul/release/install/i686-mingw32/arm-none-elf/arm-none-elf/lib");
SECTIONS
{
.text 0x00000000 : {*(.test)}
current = .;
.syscall current :{*(.syscall)}
current = .;
.fixaddr current :{*(.fixaddr)}
current = .;
.fixtype current :{*(.fixtype)}
current = .;
.intercall current :{*(.intercall)}
current = .;
.rodata current :{*(.rodata)}
current = .;
.secinfo current :{*(.secinfo)}
current = .;
.data current :{*(.data)}
current = .;
.bss current :{*(.bss)}
}
Just to see if it would work
I'm new to linker scripts so I would appreciate any help you could give me. I am using ld 2.15.94 on windows 2000.
Additionally I am getting a "_start not found" error. I have tried to include crt0.o directly from the lib directory and using the script I just showed, but is complains about
In function _sbrk within file Libg.a
End <- undefined reference
In function start within file crt0.S
_int
__bss_start__
__bss_end__
_fini
Thank you for your time.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ld scripting help
2007-09-10 19:08 ld scripting help Davis, Clayton
@ 2007-09-17 12:36 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2007-09-17 12:36 UTC (permalink / raw)
To: Davis, Clayton; +Cc: binutils
Hi Clayton,
> I know that the order of the sections needs to be.
>
> SECTIONS
> }
I assume that you meant "{" here ... :)
> .text
> .syscall
> .fixaddr
> .fixtype
> .intercall
> .interfunc
> .rodata
> .secinfo
> .data
> .bss
> }
>
> And I know that the application needs to start at 0x00000000.
The start address can be specified on the linker command line via the --entry
command line option. A linker script can provide a default start address which
is used when the linker command line option is not provided. This is done via
the ENTRY() directive in the script which names a symbol whose value is the
start address. (You mention encountering problems with the _start symbol being
undefined. This is because it was used in the ENTRY() command in your linker
script, but you had not provided a definition of the _start symbol).
> I tried
> SECTIONS
> {
> .text 0x00000000 : {*(.test)}
> current = .;
> .syscall current :{*(.syscall)}
Using "current" like this should not be necessary. By default the linker will
place each named output section after the end of the previously named output
section. ie you can do this:
.text 0x0 : { *(.test) }
.syscall : { *(.syscall} }
etc. By the way did you really mean "*(.test)" as being the input sections
that should be placed into the .text output section, or did you mean "*(.text)" ?
> Just to see if it would work
The implication being that it did not work. Can you say how it failed ?
By the way if you use the "-Map <file>" linker command line switch you can have
the linker create a map file (called <file>) which will show you exactly how
the linker has laid out the executable that it creates.
> I'm new to linker scripts so I would appreciate any help you could give me.
Try reading the linker manual. It has a large section on linker scripts
including examples of how the directives work.
Also try running "ld --verbose" to see the default, built-in linker script.
You can load this output into a text editor, trim away the unnecessary comments
at the start and end and then use the resulting file as your own linker script.
In this way you could tweak the order of the output sections to get the
ordering that you want.
> I am using ld 2.15.94 on windows 2000.
Version 2.18 of the linker (and other binutils) is now out, so it would be a
very good idea to upgrade to them if you can.
> Additionally I am getting a "_start not found" error. I have tried to include crt0.o directly from the lib directory and using the script I just showed, but is complains about
>
> In function _sbrk within file Libg.a
> End <- undefined reference
The answer to this problem has already been given to you on the gnu-arm mailing
list...
Cheers
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-09-17 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-10 19:08 ld scripting help Davis, Clayton
2007-09-17 12:36 ` Nick Clifton
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).