![]() |
![]() |
#1 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 44
Posts: 939
|
Can symbols without leading _ be accessed in vbcc?
Hi,
If you are linking against a file with "assembler functions" which are missing the leading _ in the function name, is there any way to access those functions directly in vbcc without a jump/stub function in assembler? You can declare the function to pass the arguments in the correct registers in vbcc, but I don't know how to reference the function symbol when it doesn't start with _. To give a concrete example, I would like to call the assembler variant of debug.lib/KPutStr(A0) directly. The reason for asking this is to save a few bytes in executable size of an utility I am working on, by avoiding having to use the C stub amiga.lib/_KPutStr(), if possible. Hope to hear some suggestions ![]() Last edited by patrik; 28 September 2021 at 13:37. Reason: amiga.lib should be debug.lib |
![]() |
![]() |
#2 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,552
|
Two possibilities:
1. vlink has the capability to add or delete leading underscores of all symbols from an object or a library. When KPutStr from debug.lib is the only symbol you want to transform, you can do this: Code:
vlink ... -set-adduscore -ldebug -clr-adduscore ... Code:
void myKPutStr(__reg("a0")char *)="\txref KPutStr\n\tjsr\tKputStr"; ... myKPutStr("test"); |
![]() |
![]() |
#3 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 44
Posts: 939
|
Opted for 2., works great, thank you very much!
![]() Felt like the more controlled way to just do it for the function(s) you choose, instead of the symbols of the whole linker library. Also, I have to be honest, that I am not sure how to incorporate custom linker commands without changing the build process. Right now I just call vc with all c and asm files in one go so vc calls vlink by itself. |
![]() |
![]() |
#4 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,552
|
Quote:
Quote:
Code:
vlink -bamigahunk -x -Bstatic -Cvbcc -nostdlib -mrel $VBCC/targets/m68k-amigaos/lib/startup.o your_objects.o -L$VBCC/targets/m68k-amigaos/lib -lvc -o program_name |
||
![]() |
![]() |
#5 | |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 44
Posts: 939
|
Quote:
The best thing I can think of now is something like: Code:
void *getKPutStrAddr(void)="\txref KPutStr\n\tlea\tKPutStr(pc),a0\n\tmove.l\ta0,d0\n\trts" |
|
![]() |
![]() |
#6 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,552
|
Quote:
Code:
data xref KPutStr xdef _addr _addr: dc.l KPutStr Quote:
![]() |
||
![]() |
![]() |
#7 |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 44
Posts: 939
|
Sorry for the late thank you, but thank you!
|
![]() |
![]() |
#8 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
it's better to pass the string pointer in a2:
Code:
.text .align 2 .globl _KPutStr _KPutStr: movem.l a6/a2,-(sp) move.l _SysBase,a6 bra.s .L1 .L3: jsr a6@(-0x204:W) .L1: move.b (a2)+,d0 jne .L3 movem.l (sp)+,a2/a6 rts |
![]() |
![]() |
#9 | |
Registered User
Join Date: Jan 2005
Location: Umeå
Age: 44
Posts: 939
|
Quote:
Interesting detail on that topic - apparently debug.lib/KPutStr() depends on exec.library/RawPutChar() preserving a0: Code:
$ hunktool info --brief --disassemble /opt/sdk/NDK3.2R4/lib/debug.lib | grep --before 10 --after 10 "KPutStr" _kputchar: 00000000 202f 0004 move.l ($4,A7), D0 KPutChar: 00000004 2f0e move.l A6, -(A7) 00000006 2c79 0000 0000 movea.l $0.l, A6 ; absref32: _AbsExecBase 0000000c 4eae 0000 jsr ($0,A6) ; dext16: _LVORawPutChar 00000010 2c5f movea.l (A7)+, A6 00000012 4e75 rts _kputstr: 00000014 206f 0004 movea.l ($4,A7), A0 KPutStr: 00000018 1018 move.b (A0)+, D0 0000001a 6704 beq $20 0000001c 61e6 bsr $4 0000001e 60f8 bra $18 00000020 4e75 rts _kgetchar: 00000022 6106 bsr $2a 00000024 4a80 tst.l D0 00000026 6bfa bmi $22 00000028 4e75 rts |
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
vbcc memwatch, debugging, symbols | carrion | Coders. C/C++ | 8 | 17 April 2021 11:43 |
Are drag'n'drop archives into WinUAE accessed via RDH0:? | Foebane | support.WinUAE | 6 | 21 June 2019 13:13 |
Leading Lap MPV | DamienD | support.Games | 1 | 14 January 2016 22:49 |
Leading Lap | mai | HOL data problems | 1 | 09 December 2009 21:16 |
Leading Lap AGA full version | macce2 | request.Old Rare Games | 4 | 03 June 2006 23:50 |
|
|