[comp.sys.amiga.tech] Hunks & Segments & ...

a186@mindlink.UUCP (Harvey Taylor) (05/07/89)

  I have written a file disassembler, that looks at the various
  hunks & disassembles or dumps them accordingly...which has raised
  a few questions in my mind...
  Lots of the commands use the global vector.
  1) Is this structure defined anywhere? I do _not_ intend to use this info
     for writing code, just to analyze my disassemblies.
  2) Is anybody else doing any disassembly of the system calls & commands?
     I have a copy of a Hacker's Treasure, but that is back at version 1.1.
     There is some info in the System Programmer's Guide as well.
  3) Is there anything more to Segment Lists other than what is mentioned
     in the AmigaDOS Tech Ref Man?
                    LONG    Size of Segment
     Prev BPTR ---> LONG    BPTR to next segment [0 = eolist]
                    LONG    Start of segment code/data
     The reason I wonder is that there is a commonly used initialization
     module [used in several commands] which references a pointer [Boffset?]
     at the start of the segment code/data???
  The naming conventions of Hunks are a bit confusing. With HUNK_Code,
  HUNK_reloc, etc you get the impression that these signify the hunks,
  but on Page 251 of the ATRM we read:
     "A hunk consists of a block of code or data, relocation information
     and a list of defined or referenced external symbols. etc..."
  4) If a hunk consists of say HUNK_code, then HUNK_reloc, then HUNK_end;
     what are these sub-elements called? ie. the reloc piece or the code
     piece?
  5) What is the relation between Segments & hunks? Is there anything
     hidden here?
  6) In my disassemblies, I have noticed some peculiar (to put it mildly)
     hunk structures such as Code & Data pieces of length 0; 20 or 30
     code & data hunks (many of them very short) in an 8K program. Is this
     an artifact of inefficient &/ improper linking or is there a reason
     behind it?

  <-Harvey
         _____
 M     _/     \_       Harvey Taylor
 U    /   <o>   \      Meta Media Productions
 T   |           |     [QL wares:Amigoid in training]
 A   | <o>  <o>  |     726 West 17th
 N   |     [     |     Vancouver,BC.Canada.V5Z 1T9
 T    \_  ===  _/      uunet!van-bc!rsoft!mindlink!Harvey_Taylor
 S      \_____/        a186@mindlink.UUCP
   FOR NUCLEAR POWER

jesup@cbmvax.UUCP (Randell Jesup) (05/13/89)

In article <232@mindlink.UUCP> a186@mindlink.UUCP (Harvey Taylor) writes:
>  Lots of the commands use the global vector.
>  1) Is this structure defined anywhere? I do _not_ intend to use this info
>     for writing code, just to analyze my disassemblies.

	No.  Nor will it be.  Glad you're not thinking of using it, if you
were we'd have to send out the Attack Gnomes.  :-)

>  3) Is there anything more to Segment Lists other than what is mentioned
>     in the AmigaDOS Tech Ref Man?
>                    LONG    Size of Segment
>     Prev BPTR ---> LONG    BPTR to next segment [0 = eolist]
>                    LONG    Start of segment code/data
>     The reason I wonder is that there is a commonly used initialization
>     module [used in several commands] which references a pointer [Boffset?]
>     at the start of the segment code/data???

	That's all there is.  Some programs use their segments in funny
ways that would make your brain hurt, like BCPL.  Ignore it.

>  5) What is the relation between Segments & hunks? Is there anything
>     hidden here?

	Normally, and code or data or bss hunk becomes a segment when loaded.

>  6) In my disassemblies, I have noticed some peculiar (to put it mildly)
>     hunk structures such as Code & Data pieces of length 0; 20 or 30
>     code & data hunks (many of them very short) in an 8K program. Is this
>     an artifact of inefficient &/ improper linking or is there a reason
>     behind it?

	Side effect of some compiler/linker setups.  Blink does not produce
0 length hunks.  Large numbers of hunks are due to large numbers of source
files without use of the blink SMALLCODE/SMALLDATA options.

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup