linking problem
Posted: Mon Aug 06, 2007 2:34 pm
hi
i have yet again a problem linking somthing. suppose i have the following object file:
I link this file together with two other object files:
The linker script looks is as follows:
When I disassemble the linked result, I get this:
You can see clearly here that what is placed right at the start of the linked result is the code that comes in section .text of the object file just before the function "start" EVEN THOUGH I have specified in my linker command that "start" be the entry point. The problem is that this part of section .text is not only NOT supposed to be the start of my code, but that it is really READONLY data placed into the .text section by the compiler for some reason. Can I do anything about this? If yes, how can I change it?
Thanks
Martin
i have yet again a problem linking somthing. suppose i have the following object file:
Code: Select all
main.o: file format elf32-i386
Disassembly of section .data:
00000000 <.data>:
0: ff (bad)
1: ff (bad)
2: ff (bad)
3: ff .byte 0xff
Disassembly of section .text:
00000000 <.text>:
0: 06 push %es
1: 00 00 add %al,(%eax)
3: 00 06 add %al,(%esi)
5: 00 00 add %al,(%eax)
7: 00 48 65 add %cl,0x65(%eax)
a: 6c insb (%dx),%es:(%edi)
b: 6c insb (%dx),%es:(%edi)
c: 6f outsl %ds:(%esi),(%dx)
d: 2e 00 00 add %al,%cs:(%eax)
Disassembly of section .text:
00000000 <start>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 68 08 00 00 00 push $0x8
8: e8 fc ff ff ff call 9 <start+0x9>
d: 89 ec mov %ebp,%esp
f: 5d pop %ebp
10: c3 ret
Code: Select all
ld main.o video.o utilities.o -e start -N -o boot.bin --oformat binary -T script
Code: Select all
SECTIONS
{
. = 0x0;
.text : { *(.text) }
.data : { *(.data) }
.bss : { *(.bss) }
}
Code: Select all
00000000 06 push es
00000001 0000 add [eax],al
00000003 0006 add [esi],al
00000005 0000 add [eax],al
00000007 004865 add [eax+0x65],cl
0000000A 6C insb
0000000B 6C insb
0000000C 6F outsd
0000000D 2E0000 add [cs:eax],al
00000010 55 push ebp
00000011 89E5 mov ebp,esp
...and so on
Thanks
Martin