Code: Select all
nasm test.s -o test.out -f madd
Code: Select all
extern label
mov eax,label
call [eax]
Code: Select all
nasm test.s -o test.out -f madd
Code: Select all
extern label
mov eax,label
call [eax]
Whatever value label was assigned by the linker, in the object file where it was actually defined (i.e., after relocation).mariuszp wrote:What would the value of EAX be?
...thepowersgang wrote:You can do that by studying other formats, and not asking poorly questions on the forums.
I don't think so. ELF has no support for segmentation, and it has an assumed base-address of the executable and contains offset relocation information. In my design, the code and data segments always start a offset 0, and never need relocation. Relocation is done by changing base of the code and data selector. ELF also does not support changing SEG references to real selector references. It only supports changing 32-bit offsets using relocation tables. ELF doesn't support dynamic linking using 48-bit imports either. ELF only supports changing a 32-bit offset when resolving imported references.berkus wrote:You could use ELF for that, for example.rdos wrote:I would want to implement a new executable format which would be much simpler than PE/ELF. It would be based on the compact memory model. There would be no relocation information as compact memory model does not require any runtime relocations. Dynamic link libraries would need relocations of segments and offsets of 48-bit far calls. Entries in DGROUP would not need relocations either, nor would resource entries, as these would always refer to the same segment. The only required patching would be of default code & data segments unless this is specified with fixed selectors at link-time. This could be handled at runtime by putting invalid selectors in the code, and let the protection-fault handler do the patching.