Jump to content

Photo

rmac GPU symbols not exported


8 replies to this topic

#1 swapd0 OFFLINE  

swapd0

    Moonsweeper

  • 334 posts

Posted Wed Jan 9, 2019 9:30 AM

I've this code, why _gpu_code_start it's exported but_gpu_sprite it's not exported?

 

How can I export a label that will be located at GPU RAM?


_gpu_code_start::
	.gpu
	.org G_RAM


	movei #gpu_sprite,r0
	...


	.long

_gpu_sprite::	dc.l 0



#2 ggn OFFLINE  

ggn

    Stargunner

  • 1,433 posts
  • Location:Athens, Greece

Posted Thu Jan 10, 2019 1:28 AM

Modified the code a bit to be more self contained and assemble:
 
 
BASE            EQU     $F00000 ; TOM Internal Register Base
G_RAM           EQU     BASE + $3000    ; GPU Internal RAM
 
_gpu_code_start::
.gpu
.org G_RAM
 
 
movei #_gpu_sprite,r0
 
 
.long
 
_gpu_sprite:: dc.l 0
Assembled with rmac 1.13.5 using "rmac -fe -l*swapd0.lst swapd0.s". I assume you want elf .o objects. The listing for this looks like:

    1           =00F00000               BASE            EQU     $F00000 ; TOM Internal Register Base
    2           =00F03000               G_RAM           EQU     BASE + $3000    ; GPU Internal RAM
    3                                   
    4                                   _gpu_code_start::
    5                                   	.gpu
    6                                   	.org G_RAM
    7                                   
    8                                   
    9  00000000  9800xxxxxxxx           	movei #_gpu_sprite,r0
   10                                   
   11                                   
   12  00000006  0000                   	.long
   13                                   
   14  00000008  00000000               _gpu_sprite::	dc.l 0

              BASE 0000000000F00000  a 
             G_RAM 0000000000F03000  a 
   _gpu_code_start 0000000000000000  tg
       _gpu_sprite 0000000000F03008  ag

Looks like the symbols are tagged as global here. Let's look at the .o file itself:

ELF Header

  Class:      ELF32
  Encoding:   Big endian
  ELFVersion: Current
  Type:       Relocatable file
  Machine:    Motorola m68k family
  Version:    Current
  Entry:      0x0
  Flags:      0x0

Section Headers:
[  Nr ] Type              Addr     Size     ES Flg Lk Inf Al Name
[    0] NULL              00000000 00000000 00     00 000 00                   
[    1] PROGBITS          00000000 0000000c 00 AX  00 000 04 .text             
[    2] STRTAB            00000000 00000021 00     00 000 01 .shstrtab         
[    3] SYMTAB            00000000 00000060 10     04 004 04 .symtab           
[    4] STRTAB            00000000 00000028 00     00 000 01 .strtab           
Key to Flags: W (write), A (alloc), X (execute)


Symbol table (.symtab)
[  Nr ] Value    Size     Type    Bind      Sect Name
[    0] 00000000 00000000 NOTYPE  LOCAL        0   
[    1] 00000000 00000000 SECTION LOCAL        1   
[    2] 00f00000 00000000 NOTYPE  LOCAL    65521 BASE 
[    3] 00f03000 00000000 NOTYPE  LOCAL    65521 G_RAM 
[    4] 00000000 00000000 NOTYPE  GLOBAL       1 _gpu_code_start 
[    5] 00f03008 00000000 NOTYPE  GLOBAL       0 _gpu_sprite 

Section Data:
.text
[00000000] 98 00 30 08 00 f0 00 00 00 00 00 00
.shstrtab
[00000000] 00 2e 73 68 73 74 72 74 61 62 00 2e 73 79 6d 74
[00000010] 61 62 00 2e 73 74 72 74 61 62 00 2e 74 65 78 74
[00000020] 00
.symtab
[00000000] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[00000010] 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 01
[00000020] 00 00 00 01 00 f0 00 00 00 00 00 00 00 00 ff f1
[00000030] 00 00 00 06 00 f0 30 00 00 00 00 00 00 00 ff f1
.strtab
[00000000] 00 42 41 53 45 00 47 5f 52 41 4d 00 5f 67 70 75
[00000010] 5f 63 6f 64 65 5f 73 74 61 72 74 00 5f 67 70 75
[00000020] 5f 73 70 72 69 74 65 00


Generated by ELFIO (C++ library for ELF file processing)
http://elfio.sourceforge.net/
Again the symbols look global. So as far as I can see it's not rmac's fault. You'll have to tell us some more info like the version of rmac you used, the command line you used, and whether your compiler/linker requires extra undercores (or no underscores at all). Maybe your symbols need to be defined using a double underscore (for example __gpu_sprite).

Edited by ggn, Thu Jan 10, 2019 1:32 AM.


#3 swapd0 OFFLINE  

swapd0

    Moonsweeper

  • Topic Starter
  • 334 posts

Posted Thu Jan 10, 2019 4:14 AM

I'm using rmac 1.12.4

 

List output, looks ok.

swapd0$ cat test.lst 

                                        test.s               Page 1       11:07:22 am 10-Jan-2019        RMAC 1.12.04 (Linux/OSX)


    1           =00F00000               BASE            EQU     $F00000 ; TOM Internal Register Base
    2           =00F03000               G_RAM           EQU     BASE + $3000    ; GPU Internal RAM
    3                                   
    4                                   _gpu_code_start::
    5                                       .gpu
    6                                       .org G_RAM
    7                                   
    8  00000000  9800xxxxxxxx               movei #_gpu_sprite,r0
    9                                   
   10  00000006  0000                       .long
   11                                   
   12  00000008  00000000               _gpu_sprite:: dc.l 0



                                        test.s               Page 2       11:07:22 am 10-Jan-2019        RMAC 1.12.04 (Linux/OSX)
Symbol Table

              BASE 0000000000F00000  a 
             G_RAM 0000000000F03000  a 
   _gpu_code_start 0000000000000000  tg
       _gpu_sprite 0000000000F03008  ag



nm output, _gpu_sprite it's wrong, it should be $f03008

0$ nm test.o
00f00000 a BASE
00f03000 a G_RAM
00000000 T _gpu_code_start
         U _gpu_sprite

I got a linker error telling me that _gpu_sprite it's not defined, but I've no problem with _gpu_code_start, it's weird.

 



#4 ggn OFFLINE  

ggn

    Stargunner

  • 1,433 posts
  • Location:Athens, Greece

Posted Thu Jan 10, 2019 4:21 AM

nm output, _gpu_sprite it's wrong, it should be $f03008

0$ nm test.o
00f00000 a BASE
00f03000 a G_RAM
00000000 T _gpu_code_start
         U _gpu_sprite

I got a linker error telling me that _gpu_sprite it's not defined, but I've no problem with _gpu_code_start, it's weird.


Here I got

nm swapd0.o
00000000 T _gpu_code_start
         U _gpu_sprite
00f00000 a BASE
00f03000 a G_RAM
So, probably update your rmac?

#5 swapd0 OFFLINE  

swapd0

    Moonsweeper

  • Topic Starter
  • 334 posts

Posted Thu Jan 10, 2019 4:22 AM

With this asm code.

_label1::
_gpu_code_start::
	.gpu
_label2::
	.org G_RAM
_label3::

extern char *label1;
extern char *label2;
extern char *label3;

int main(int argc, const char * argv[])
{
	*label1 = 0;
	*label2 = 0;
	*label3 = 0;
}

I got a linker error with label3. XD



#6 swapd0 OFFLINE  

swapd0

    Moonsweeper

  • Topic Starter
  • 334 posts

Posted Thu Jan 10, 2019 4:25 AM

Here I got
 

nm swapd0.o
00000000 T _gpu_code_start
         U _gpu_sprite
00f00000 a BASE
00f03000 a G_RAM
So, probably update your rmac?

 

Yeah, updating in progress...



#7 swapd0 OFFLINE  

swapd0

    Moonsweeper

  • Topic Starter
  • 334 posts

Posted Fri Jan 11, 2019 4:52 AM

Updated and it doesn't work, the problem it's that the label it's marked as undefined.

 

To share data between GPU & 68000 I had been using a crap solution that it's to use some low memory address to write some data and the GPU reads from there, for example 0x4000 - 4 stores a pointer to the raster table at Classic Kong.

 

I've been looking at the rmac code, and I've fixed the export to elf with absolute addressing, I've tested with Classic Kong and It works, now I'm using a label at GPU address as the raster pointer.

 

Here it's the fix:

file: object.c

function: uint8_t * AddELFSymEntry(uint8_t * buf, SYM * sym, int globflag)

lines: around 233
old code
	if (w1 & TEXT)
		st_shndx = elfHdrNum[ES_TEXT];
	else if (w1 & DATA)
		st_shndx = elfHdrNum[ES_DATA];
	else if (w1 & BSS)
		st_shndx = elfHdrNum[ES_BSS];
	else if (globflag)
		st_shndx = 0;		// Global, not absolute

 
new code
	if (w1 & TEXT)
		st_shndx = elfHdrNum[ES_TEXT];
	else if (w1 & DATA)
		st_shndx = elfHdrNum[ES_DATA];
	else if (w1 & BSS)
		st_shndx = elfHdrNum[ES_BSS];
	else if (globflag)
	{
		// not absolute code or it's an extern reference (DEFINED missing)
		if (!orgactive || (w1 & DEFINED) == 0)
			st_shndx = 0;		// Global, not absolute
	}



#8 Zerosquare OFFLINE  

Zerosquare

    River Patroller

  • 2,752 posts
  • Location:France

Posted Fri Jan 11, 2019 6:30 AM

To share data between GPU & 68000 I had been using a crap solution that it's to use some low memory address to write some data and the GPU reads from there, for example 0x4000 - 4 stores a pointer to the raster table at Classic Kong.

If you're using shared memory for communication, it's better to use GPU memory, since the GPU can access it without needing the main bus.

#9 swapd0 OFFLINE  

swapd0

    Moonsweeper

  • Topic Starter
  • 334 posts

Posted Fri Jan 11, 2019 6:51 AM

Yes, I'm using that now, I was using main ram because I couldn't access labels defined into GPU ram, and I didn't wanted to use a fixed location into GPU ram.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users