Hi guys. So I've been experimenting with creating a CFE binary to run things from the CFE firmware. As it turns out, externally it identifies as CFE, but internally CFE uses OpenFirmware.
To run on CFE you just create a standard OS binary but it must be loaded to $200000 and start within this area. So I found some example code from the openbios project. I adapted the ofclient example so it compiled on OS4.
I made up a makefile that I had working at some stage but somewhere along the line it broke. Now when I load the binary it has a start and entry address of zero! This isn't right and even the binary looks to be set correctly. It doesn't crash but it does hang CFE. My current makefile as follows.
PROGRAM := ofclient OBJECTS := of1275.o of1275_io.o ofclient.o CC := gcc CFLAGS := -mpowerpc -fpic -fno-builtin-strlen -fno-builtin-exit -Os LDFLAGS := -melf32ppc -N -e _start -g -Ttext 0x200000 $(PROGRAM): $(OBJECTS) $(LD) $(LDFLAGS) -Map $(PROGRAM).map -o $(PROGRAM) $(OBJECTS)
Output of relevant info from objdump.
ofclient: file format elf32-amigaos ofclient architecture: powerpc:common, flags 0x00000012: EXEC_P, HAS_SYMS start address 0x00200c30 Program Header: LOAD off 0x00000054 vaddr 0x00200000 paddr 0x00200000 align 2**2 filesz 0x000010a8 memsz 0x0000130c flags rwx Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000e9c 00200000 00200000 00000054 2**2 CONTENTS, ALLOC, LOAD, CODE 1 .rodata 00000160 00200e9c 00200e9c 00000ef0 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 2 .data 00000002 00200ffc 00200ffc 00001050 2**1 CONTENTS, ALLOC, LOAD, DATA 3 .got 000000a8 00201000 00201000 00001054 2**2 CONTENTS, ALLOC, LOAD, CODE 4 .bss 00000264 002010a8 002010a8 000010fc 2**2 ALLOC 5 .comment 00000081 00000000 00000000 000010fc 2**0 CONTENTS, READONLY SYMBOL TABLE: 00200000 l d .text 00000000 .text 00200e9c l d .rodata 00000000 .rodata 00200ffc l d .data 00000000 .data 00201000 l d .got 00000000 .got 002010a8 l d .bss 00000000 .bss 00000000 l d .comment 00000000 .comment 00000000 l df *ABS* 00000000 of1275.c 00000000 l df *ABS* 00000000 of1275_io.c 00000000 l df *ABS* 00000000 ofclient.c 0020109c l O .got 00000000 .hidden _GLOBAL_OFFSET_TABLE_ 00200c30 g F .text 00000054 _start 0020130c g *ABS* 00000000 __end 00200e00 g F .text 0000009c main 002010a8 g *ABS* 00000000 _edata 0020130c g *ABS* 00000000 _end
Comparison with amigaboot.of that works.
architecture: powerpc:common, flags 0x00000012: EXEC_P, HAS_SYMS start address 0x00200000 Program Header: LOAD off 0x00000054 vaddr 0x00200000 paddr 0x00200000 align 2**2 filesz 0x0000f060 memsz 0x0000f060 flags rwx Sections: Idx Name Size VMA LMA File off Algn 0 .text 0000c0ec 00200000 00200000 00000054 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .rodata 00001048 0020d000 0020d000 0000d054 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 2 .data 00000058 0020f000 0020f000 0000f054 2**2 CONTENTS, ALLOC, LOAD, DATA 3 .got2 00000008 0020f058 0020f058 0000f0ac 2**0 CONTENTS, ALLOC, LOAD, DATA SYMBOL TABLE: 00200000 l d .text 00000000 .text 0020d000 l d .rodata 00000000 .rodata 0020f000 l d .data 00000000 .data 0020f058 l d .got2 00000000 .got2 002039d8 g F .text 0000015c _start
As you can see there isn't much difference. What would cause it to think the start and load address is zero? And despite having this working what do I need to get it to load at $200000 like I said? I suspect I need a linker script but I didn't need one before. It's kind of annoying when a simle thing like an absolute startign address is complicated to specify. I've read GCC doesn't like to even put the _start routine right at the start and objects must appear in certain order with certain options.