On 22.04.2024 06:16, Paul Moore wrote:
Weird processor. It only supports absolute jumps. So this is something that
needs to be fixed up during link time. I do not know the elf details well
enough to be able to work out how to do it
Seems like I need the jmp instruction to be a have reloc that refers to a
symbol that matches the jump destination, say “dest1”. So I need a reference to
Symbol “dest1” at the jump site and a definition generated later (by
gsym_addr). Can I even do that , have a reference to a symbol that I export but
want resolved at link time and not have ELF go “well I know that symbol, its
right here”
Hi,
certainly it's easily possible, however assuming this 16-bit 'hack'
computer/processor doesn't really have an operating system capable
to load ELF files and hence assuming that you probably want to go
with the -Wl,-oformat=binary option, you can get away without relocation
at all.
You'd simply replace the relative patch in gsym_addr()
write32le(ptr, a - t - 4);
by an absolute one, for example
write16le(ptr, a + LOAD_ADDRESS);
where LOAD_ADDRESS obviously is where the program is supposed to be
loaded.
By the way, if you prefer to start hacking with something more
simple, maybe you want to have a look at tinycc's initial revision
https://repo.or.cz/tinycc.git/commitdiff/initial
which already can compile itself, almost at least. (IIRC parsing
for 0x... hex numbers needs to be added and the #ifdefs need to
be removed. It can handle "#define SYM VAL" though. Also the
vac and/or vat table should be initialized with '0', IIRC)
-- gr
I thought that maybe computed goto offered a way to prise the lid off this, but
no , that doesn’t not work the same way.
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel