Open LowLevelMahn opened 3 years ago
Hello @LowLevelMahn,
Well, sort of. You can say something like
int __far __attribute__ ((section (".text"))) x;
int
f (void)
{
return x;
}
(Note: The __far
is important.)
However, gcc-ia16
is not (yet) smart enough to recognize that --- in this case --- x
can be accessed via a %cs:
segment override, because it is in the same section (.text
) as the function referring to it. Thus the above code will cause a segment relocation to be emitted. (I see that Open Watcom does know about such special cases.)
Thank you!
Hello @tkchia,
Thus the above code will cause a segment relocation to be emitted.
I see the code emitted which causes a segment relocation to be:
movw $"x!"@SEG, %ax
movw %ax, %ds
Out of curiosity, then, the linker will correctly emit the relocation table entry such that %AX gets loaded with the same value as the CS segment, but that this would only work if the OS and executable format support relocation table relocations at load time, correct?
That is, this would produce an extended header (that which is being used for the medium model support) on ELKS, and work correctly if CONFIG_EXEC_MMODEL is turned on, and the same for MSDOS MZ format exes, right?
Thank you!
@ghaerr : that is so. Thank you!
close for now - solved my problem using watcom long time ago
Should probably be reopened - that the problem was solved doesn't mean it's still not an outstanding feature request in gcc-ia16.
Watcom supports something like based( segname("_CODE") ) to bind definition or extern of variables to the code segment
is there somethin similar available with gcc ia 16? is attribute ((section ("segXYZ"))) useable?