[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] DR relocations (for lib converter)



Hi Guido

Guido Flohr wrote:
>
> But how to code relocation against an external symbol?  Say we've got an
> external symbol "_printf" that is referenced at offset 0x456 in the text
> segment.  How the heck can the linker find out that "_printf" is
> referenced there? 

This what I know of the simplest and oldest DRI format. 
(No docs, it is the way how TTDigger does it. :-).

At the position (e.g. 456) where the reference to a external occurs, the relocation
(I prefer the word "fixup") info contains a code that means 'external' + the
number of the position in the symbol table as follows:
Suppose its a long reference;
the first word contains 5.	this means 'long'.
the second word contains in the first 13 bits the number of the symbol table
entry and in the last 3 bits the value 4 or 6.  this means 'external'.
(I do not know the difference between 4 or 6)
If the reference was name+offset, the offset sits in the code itself.
The linker uses the name to find the object in the library.
The linker calculates the address, if the object is found, and if
the mode of the reference is PC relative, the value is simply adjusted by the linker.
If not in the same segment or forward, then at a later stage.
In DRI format you have only PC reletive references in instructions, so the fact
that a reference is reletive is obtained from the instructions addressing mode.

The name is the only thing you know, so its the only thing you get. ;-)

Maybe this helps.
Groeten
Henk.

TTDigger is a disassembler, on http://people.A2000.nl/hrobbers/Homepage.html