Re: [hatari-devel] Support for loading GNU-style symbols from a.out executables

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


On Donnerstag, 9. November 2017 00:50:05 CET Eero Tamminen wrote:

> The section address can be determined only when the program is loaded

Yes, of course. But the output of the tool should at least be consistent, 
either section based, or all text-based. I think this is currently not the 
case. I also don't know how to produce an executable with GST symbols that are 
text based to test that, maybe that is only possible with some other linker.

> You can know that only after OS has loaded the program.

Actually, for atari, not. You can't load atari programs other than with 
continguous text/data/bss sections. There is no relocation information that 
would tell you which instructions have to be patched. I've seen lots of 
programs that use pc-relative addressing in the text segment to addresses 
defined in the data segment. That can only be done if the pc-offset is already 
known at compile time, or the instruction is changed when loading the program 
using some relocation information, which is not the case for Atari.

>or would it be within spec if OS would put them into wildly different
>addresses.

Thats only possible if both the file format and the OS are supporting this. For 
gemdos executables, this is not the case, since the relocation information 
only allows to relocate absolute addresses.

There are fields in the a.out header that would allow to do so (the a_troffset 
and a_droffset), but those are not written by our a.out-mintprg binutils 
format, and are also not used by gemdos Pexec() (they are still present in the 
object files, and are used by the linker to perform the calculations mentioned 
above, but not in the final executable).

So unless some program uses a propietary format, some custom linker to produce 
it, and some custom loader, there is no way to load gemdos executables with 
sections at arbitrary addresses. One of the reasons which makes implementing 
real shared libs for atari almost impossible.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/