Quote:
Originally Posted by bebbo
IMHO the amiga.lib misses some relocations:
... e.g. _CreatePort (in CreatePort.c-00001382.o) calls _NewList (NewList.asm-00001381.o) with a `bsr`
Code:
5c: 486b 0014 pea 20(a3)
60: 6100 0000 bsr.w 62 62 _NewList+0x62
64: 584f addq.w #4,sp
But there is no relocation for that. Right?
|
The NewList() is part of amiga.lib, has been since the exec.library API was frozen. Apparently, the exec list node macros in "exec/lists.i" were not adapted for use as 'C' macros and just NewList() made the cut, winding up as an amiga.lib function.
I reckon the problem here is that amiga.lib making a PC-relative call to NewList() is unsuitable for the program in question because of it size, or linker implementation constraints.
The original "vintage" amiga.lib was always built using the Green Hills 'C' compiler, which always used 32 bit adressing when referencing external code or data. Here's how the 1992 vintage CreatePort.c looks like:
Code:
Amiga Object File Loader V1.00
68000 Instruction Set
EXTERNAL DEFINITIONS
_DeletePort 0088-00 _CreatePort 0000-00
SECTION 00 "" 000000CC BYTES
| 0000 48E7 3C20 MOVEM.L D2-D5/A2,-(A7)
| 0004 262F 0018 MOVE.L 0018(A7),D3
| 0008 142F 001F MOVE.B 001F(A7),D2
| 000C 7AFF MOVEQ #FF,D5
| 000E 2F05 MOVE.L D5,-(A7)
| 0010 4EB9 0000 0000-XX JSR _AllocSignal
| 0016 2800 MOVE.L D0,D4
| 0018 588F ADDQ.L #4,A7
| 001A 6F64 BLE.B 0080
| 001C 2F3C 0001 0001 MOVE.L #00010001,-(A7)
| 0022 4878 0022 PEA 0022
| 0026 4EB9 0000 0000-XX JSR _AllocMem
| 002C 2440 MOVEA.L D0,A2
| 002E 2A0A MOVE.L A2,D5
| 0030 508F ADDQ.L #8,A7
| 0032 6742 BEQ.B 0076
| 0034 2543 000A MOVE.L D3,000A(A2)
| 0038 1542 0009 MOVE.B D2,0009(A2)
| 003C 157C 0004 0008 MOVE.B #04,0008(A2)
| 0042 422A 000E CLR.B 000E(A2)
| 0046 1544 000F MOVE.B D4,000F(A2)
| 004A 42A7 CLR.L -(A7)
| 004C 4EB9 0000 0000-XX JSR _FindTask
| 0052 2540 0010 MOVE.L D0,0010(A2)
| 0056 4A83 TST.L D3
| 0058 588F ADDQ.L #4,A7
| 005A 670A BEQ.B 0066
| 005C 2F0A MOVE.L A2,-(A7)
| 005E 4EB9 0000 0000-XX JSR _AddPort
| 0064 600A BRA.B 0070
| 0066 486A 0014 PEA 0014(A2)
| 006A 4EB9 0000 0000-XX JSR _NewList
| 0070 588F ADDQ.L #4,A7
| 0072 200A MOVE.L A2,D0
| 0074 600C BRA.B 0082
| 0076 2F04 MOVE.L D4,-(A7)
| 0078 4EB9 0000 0000-XX JSR _FreeSignal
| 007E 588F ADDQ.L #4,A7
| 0080 7000 MOVEQ #00,D0
| 0082 4CDF 043C MOVEM.L (A7)+,D2-D5/A2
| 0086 4E75 RTS
| 0088 2F0A MOVE.L A2,-(A7)
| 008A 246F 0008 MOVEA.L 0008(A7),A2
| 008E 4AAA 000A TST.L 000A(A2)
| 0092 670A BEQ.B 009E
| 0094 2F0A MOVE.L A2,-(A7)
| 0096 4EB9 0000 0000-XX JSR _RemPort
| 009C 588F ADDQ.L #4,A7
| 009E 157C 00FF 0008 MOVE.B #FF,0008(A2)
| 00A4 70FF MOVEQ #FF,D0
| 00A6 2540 0014 MOVE.L D0,0014(A2)
| 00AA 7000 MOVEQ #00,D0
| 00AC 102A 000F MOVE.B 000F(A2),D0
| 00B0 2F00 MOVE.L D0,-(A7)
| 00B2 4EB9 0000 0000-XX JSR _FreeSignal
| 00B8 4878 0022 PEA 0022
| 00BC 2F0A MOVE.L A2,-(A7)
| 00BE 4EB9 0000 0000-XX JSR _FreeMem
| 00C4 4FEF 000C LEA 000C(A7),A7
| 00C8 245F MOVEA.L (A7)+,A2
| 00CA 4E75 RTS
SECTION 01 " " 00000000 BYTES
In the mean time I have modified the build options for amiga.lib to emulate the Green Hills 'C' compiler behaviour: 32 bit references for code and data only.
I do wonder why amiga.lib is still being used, though. libnix, clib2, etc. should have their own versions of these functions. Nobody should need to link against amiga.lib. The majority of the code found in amiga.lib are stubs for calling Amiga library and device functions via stack-based parameter passing. If you really do not need these, you ought to link against small.lib, which is shorter because it omits the stubs.