* 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
* Re: mips64 linker bug?
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
0 siblings, 1 reply; 12+ messages in thread
From: Ralf Baechle @ 2001-07-21 15:23 UTC (permalink / raw)
To: Lars Munch Christensen; +Cc: linux-mips
On Sat, Jul 21, 2001 at 11:27:15AM +0200, Lars Munch Christensen wrote:
> 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.
Gas and ld of the published 64-bit binutils are entirely useless for 64-bit
code. Various people are working on fixing that but that takes time,
especially the non-pic case is a bit hairy.
> btw why isn't everything disassembled?
Executive summary: because binutils is a stupid. Technical answer, objdump
only disassembles MIPS I instructions by default.
Ralf
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
2001-07-21 15:23 ` Ralf Baechle
@ 2001-07-21 16:17 ` Lars Munch Christensen
2001-07-21 19:07 ` Ralf Baechle
0 siblings, 1 reply; 12+ messages in thread
From: Lars Munch Christensen @ 2001-07-21 16:17 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Lars Munch Christensen, linux-mips
On Sat, Jul 21, 2001 at 05:23:09PM +0200, Ralf Baechle wrote:
> On Sat, Jul 21, 2001 at 11:27:15AM +0200, Lars Munch Christensen wrote:
>
> > 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.
>
> Gas and ld of the published 64-bit binutils are entirely useless for 64-bit
> code. Various people are working on fixing that but that takes time,
> especially the non-pic case is a bit hairy.
>
Thanks...What should I do now? Change my code to mips32 or are there some
patches to binutils that I can use, to get it working?
Thanks for your help
Regards
Lars Munch
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
2001-07-21 16:17 ` Lars Munch Christensen
@ 2001-07-21 19:07 ` Ralf Baechle
2001-07-22 9:39 ` Lars Munch Christensen
0 siblings, 1 reply; 12+ messages in thread
From: Ralf Baechle @ 2001-07-21 19:07 UTC (permalink / raw)
To: Lars Munch Christensen; +Cc: linux-mips
On Sat, Jul 21, 2001 at 06:17:33PM +0200, Lars Munch Christensen wrote:
> Thanks...What should I do now? Change my code to mips32 or are there some
> patches to binutils that I can use, to get it working?
Depends on what you want to do?
Ralf
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
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 21:23 ` Ralf Baechle
0 siblings, 2 replies; 12+ messages in thread
From: Lars Munch Christensen @ 2001-07-22 9:39 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Lars Munch Christensen, linux-mips
On Sat, Jul 21, 2001 at 09:07:37PM +0200, Ralf Baechle wrote:
> On Sat, Jul 21, 2001 at 06:17:33PM +0200, Lars Munch Christensen wrote:
>
> > Thanks...What should I do now? Change my code to mips32 or are there some
> > patches to binutils that I can use, to get it working?
>
> Depends on what you want to do?
I'm working on a very small, single address space, microkernel and I have
the MIPS Malta with a 5Kc CPU to develop it on. The 5Kc is compatible
with mips32 but I must admit, I really like to have my kernel
running 64bit :). Is there a working binutils for 64 bit code floating
around somewhere or should I stick with the mips32 stuff?
I tried the binutil from ftp://ftp.ds2.pg.gda.pl/pub/macro/SRPMS/ but
they where unable to compile with target mips64-linux.
Thanks
Lars Munch
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
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 21:23 ` Ralf Baechle
1 sibling, 1 reply; 12+ messages in thread
From: Thiemo Seufer @ 2001-07-22 10:35 UTC (permalink / raw)
To: linux-mips
Lars Munch Christensen wrote:
> On Sat, Jul 21, 2001 at 09:07:37PM +0200, Ralf Baechle wrote:
> > On Sat, Jul 21, 2001 at 06:17:33PM +0200, Lars Munch Christensen wrote:
> >
> > > Thanks...What should I do now? Change my code to mips32 or are there some
> > > patches to binutils that I can use, to get it working?
> >
> > Depends on what you want to do?
>
> I'm working on a very small, single address space, microkernel and I have
> the MIPS Malta with a 5Kc CPU to develop it on. The 5Kc is compatible
> with mips32 but I must admit, I really like to have my kernel
> running 64bit :).
An Kernel with 64bit addresses is less compact and likely to run slower.
OTOH, a 64bit Kernel has certainly some hack value. :-)
> Is there a working binutils for 64 bit code floating
> around somewhere or should I stick with the mips32 stuff?
Using 32bit is surely the easier way to go.
You might try the toolchain I use for my mips64-linux development.
Be warned: It's barely good enough to compile a linux kernel, no
pic code and therefore no libc. You have to compile it yourself,
the source is available at
http://www.csv.ica.uni-stuttgart.de/homes/ths/linux-mips/
Have fun. :-)
Thiemo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
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
0 siblings, 2 replies; 12+ messages in thread
From: Kevin D. Kissell @ 2001-07-22 11:02 UTC (permalink / raw)
To: linux-mips, Thiemo Seufer
> > > > Thanks...What should I do now? Change my code to mips32 or are there
some
> > > > patches to binutils that I can use, to get it working?
> > >
> > > Depends on what you want to do?
> >
> > I'm working on a very small, single address space, microkernel and I
have
> > the MIPS Malta with a 5Kc CPU to develop it on. The 5Kc is compatible
> > with mips32 but I must admit, I really like to have my kernel
> > running 64bit :).
>
> An Kernel with 64bit addresses is less compact and likely to run slower.
> OTOH, a 64bit Kernel has certainly some hack value. :-)
Note that the 5Kc is one of the new generation of MIPS64 parts
that can enable 64-bit integer and floating point instructions without
requiring that 64-bit addressing also be enabled in the kernel.
Making Linux kernel support for this capability available is
one of the things that we're working on. But it's not there yet.
Kevin K.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
2001-07-22 11:02 ` Kevin D. Kissell
@ 2001-07-22 11:02 ` Kevin D. Kissell
2001-07-22 11:15 ` Thiemo Seufer
1 sibling, 0 replies; 12+ messages in thread
From: Kevin D. Kissell @ 2001-07-22 11:02 UTC (permalink / raw)
To: linux-mips, Thiemo Seufer
> > > > Thanks...What should I do now? Change my code to mips32 or are there
some
> > > > patches to binutils that I can use, to get it working?
> > >
> > > Depends on what you want to do?
> >
> > I'm working on a very small, single address space, microkernel and I
have
> > the MIPS Malta with a 5Kc CPU to develop it on. The 5Kc is compatible
> > with mips32 but I must admit, I really like to have my kernel
> > running 64bit :).
>
> An Kernel with 64bit addresses is less compact and likely to run slower.
> OTOH, a 64bit Kernel has certainly some hack value. :-)
Note that the 5Kc is one of the new generation of MIPS64 parts
that can enable 64-bit integer and floating point instructions without
requiring that 64-bit addressing also be enabled in the kernel.
Making Linux kernel support for this capability available is
one of the things that we're working on. But it's not there yet.
Kevin K.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
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
1 sibling, 1 reply; 12+ messages in thread
From: Thiemo Seufer @ 2001-07-22 11:15 UTC (permalink / raw)
To: linux-mips
Kevin D. Kissell wrote:
[snip]
> > An Kernel with 64bit addresses is less compact and likely to run slower.
> > OTOH, a 64bit Kernel has certainly some hack value. :-)
>
> Note that the 5Kc is one of the new generation of MIPS64 parts
> that can enable 64-bit integer and floating point instructions without
> requiring that 64-bit addressing also be enabled in the kernel.
Sorry, but I can't see what's new here. AFAICS this possibility existed
already in MIPS III.
> Making Linux kernel support for this capability available is
> one of the things that we're working on. But it's not there yet.
I know. :-)
Thiemo
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
2001-07-22 11:15 ` Thiemo Seufer
@ 2001-07-22 11:44 ` Kevin D. Kissell
2001-07-22 11:44 ` Kevin D. Kissell
0 siblings, 1 reply; 12+ messages in thread
From: Kevin D. Kissell @ 2001-07-22 11:44 UTC (permalink / raw)
To: linux-mips, Thiemo Seufer
> Kevin D. Kissell wrote:
> [snip]
> > > An Kernel with 64bit addresses is less compact and likely to run
slower.
> > > OTOH, a 64bit Kernel has certainly some hack value. :-)
> >
> > Note that the 5Kc is one of the new generation of MIPS64 parts
> > that can enable 64-bit integer and floating point instructions without
> > requiring that 64-bit addressing also be enabled in the kernel.
>
> Sorry, but I can't see what's new here. AFAICS this possibility existed
> already in MIPS III.
Sorry if I wasn't clear. It is only the newer parts that can enable the
use of the 64-bit instructions *in user mode* without also enabling
64-bit addressng. It's true that MIPS III/IV parts provide access to
those instructions in kernel regardless of the state of the Status.KX
bit, but in user mode they are only available if the Status.UX bit is set,
enabling 64-bit addressing. MIPS64 CPU's have an additional
bit in the Status register (Bit 23, "PX") to enable 64-bit instructions
without enabling 64-bit addressing.
Regards,
Kevin K.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
2001-07-22 11:44 ` Kevin D. Kissell
@ 2001-07-22 11:44 ` Kevin D. Kissell
0 siblings, 0 replies; 12+ messages in thread
From: Kevin D. Kissell @ 2001-07-22 11:44 UTC (permalink / raw)
To: linux-mips, Thiemo Seufer
> Kevin D. Kissell wrote:
> [snip]
> > > An Kernel with 64bit addresses is less compact and likely to run
slower.
> > > OTOH, a 64bit Kernel has certainly some hack value. :-)
> >
> > Note that the 5Kc is one of the new generation of MIPS64 parts
> > that can enable 64-bit integer and floating point instructions without
> > requiring that 64-bit addressing also be enabled in the kernel.
>
> Sorry, but I can't see what's new here. AFAICS this possibility existed
> already in MIPS III.
Sorry if I wasn't clear. It is only the newer parts that can enable the
use of the 64-bit instructions *in user mode* without also enabling
64-bit addressng. It's true that MIPS III/IV parts provide access to
those instructions in kernel regardless of the state of the Status.KX
bit, but in user mode they are only available if the Status.UX bit is set,
enabling 64-bit addressing. MIPS64 CPU's have an additional
bit in the Status register (Bit 23, "PX") to enable 64-bit instructions
without enabling 64-bit addressing.
Regards,
Kevin K.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: mips64 linker bug?
2001-07-22 9:39 ` Lars Munch Christensen
2001-07-22 10:35 ` Thiemo Seufer
@ 2001-07-22 21:23 ` Ralf Baechle
1 sibling, 0 replies; 12+ messages in thread
From: Ralf Baechle @ 2001-07-22 21:23 UTC (permalink / raw)
To: Lars Munch Christensen; +Cc: linux-mips
On Sun, Jul 22, 2001 at 11:39:23AM +0200, Lars Munch Christensen wrote:
> I'm working on a very small, single address space, microkernel and I have
> the MIPS Malta with a 5Kc CPU to develop it on. The 5Kc is compatible
> with mips32 but I must admit, I really like to have my kernel
> running 64bit :). Is there a working binutils for 64 bit code floating
> around somewhere or should I stick with the mips32 stuff?
>
> I tried the binutil from ftp://ftp.ds2.pg.gda.pl/pub/macro/SRPMS/ but
> they where unable to compile with target mips64-linux.
Afaik the mips64-linux binutils are the only one that more (or more less ;)
work for building a 64-bit kernel. What we have to do to get around the
bugs and missing features is building a 64-bit kernel but passing -32 to
the assembler so we never use 64-bit ELF. In the end we convert the
resulting 32-bit ELF executable into 64-ELF using objcopy. That's about
as much as 64-bit binutils are usable for. For details see
arch/mips64/Makefile.
Ralf
^ 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