Linking problem.

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Linking problem.

Post by Mikae »

Hello all!

Again, I have problem with linker, 'ld'. When I link my .asm file and .c file into flat binary everything is Ok. But when I try to call a function from third .c file linker doesn't insert correct 'call' instruction (it points to a very strange place in the flat binary). I use the following script file to link it together:

Code: Select all

SECTIONS
{
	. = 0x10000;
	.text : { pm.o(.flat) test.o(.text) test2.o(.text) }
}
OUTPUT_FORMAT(binary)
OUTPUT(test)
Content of .c files:

Code: Select all

void _start()
{
	test2();
	while(1);
}
void (*_start_ptr)() = _start;

Code: Select all

void test2()
{
}
And I get the following flat file which is incorrect...


I'am using Cygwin + recompiled binutils 2.16 (targeted to i586-elf, like in Wiki). Any ideas?..

TIA, Mikae.
Attachments
ldr.rar
(424 Bytes) Downloaded 15 times
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Post by Mikae »

I found out, that problem exists only under cygwin. When I link under BSD everything is Ok... But how to force cygwin's 'ld' to work correctly?..
Post Reply