Skip to contentSkip to conversation

Compiling for MIPS - Problem with "mips-linux-ld" address exeption in run time

DISCUSSION Bemipefe 1 participant 1 message Oct 22, 2007 MIPS

lore
Share & tools
lore

Bemipefe

author
#0 lore raw

Hi to all mips programmers!
First i want sorry for my bad english ... i'm working for upgrade :-D

So i want to submit any question:

I'm compiling with mips compiler gcc (mips-linux-gcc from tools mips-2007 iso image ) and all GNU tools and i have any problems.

I succeed to compile the program demo "hello_mips.c" from gxemul sample in this way:

____________________________________________________________________
____________________________________________________________________

$mips-linux-gcc -I../../src/include/testmachine -g -DMIPS hello.c -mips1 -mabi=32 -c -o hello_mips32.o

$mips-linux-ld -T /home/bemipefe/Programs/mipstools/usr/lib/ldscripts/elf32btsmip.x -e f hello_mips32.o -o hello_mips32

____________________________________________________________________
____________________________________________________________________

As you see i must specify the script for linking because option "-Ttext 0x80030000" supplied from gxemul README don't work.

So i have modified the script changing "0x1000000" in "0x10000000" in that is:

PROVIDE (__executable_start = 0x10000000); . = 0x10000000 + SIZEOF_HEADERS;

I have also added "SIZEOF_HEADERS" that (at first "0") . Now the linker don't claim any message but if i test the binary, occur a exeption in run time:
____________________________________________________________________
____________________________________________________________________

[bemipefe@M-Parallelmind hello]$ ../../gxemul -V -E testmips -C R3000 ./hello_mips32
GXemul 0.4.4 Copyright (C) 2003-2007 Anders Gavare
Read the source code and/or documentation for other Copyright messages.

Simple setup...

    net: simulating 10.0.0.0/8 (max outgoing: TCP=100, UDP=100)
        simulated gateway: 10.0.0.254 (60:50:40:30:20:10)
            using nameserver 192.168.1.1
    machine "default":
        memory: 32 MB
        cpu0: R3000 (I+D = 4+4 KB)
        machine: MIPS test machine
        loading ./hello_mips32
        starting cpu0 at 0x100001ac

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

GXemul> step
[ exception TLBL <tlb> vaddr=0x100001ac pc=0x100001ac ]
80000000: 00000000 nop

____________________________________________________________________
____________________________________________________________________

If I change "0x10000000" in "0x80000000" and also the section:

____________________________________________________________________
____________________________________________________________________

/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = 0x80000000;

____________________________________________________________________
____________________________________________________________________

In the same way from "0x10000000" to "0x80000000". Now i do run the program with gxemul and i still down in trap of "exeption" in TLBL:

____________________________________________________________________
____________________________________________________________________

[bemipefe@M-Parallelmind hello]$ ../../gxemul -V -E testmips -C R3000 ./hello_mips32
GXemul 0.4.4 Copyright (C) 2003-2007 Anders Gavare
Read the source code and/or documentation for other Copyright messages.

Simple setup...

    net: simulating 10.0.0.0/8 (max outgoing: TCP=100, UDP=100)
        simulated gateway: 10.0.0.254 (60:50:40:30:20:10)
            using nameserver 192.168.1.1
    machine "default":
        memory: 32 MB
        cpu0: R3000 (I+D = 4+4 KB)
        machine: MIPS test machine
        loading ./hello_mips32
        starting cpu0 at 0x800001ac

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

GXemul> step
800001ac: 3c1c0000 lui gp,0x0
GXemul> step
800001b0: 279c7e44 addiu gp,gp,32324
GXemul> step
800001b4: 0399e021 addu gp,gp,t9
GXemul> step
800001b8: 27bdffe0 addiu sp,sp,-32
GXemul> step
800001bc: afbf001c sw ra,28(sp) [0xa0007efc]
GXemul> step
800001c0: afbe0018 sw fp,24(sp) [0xa0007ef8]
GXemul> step
800001c4: 03a0f021 move fp,sp
GXemul> step
800001c8: afbc0010 sw gp,16(sp) [0xa0007ef0]
GXemul> step
800001cc: 8f828018 lw v0,-32744(gp) [0xfffffe5c]
[ exception TLBL <tlb> vaddr=0xfffffe5c pc=0x800001cc ]

____________________________________________________________________
____________________________________________________________________

But in this time i see any executed istruction.

The ask is: How can fix it ? The problem is in the linker ? How can find documentation from ELF format ?

Thank you and Good Work!