LD, section start option doesn't work?

Programming, for all ages and all languages.
Post Reply
0000
Posts: 9
Joined: Tue Jul 06, 2010 6:44 pm

LD, section start option doesn't work?

Post by 0000 »

Hi,

I just want to set the .text segment address through ld's option (--section-start .text=org).
Nevertheless, after linking, the .text segment start at an other address.

My code is similar to:

Code: Select all

[...]
.text
.global _start
_start:
    xor eax,eax
    inc eax
    int 0x80
Assembling, linking:

Code: Select all

as -o test.o test.s
ld --section-start .text=0x08048000 --oformat binary -o test test.o
_start isn't located at 0x08048000 but at 0x080480da.
So, what is wrong ?
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: LD, section start option doesn't work?

Post by gerryg400 »

Disassemble/inspect the output and look what is in the first 0xda bytes. Is it startup code ? Junk ?

Isn't the syntax

Code: Select all

ld --section-start=.text=0x08048000 --oformat binary -o test test.o
i.e. 2 equal signs ?
If a trainstation is where trains stop, what is a workstation ?
0000
Posts: 9
Joined: Tue Jul 06, 2010 6:44 pm

Re: LD, section start option doesn't work?

Post by 0000 »

gerryg400 wrote:Disassemble/inspect the output and look what is in the first 0xda bytes. Is it startup code ? Junk ?
It startup with code:

Code: Select all

$ hexdump -Cn 9 -s 218 load-sym  
000000da  31 c0 40 cd 80 74 65 0d  07                       |1À@Í.te..|
We can find the xor instruction at the first byte.
It's really difficult to disassemble/debug, because I'm writing his own elf header and use some tricks
to reduce his size.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: LD, section start option doesn't work?

Post by gerryg400 »

I mean 'what is at the beginning of the file'?
If a trainstation is where trains stop, what is a workstation ?
Post Reply