English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 14 January 2018, 19:20   #601
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 175
Quote:
Originally Posted by Toni Wilen View Post
But if thats true, where those PutMsg() (and other library call) truncated relocation messages come from? It makes no sense, there should be nothing to relocate.
PutMsg is not a library function, as Newlist.
And the other ones are wrappers from kswrapper.c

edith says:

If jumps are not pc relative relocation is necessary. Since the code is >32k pc relative only does not work.

The SAS Linker is able to insert additional jumps, so some jumps are a combination of a pcrel jump and an abs jump.

Last edited by bebbo; 14 January 2018 at 20:58.
bebbo is offline  
AdSense AdSense  
Old 14 January 2018, 19:48   #602
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 46
Posts: 379
Quote:
Originally Posted by bebbo View Post
BTW: I am using now https://github.com/bebbo/amiga-gcc to build the compiler, tools and libraries. Makefile based and way faster.
Can we keep using the old method or the old method is frozen?
alkis is offline  
Old 14 January 2018, 21:40   #603
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 175
pfs3aio at ~64k and still ~4k reloc table.

Code:
m68k-amigaos-gcc -o pfs3aio assroutines.o messages.o \
dostohandlerinterface.o disk.o diskchange.o resethandler.o volume.o \
allocation.o lock.o anodes.o format.o lru.o update.o kswrapper.o boot.o \
directory.o CheckAccess.o init.o -Os -m68000 -noixemul -fbaserel \
-fomit-frame-pointer -nostartfiles -mregparm=4 -DMIN_LIB_VERSION=33 \
-DKSWRAPPER=1 -DSCSIDIRECT=1 -DNSD=1 -DTD64=1 -DTRACKDISK=1 \
-DLARGE_FILE_SIZE=0 -DEXTRAPACKETS=1 -DSIZEFIELD -DDELDIR=1 \
-DMAX_BUFFERS=600 -DMIN_BUFFERS=20 -DMULTIUSER=0 -DPROTECTION=0 \
-DVERSION23=1 -DROLLOVER=1  -s -nostdlib -lnix -lamiga -lgcc -lnix -lnix20 \
-lstubs
bebbo is offline  
Old 14 January 2018, 22:02   #604
pipper
Registered User

 
Join Date: Jul 2017
Location: San Jose
Posts: 34
Quote:
Originally Posted by bebbo View Post
PutMsg is not a library function, as Newlist.
And the other ones are wrappers from kswrapper.c

edith says:

If jumps are not pc relative relocation is necessary. Since the code is >32k pc relative only does not work.

The SAS Linker is able to insert additional jumps, so some jumps are a combination of a pcrel jump and an abs jump.


In theory it should be possibly to have more than 32kb of Code and still use pc-relative jumps. I would think in many cases the code could be rearranged that most jumps are not farther than 32kb, yet the overall code is much larger. This is an optimization problem at the linker stage. (I think this is what Toni alluded to when he asked if he needs to rearrange the object files.) We have vast computation power nowadays to throw at this problem. I do not know about the practicality of this optimization in the gcc tool chain, though. But I’d really like to know if this can be done.
pipper is offline  
Old 14 January 2018, 23:19   #605
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 175
Quote:
Originally Posted by pipper View Post
In theory it should be possibly to have more than 32kb of Code and still use pc-relative jumps. I would think in many cases the code could be rearranged that most jumps are not farther than 32kb, yet the overall code is much larger. This is an optimization problem at the linker stage. (I think this is what Toni alluded to when he asked if he needs to rearrange the object files.) We have vast computation power nowadays to throw at this problem. I do not know about the practicality of this optimization in the gcc tool chain, though. But I’d really like to know if this can be done.
Slink inserts jump tables:
Code:
     814:       4ef9 0000 e676  jmp e676 <@W_RemDosEntry>
     81a:       4ef9 0000 d838  jmp d838 <@UpdateDisk>
     820:       4ef9 0000 a442  jmp a442 <@_NormalErrorMsg>
     826:       4ef9 0000 e840  jmp e840 <@FixStartupPacket>
     82c:       4ef9 0000 9c4e  jmp 9c4e <@DiskRemoveSequence>
     832:       4ef9 0000 9b44  jmp 9b44 <@NewVolume>
     838:       4ef9 0000 981a  jmp 981a <@UninstallDiskChangeHandler>
     83e:       4ef9 0000 de80  jmp de80 <@CheckUpdate>
     844:       4ef9 0000 9042  jmp 9042 <@MotorOff>
     84a:       4ef9 0000 98f0  jmp 98f0 <@UninstallResetHandler>
     850:       4ef9 0000 e3d0  jmp e3d0 <@W_FreeVec>
     856:       4ef9 0000 e4a6  jmp e4a6 <@W_DeleteMsgPort>
     85c:       4ef9 0000 90ac  jmp 90ac <@Initialize>
     862:       4ef9 0000 e432  jmp e432 <@W_DeleteIORequest>
     868:       4ef9 0000 d498  jmp d498 <@DeallocLRU>
     86e:       4ef9 0000 e8f4  jmp e8f4 <@W_LibDeletePool>
     874:       4ef9 0000 9874  jmp 9874 <@HandshakeResetHandler>
The algorithm to add jump tables is simple and straighforward.

Rearranging will rarely find a solution, if it's allowed at all since the object order is defined by the caller.
bebbo is offline  
Old Yesterday, 00:38   #606
pipper
Registered User

 
Join Date: Jul 2017
Location: San Jose
Posts: 34
That’s what I meant by “I do not know about the practicalities in the gcc tool chain”
My thinking is this: the whole program is a set of clumps of code calling each other. The task is to arrange those clumps in such a way so that the number of call distances > 32kb is minimal. Maybe this can be expressed as a graph (code being the vertices and calls being the edges) and the optimization is some form of maximum flow graph algorithm.

Can you elaborate on “if it’s allowed at all since the object order is defined by the caller”?
pipper is offline  
Old Yesterday, 03:49   #607
gregthecanuck
Registered User
 
Join Date: Mar 2017
Location: Vancouver, BC, Canada
Posts: 4
@bebbo -

Thanks for donation link. I just donated via PayPal. Thanks for all your work on gcc and the toolchain in general.
gregthecanuck is offline  
Old Yesterday, 09:43   #608
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 175
Quote:
Originally Posted by gregthecanuck View Post
@bebbo -

Thanks for donation link. I just donated via PayPal. Thanks for all your work on gcc and the toolchain in general.
Thank you for your real world support !

And also thanks to all testers providing test cases and feedback.
bebbo is offline  
Old Yesterday, 18:28   #609
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 42
Posts: 20,153
There is still something wrong. For example AllocMem() (jsr -$c6(a6)) is not inlined and mixes register and stack parameters:

Code:
	SysBase =  *((struct ExecBase **)4);

	/* init globaldata */
	g = AllocMem(sizeof(struct globaldata), MEMF_CLEAR);
	if (!g)
	{
		Alert (AG_NoMemory);
		Wait (0);
	}
	g->g_SysBase = SysBase;
Becomes:

082B3754 48e7 3f36 MOVEM.L D2-D7/A2-A3/A5-A6,-(A7)
082B3758 49f9 082c 9cbe LEA.L $082c9cbe,A4
082B375E 2678 0004 MOVEA.L $0004 [08000810],A3
; use register parameters (D0 and D1)
082B3762 7201 MOVE.L #$01,D1
082B3764 4841 SWAP.W D1
082B3766 203c 0000 09d0 MOVE.L #$000009d0,D0
082B376C 4eb9 082c 1804 JSR $082c1804
082B3772 2a40 MOVEA.L D0,A5

; takes parameters from stack
082C1804 2f0e MOVE.L A6,-(A7) [145e0064]
082C1806 2c6c 884a MOVEA.L (A4, -$77b6) == $00f79e42,A6
082C180A 202f 0008 MOVE.L (A7, $0008) == $08002290 [08009460],D0
082C180E 222f 000c MOVE.L (A7, $000c) == $08002294 [08025086],D1
082C1812 4eae ff3a JSR (A6, -$00c6) == $0800074a
082C1816 2c5f MOVEA.L (A7)+ [00000016],A6
082C1818 4e75 RTS

Code:
m68k-amigaos-gcc -o pfs3aio boot.o assroutines.o messages.o directory.o dostohandlerinterface.o disk.o init.o diskchange.o resethandler.o volume.o allocation.o lock.o anodes.o format.o lru.o update.o CheckAccess.o kswrapper.o -Os -m68000 -noixemul -fbaserel -fomit-frame-pointer -nostartfiles -mregparm=4 -s -DMIN_LIB_VERSION=33 -DKSWRAPPER=1 -DSCSIDIRECT=1 -DNSD=1 -DTD64=1 -DTRACKDISK=1 -DLARGE_FILE_SIZE=0 -DEXTRAPACKETS=1 -DSIZEFIELD -DDELDIR=1 -DMAX_BUFFERS=600 -DMIN_BUFFERS=20 -DMULTIUSER=0 -DPROTECTION=0 -DVERSION23=1 -DROLLOVER=1 -nostdlib -lnix -lamiga -lgcc -lnix -lnix20 -lstubs -s
Toni Wilen is offline  
Old Yesterday, 19:59   #610
bebbo
Registered User

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 175
Quote:
Originally Posted by Toni Wilen View Post
There is still something wrong. For example AllocMem() (jsr -$c6(a6)) is not inlined and mixes register and stack parameters:

Code:
    SysBase =  *((struct ExecBase **)4);

    /* init globaldata */
    g = AllocMem(sizeof(struct globaldata), MEMF_CLEAR);
    if (!g)
    {
        Alert (AG_NoMemory);
        Wait (0);
    }
    g->g_SysBase = SysBase;
Becomes:

082B3754 48e7 3f36 MOVEM.L D2-D7/A2-A3/A5-A6,-(A7)
082B3758 49f9 082c 9cbe LEA.L $082c9cbe,A4
082B375E 2678 0004 MOVEA.L $0004 [08000810],A3
; use register parameters (D0 and D1)
082B3762 7201 MOVE.L #$01,D1
082B3764 4841 SWAP.W D1
082B3766 203c 0000 09d0 MOVE.L #$000009d0,D0
082B376C 4eb9 082c 1804 JSR $082c1804
082B3772 2a40 MOVEA.L D0,A5

; takes parameters from stack
082C1804 2f0e MOVE.L A6,-(A7) [145e0064]
082C1806 2c6c 884a MOVEA.L (A4, -$77b6) == $00f79e42,A6
082C180A 202f 0008 MOVE.L (A7, $0008) == $08002290 [08009460],D0
082C180E 222f 000c MOVE.L (A7, $000c) == $08002294 [08025086],D1
082C1812 4eae ff3a JSR (A6, -$00c6) == $0800074a
082C1816 2c5f MOVEA.L (A7)+ [00000016],A6
082C1818 4e75 RTS

Code:
m68k-amigaos-gcc -o pfs3aio boot.o assroutines.o messages.o directory.o dostohandlerinterface.o disk.o init.o diskchange.o resethandler.o volume.o allocation.o lock.o anodes.o format.o lru.o update.o CheckAccess.o kswrapper.o -Os -m68000 -noixemul -fbaserel -fomit-frame-pointer -nostartfiles -mregparm=4 -s -DMIN_LIB_VERSION=33 -DKSWRAPPER=1 -DSCSIDIRECT=1 -DNSD=1 -DTD64=1 -DTRACKDISK=1 -DLARGE_FILE_SIZE=0 -DEXTRAPACKETS=1 -DSIZEFIELD -DDELDIR=1 -DMAX_BUFFERS=600 -DMIN_BUFFERS=20 -DMULTIUSER=0 -DPROTECTION=0 -DVERSION23=1 -DROLLOVER=1 -nostdlib -lnix -lamiga -lgcc -lnix -lnix20 -lstubs -s
Some guesses:

1. you are refering to boot.c:EntryPoint:
Code:
        movem.l #16182,-(sp)
        lea ___a4_init,a4
        move.l 4.w,d2
        move.l d2,a6
        move.l #2512,d0
        moveq #1,d1
        swap d1
        jsr a6@(-0xc6:W)
        ...
2. your header files are bogus.

Somehow your configuration does not pickup the inline macros for the calls.

No macros? => amiga lib function calls.
bebbo is offline  
Old Yesterday, 20:03   #611
pipper
Registered User

 
Join Date: Jul 2017
Location: San Jose
Posts: 34
Try adding -v to your CFLAGS to get more output (among this you’ll see the include paths searched)
pipper is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
New GCC based dev toolchain for AmigaOS 3.x cla Coders. Releases 8 24 December 2017 11:18
Issue with photon/xxxx WinUAE Toolchain arpz Coders. Asm / Hardware 2 26 September 2015 23:33
New 68k gcc toolchain arti Coders. C/C++ 17 31 July 2015 04:59
Hannibal's WinUAE Demo Toolchain 5 Bobic Amiga scene 1 23 July 2015 22:04
From gcc to vbcc. Cowcat Coders. General 9 06 June 2014 15:45

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:31.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Page generated in 0.16801 seconds with 14 queries