On 05/02/2014 00:40, Mark Cave-Ayland wrote:
On 01/02/14 20:54, Olivier Danet wrote:
NextSTEP's bootloader for Sparc32 expects that the 32 bytes a.out header is copied just before the start address.
Signed-off-by: Olivier Danet odanet@caramail.com
--- libopenbios/aout_load.c (révision 1257) +++ libopenbios/aout_load.c (copie de travail) @@ -139,6 +139,8 @@ goto out; } }
- seek_io(fd, offset);
- read_io(fd, (char *)(start-0x20), 0x20);
debug("Loaded %lu bytes\n", size); debug("entry point is %#lx\n", start); ===================================================================
Hmmmm I'm not sure that anything below load-base is supposed to be mapped. Is it possible to load the header at start, and then simply add N_TXTOFF(ehdr) to the read_io() destination offsets? Or are the addresses in the a.out binary absolute?
ATB,
Mark.
Here is the beginning of the NextSTEP bootloader :
Dump of assembler code from 0x4000 to 0x4100: => 0x00004000: tst %o0 0x00004004: be 0x404c 0x00004008: nop 0x0000400c: mov %o0, %g7 0x00004010: sethi %hi(0x4000), %o1 0x00004014: mov %o1, %o1 ! 0x4000 0x00004018: sub %o1, 0x1c, %o2 0x0000401c: ld [ %o2 ], %o2 <<<<<<< HERE : $O2=*(0x4000-0x1C) 0x00004020: add %o2, %o1, %o2 0x00004024: sethi %hi(0x5800), %g1 0x00004028: st %g7, [ %g1 + 0x110 ] ! 0x5910 0x0000402c: ld [ %o0 + 4 ], %o4 0x00004030: mov %o1, %l0 0x00004034: add %o1, 0x20, %l1 0x00004038: call 0x4088 0x0000403c: sub %o2, %o1, %l2 0x00004040: tst %o4 0x00004044: be 0x404c 0x00004048: nop 0x0000404c: save %o1, -96, %sp 0x00004050: call 0x432c
Addresses are absolute. This code is directly copied from the ISO's sector 1
It accesses the a.out header very early (which helped _a lot_ to find the bug) to get the a_text field, which is the lenght of the TEXT segment. Sun's OpenBOOT copies the whole header at 0x3FE0, not the .a_text only.
Are there SunOS version using a.out ?
Of course, we could add #ifdef CONFIG_SPARC32 fences.
Regards