This is the mail archive of the binutils@sources.redhat.com 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: a question about link script


Hi Martin,

> Thanks for your answer, but I think you don't understand me. Maybe I
> don't express my question very clear,sorry. I use a example to
> express it. If I have three obj files, a.o, b.o and c.o, I should
> link them as an elf file. My aim is:1. program executes from the
> first instruction in b.o; 2. the first instruction of b.o is located
> at address 0. 
> If I use command "ld -T link.script -o xx.elf b.o a.o c.o", the
> first instruction will be at address 0. But I use a auto makefile,
> so I can't specify it every time. I need a auto solution. 

Try creating a separate entry for b.o in your linker script like this:

    SECTIONS
    {
        . = 0
        .text {
        b.o(.text)
        *(.text)
        }

        ....

This will force the .text section from the b.o file to be placed at
the start of the .text section in the executable, regardless of where
b.o was specified on the linker command line.

Cheers
        Nick


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