NASM Forum > Programming with NASM

relocatable real-mode code in ELF?

(1/2) > >>

stsp:
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?

stsp:
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?

Elawig57:
That was so amazing and that was so great.
MIBridges

Frank Kotler:
Nasm's "-f elf" ts protected mode code. If you can get real mode out of it (?). what OS would you run it in? What is the state of bit 0 of cr0? They calculate addresses by a different scheme!

What do you think, Elawig57?

Confused,
Frank

fredericopissarra:

--- Quote from: Frank Kotler on January 02, 2023, 02:45:30 PM ---Nasm's "-f elf" ts protected mode code. If you can get real mode out of it (?). what OS would you run it in? What is the state of bit 0 of cr0? They calculate addresses by a different scheme!

What do you think, Elawig57?

Confused,
Frank

--- End quote ---
Nope... -felf (or -felf32) is an ELF32 format. If you create an apropriate script for ld you can generate a binary file from this linkable format...

Navigation

[0] Message Index

[#] Next page

Go to full version