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: ld scripting help


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


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