English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 19 March 2022, 07:28   #1
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Turning HUNK_SYMBOL offsets into pointers

I'd like to create a simple DLL/SO-like dynamic linking system to aid some future ports. There are existing implementations (Quake2 DLLs from Hyperion, FPSE plugins, etc.), but they are inconvenient as you have to manually create a symbol table with every exported symbol. I decided to use the HUNK_SYMBOL in unstripped executables to avoid doing double work. The "DLL" files will be regular executables started from shell, so in case of HUNK_CODE I was able to add the offsets to BADDR(cli_Module)+4 of the CommandLineInterface struct to get the address of functions. Is there a way to do the same for HUNK_DATA and HUNK_BSS the get the addresses of global variables?
BSzili is offline  
Old 19 March 2022, 11:36   #2
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Did you try traversing the hunk list? Each hunk (when loaded through LoadSeg, et.al.) has a size and pointer to next hunk placed just before the actual hunk data.
hooverphonique is offline  
Old 19 March 2022, 12:04   #3
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
I see, so the first longword I skipped was the size of the hunk. I forgot to mention, but the global variables seem to have a lower memory address than BADDR(cli_Module), so going forward in the list wouldn't help in this case.
edit: I missed the part about the pointer, I'll check this out.
BSzili is offline  
Old 19 March 2022, 12:11   #4
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
Quote:
Originally Posted by hooverphonique View Post
Did you try traversing the hunk list? Each hunk (when loaded through LoadSeg, et.al.) has a size and pointer to next hunk placed just before the actual hunk data.
Pedantic correction: bcpl pointer. So, for each hunk:
address-8 = hunk size in bytes
address-4 = bcpl pointer to next hunk (0 if none)
a/b is offline  
Old 19 March 2022, 12:15   #5
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
Thanks for the help! It seems like the first longword stored at BADDR(cli_Module) is indeed a BPTR to the next hunk which is lower than the address of the global variables. Now I just have to figure out which ones comes after which and I'm set.
BSzili is offline  
Old 30 July 2022, 19:00   #6
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
I ended up finishing the dynamic linking library, now it's up on GitHub:
https://github.com/BSzili/libdl-hunk/
BSzili is offline  
Old 31 July 2022, 11:33   #7
bebbo
bye
 
Join Date: Jun 2016
Location: Some / Where
Posts: 680
There are libraries and there is https://aminet.net/dev/gg/a2ixlibrary-2.1.lha

/shrug
bebbo is offline  
Old 31 July 2022, 14:25   #8
BSzili
old chunk of coal
 
BSzili's Avatar
 
Join Date: Nov 2011
Location: Hungary
Posts: 1,289
I saw this, but it's for ixemul.library only. My solution is independent from the C library and only uses exec and dos functions. The program and libraries can be linked different C-libraries as long as they don't pass incompatible stdio handles, or try to free memory allocated by the other.
BSzili is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading base address of custom hw registers and using offsets burma-shave Coders. Asm / Hardware 9 29 May 2021 01:29
Structures offsets kamelito Coders. System 16 24 January 2021 07:26
Library offsets BippyM Coders. General 17 29 April 2020 03:32
turning laptop to an Amiga Arkas New to Emulation or Amiga scene 3 25 December 2017 22:10
Dat File Offsets? Brakus Coders. General 2 29 June 2008 00:51

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 15:01.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.12914 seconds with 15 queries