NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: stsp on March 10, 2021, 09:47:42 AM

Title: relocatable real-mode code in ELF?
Post by: stsp on March 10, 2021, 09:47:42 AM
Hi.

I wonder if it is possible to create the
relocatable real-mode code with nasm,
outputting it into an ELF format.
For example if we have the code like
jmp     TGROUP:label
then we can define TGROUP in a linker
script, but it won't be relocatable.
I read the doc about the relocations in nasm,
and it seems to mostly support only got
and plt relocations.
What I think would be useful for the real-mode
code, is the copy relocations like R_386_COPY,
so that in the example above, the value of
the variable TGROUP can just be copied
by dynamic linker, and used as a segment value.
(if someone wonders why putting real-mode code
into elf - well, its a common practice actually
when the resulting stuff is then executed under VTx)

What do people think?
Does nasm currently support creating the
relocatable real-mode code in ELF, or if not -
would something like R_386_COPY be an
adequate solution to the problem?
Title: Re: relocatable real-mode code in ELF?
Post by: stsp on March 10, 2021, 10:52:00 AM
I have now found this document:
https://github.com/tkchia/build-ia16/blob/master/elf16-writeup.md
Which mentions the R_386_SEGRELATIVE
relocation, which may also allow the run-time
relocations of real-mode code.
But I can't find such relocation in a nasm sources...
Where is it?
Is it something that is only being planned?