Linux MIPS Architecture development
 help / color / mirror / Atom feed
* mips64 linker bug?
@ 2001-07-21  9:27 Lars Munch Christensen
  2001-07-21 15:23 ` Ralf Baechle
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Munch Christensen @ 2001-07-21  9:27 UTC (permalink / raw)
  To: linux-mips

Hi All

I think I have found a linker bug!

I use the following cross compilers from sgi's ftp:

binutils-mips64-linux-2.9.5-3.i386.rpm
egcs-mips64-linux-1.1.2-4.i386.rpm
binutils-mips64el-linux-2.9.5-3.i386.rpm
egcs-mips64el-linux-1.1.2-4.i386.rpm

Anyway the bug is that static functions get linked wrongly.
Test program:
---------------------
/* This function has to be here to get the error */
int test1(void) {
	return 1;
}

static int test2(void) { /* <---- notice this static */
	return 2;
}

int main() {

	test2();
	return 1;
}

---------------------

Compile and link with:

mips64-linux-gcc -mcpu=r4600 -mabi=64 -mips3 -g -c -O2  -o main.o main.c
mips64-linux-ld -m elf64btsmip  -nostdlib -e main main.o -o main.elf

Now I see the bug where main calls test2:

Doing a 'mips64-linux-objdump -S test.elf' gives me:

main.elf:     file format elf64-bigmips

Disassembly of section .text:

00000000100000f0 <test1>:
        return 1;
    100000f0:   03e00008        jr      $ra
    100000f4:   24020001        li      $v0,1

00000000100000f8 <test2>:
}

static int test2(void) {
        return 2;
    100000f8:   03e00008        jr      $ra
    100000fc:   24020002        li      $v0,2

0000000010000100 <main>:
}

int main() {
    10000100:   67bdfff0        0x67bdfff0
    10000104:   ffbf0000        0xffbf0000

0000000010000108 <$LM6>:

        test2();
    10000108:   0c000044        jal     10000110 <$LM7> <-- 110 ????????????
    1000010c:   00000000        nop

0000000010000110 <$LM7>:
        return 1;
    10000110:   dfbf0000        0xdfbf0000
    10000114:   24020001        li      $v0,1
    10000118:   03e00008        jr      $ra
    1000011c:   67bd0010        0x67bd0010


When removing the static I get the correct address 100000f8 ?!?

Am I missing something. Please help me, I have spend 3 days
chasing this bug, until I figures out it was related to 
static functions.

btw why isn't everything disassembled?

Thanks
Lars Munch

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2001-07-22 21:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-21  9:27 mips64 linker bug? Lars Munch Christensen
2001-07-21 15:23 ` Ralf Baechle
2001-07-21 16:17   ` Lars Munch Christensen
2001-07-21 19:07     ` Ralf Baechle
2001-07-22  9:39       ` Lars Munch Christensen
2001-07-22 10:35         ` Thiemo Seufer
2001-07-22 11:02           ` Kevin D. Kissell
2001-07-22 11:02             ` Kevin D. Kissell
2001-07-22 11:15             ` Thiemo Seufer
2001-07-22 11:44               ` Kevin D. Kissell
2001-07-22 11:44                 ` Kevin D. Kissell
2001-07-22 21:23         ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox