English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 25 May 2022, 22:59   #41
Hedeon
Semi-Retired
 
Join Date: Mar 2012
Location: Leiden / The Netherlands
Posts: 1,993
Quote:
Originally Posted by phx View Post
I remember there is a PPC project (by Hedeon?), which has a special memory region indicated by a new MEM-flag. So it may be useful, as long as you have the right tool to create such object files.
I used it to flag the PPC hunks with MEM attributes $2005 which is used by Elbox to define memory located in PCI space (in their case VGA memory, in my case the memory on a PPC PCI card). So bit 31 and 30 were set of the hunk length in the hunk header followed by a ULONG with the value $2005. IIRC.

As the PPC on the PCI bus can only access memory located in PCI space I wanted to make sure that those hunks were loaded into memory residing in PCI space.

This of course only worked for stuff compiled with the extra stuff in the hunk header (thanks phx for this in vlink. I am talking about 2016 now I think). Original WarpOS stuff needed a patch of the hunk header.

Later I just patched LoadSeg() and used InternalLoadSeg() and some other stuff to recognize PPC programs and load them into PPC memory directly.

Last edited by Hedeon; 25 May 2022 at 23:08.
Hedeon is offline  
Old 26 May 2022, 17:17   #42
Olaf Barthel
Registered User
 
Join Date: Aug 2010
Location: Germany
Posts: 532
Quote:
Originally Posted by paraj View Post
In the header, yes, but not subsequent hunks according to my testing (2.0/3.0/3.1). Do you have an example of an executable where this works? This is just for my curiosity as I can't see any use of this feature
The binary file loader only ever allocates the segments once when the header is processed. This is when it needs to know how much memory to allocate per segment and the associated allocation flags passed to the AllocMem function (or whatever the equivalent callback function for InternalLoadSeg does). Note that the memory allocation function must return a pointer to memory whose contents can be modified. Returning a ROM address is not an option. Do not second-guess what the loader might try.

When this segment list setup has been taken care of, the HUNK_CODE/HUNK_DATA/HUNK_BSS type hunks will be processed in the order in which they are found in the file. For each such hunk type the loader expects the hunk size to be either smaller than what was allocated or exactly the same.

The size of the hunk is really just the number of 32 bit words, no flags are expected or even supported. It is too late to change anything now anyway. The loader will not free and reallocate any part of the segment list.

If the size of the hunk is smaller than what was asked for at allocation time, then the memory which was not initialized yet will be filled with 0.

This is where things can go really wrong if the load file indicates that the size of the HUNK_CODE/HUNK_DATA/HUNK_BSS type hunk is larger than what was allocated. The loader does not expect this and may end up trashing memory.
Olaf Barthel is offline  
Old 27 May 2022, 02:02   #43
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by paraj View Post
In the header, yes, but not subsequent hunks according to my testing (2.0/3.0/3.1).
Quote:
Originally Posted by Olaf Barthel View Post
The size of the hunk is really just the number of 32 bit words, no flags are expected or even supported. It is too late to change anything now anyway.
Maybe it's just me, but I think you both agree in confirming the same fact: There are no memory flags in the size-longword, following the HUNK_CODE/DATA/BSS id in executable files.

Only with object files the memory flags are passed in this location. Simply because object files have no other place to pass them.

Some linkers in the past may have been too lazy to remove the flags there, when writing an executable. Which is usually not a problem (at least with either the CHIP or the FAST flag only), because the upper two bits disappear when multiplying by four, to determine the size in bytes.

More interesting (to me) is how the extended memory attributes word is passed in object files, when both bits are set, as I never found anything about it. I assumed that the extra word is passed directly behind the size-word in object files, i.e.:
Code:
dc.l HUNK_CODE,HUNKF_CHIP|HUNKF_FAST|size,memattr
phx 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
Amiga Exe Hunks heavy Coders. General 4 16 August 2007 00:20
AmigaDOS hunks documentation & HUNK_OVERLAY AmiGer Coders. General 2 06 February 2004 08:00

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 05:50.

Top

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