Add rErrno variable to relocator

0 is used as error condition, so add a way to pass some more
detailed error information to the caller.
This commit is contained in:
Stefan Reinauer 2022-09-19 23:06:36 +08:00
parent ce96f096fe
commit e221cea549
2 changed files with 13 additions and 4 deletions

14
reloc.S
View File

@ -67,9 +67,10 @@ HunkLoop
; We don't know this hunk
RelocateFail
; Save hunk number in rErrno as error code
lea _rErrno(pc),a0
move.l d0,(a0)
bsr RelocateCleanup
; Save hunk number in d1 as error code
move.l d0,d1
moveq.l #0,d0 ; NULL = Failure
rts
@ -145,7 +146,11 @@ SkipSymbol
HunkEnd
addq.l #4,a5
dbra d6,HunkLoop
moveq.l #$0,d0
lea _rErrno(pc),a0
moveq.l #0,d0
move.l d0,(a0)
bsr.s CreateSegList
move.l _pHunks(pc),a0
move.l (a0),d2
@ -264,4 +269,7 @@ ReadHandle
_pHunks
dc.l 0
public _rErrno
_rErrno
dc.l 0
CODE

View File

@ -9,6 +9,7 @@
#include <clib/exec_protos.h>
uint32_t relocate(ULONG offset asm("d0"), uint8_t *program asm("a0"));
extern uint32_t rErrno;
extern uint8_t device[];
static void hexdump(unsigned char *data, size_t size)
@ -51,7 +52,7 @@ int main(int argc, char *argv[])
printf("Calling relocate()\n");
ret=relocate(0, device);
printf("... relocate returned %x\n", ret);
printf("... relocate returned %x (rErrno=0x%x)\n", ret, rErrno);
seg=(uint32_t *)ret;