Subject: Cross-compile kernel for arm32 1.5 kernel?
To: None <port-arm32@netbsd.org>
From: Alstrup, Kurt <kurt.alstrup@intel.com>
List: port-arm32
Date: 02/02/2001 13:41:35
  I would like to compile the 1.5 NetBSD kernel for arm32 architecture (a
Chalice Cats system) on a standard
PC (running NetBSD 1.5). I install the cross compiler packages and except
from a .depend that wasn't removed
by a make clean then the cross compile runs nicely using a wrapper to setup
machine dependent stuff for make.
However, the kernel crashes very quickly (immediately) when launched on the
Cats system, so something isn't right.

 I have not been able to find out exactly what kills the build, but I have a
couple af candidates ..

 - It seems that the entry point to the kernel moved 0x20 bytes when built
on the PC. Builds on the Arm machine
  (kernel 1.4.2 I might need to add) is linked to 0xf0000000, but for some
reason unknown to me (interrupt vectors ?)
  the entry point is shifted to 0xf0000020. That shift does not happen on
the PC build.

 - Even when given the -Bstatic directive the 1.5 linker puts a __DYNAMIC
symbol into the output format and the
   relocation table seems different. The object code seems to be identical,
but as the disassembly differ then would
   that difference affect the Cats bootloader? 

 Has anyone done this before and if so how is it done, (or what did I miss)
?

Kurt Alstrup

Below is the disassembly of a function linked on the two systems. It shows
both issues neatly.

--------

   Linked on PC running 1.5; objdump'ed on Cats running 1.4.2:

PC$ arm-netbsd-ld -e _main2 -Ttext f0000000 -x -o xx2  xx.o
[moving file to cats system]
Cats$ objdump --disassemble  xx2

xx2:     file format a.out-arm-netbsd

Disassembly of section .text:

effff020 <_main2-0xfe0>:
effff020:       e1a0c00d        mov     ip, sp
effff024:       e92dd800        stmdb   sp!, {fp, ip, lr, pc}
effff028:       e24cb004        sub     fp, ip, #4
effff02c:       e24dd008        sub     sp, sp, #8
effff030:       e59f301c        ldr     r3, effff054 <__DYNAMIC+0xeffff054>
effff034:       e50b3014        str     r3, [fp, -#20]
effff038:       e51b3014        ldr     r3, [fp, -#20]
effff03c:       e51b2014        ldr     r2, [fp, -#20]
effff040:       e0030392        mul     r3, r2, r3
effff044:       e50b3010        str     r3, [fp, -#16]
effff048:       e51b3010        ldr     r3, [fp, -#16]
effff04c:       e1a00003        mov     r0, r3
effff050:       ea000000        b       effff058 <__DYNAMIC+0xeffff058>
effff054:       f0000000        andnv   r0, r0, r0
effff058:       e91ba800        ldmdb   fp, {fp, sp, pc}
        ...

f0000000 <_main2>:
        ...

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

  Linked and objdump'ed on Cats running 1.4.2:

Cats$ ld -e _main2 -Ttext f0000000 -x -o xx xx.o
Cats$ objdump --disassemble  xx  

xx:     file format a.out-arm-netbsd

Disassembly of section .text:

f0000020 <_main2>:
f0000020:       e1a0c00d        mov     ip, sp
f0000024:       e92dd800        stmdb   sp!, {fp, ip, lr, pc}
f0000028:       e24cb004        sub     fp, ip, #4
f000002c:       e24dd008        sub     sp, sp, #8
f0000030:       e59f301c        ldr     r3, f0000054 <_main2+0x34>
f0000034:       e50b3014        str     r3, [fp, -#20]
f0000038:       e51b3014        ldr     r3, [fp, -#20]
f000003c:       e51b2014        ldr     r2, [fp, -#20]
f0000040:       e0030392        mul     r3, r2, r3
f0000044:       e50b3010        str     r3, [fp, -#16]
f0000048:       e51b3010        ldr     r3, [fp, -#16]
f000004c:       e1a00003        mov     r0, r3
f0000050:       ea000000        b       f0000058 <_main2+0x38>
f0000054:       f0000020        andnv   r0, r0, r0, lsr #32
f0000058:       e91ba800        ldmdb   fp, {fp, sp, pc}
f000005c:       00000000        andeq   r0, r0, r0

f0000060 <_etext>:
        ...