Author Topic: relocatable real-mode code in ELF?  (Read 7457 times)

Offline stsp

  • Jr. Member
  • *
  • Posts: 2
relocatable real-mode code in ELF?
« on: March 10, 2021, 09:47:42 AM »

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?

Offline stsp

  • Jr. Member
  • *
  • Posts: 2
Re: relocatable real-mode code in ELF?
« Reply #1 on: March 10, 2021, 10:52:00 AM »
I have now found this document:
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?