[Oberon] A2 start. Was "clock_gettime."
Michael Schierl
schierlm at gmx.de
Sat Aug 1 00:36:27 CEST 2026
Hello Peter,
Am 25.07.2026 um 23:53 schrieb Michael Schierl:
> It does not matter whether running it with multiarch or inside a 32-bit
> chroot (Debian sid), it always immediately receives SIGTRAP like in your
> example. Loading the core file into gdb suggests it got stranded on an
> INT3 instruction.
>
> It also does not matter whether it is started with setarch flags (I
> think I tried all possible ones, but probably I missed the correct
> combination).
I probably should have tried a 32-bit Debian oldstable chroot in my
64-bit kernel as well on Monday... As it works fine there. But not on
Debian stable or unstable.
Anyway, spent some time in edb today tracking down that INT3 instruction.
It maps to this line in Linux.Glue.Mod:
ASSERT(dlsym # NIL);
dlsym is populated by ld-linux.so.2 based on the relocations table in
the ELF header. So something is wrong in the ELF header for
ld-linux.so.2 of recent glibc versions. (The ELF header is built by some
crude "assembly" code in Linux.Glue.Mod PROCEDURE EntryPoint).
It may reassure you that building ELF headers from Assembly is also
unfamiliar territory for me, it would required me hours of reading the
spec and comparing it line-by-line with the assembly, so I asked ChatGPT
(you can follow along at
<https://chatgpt.com/share/6a6d2167-ab74-83ed-8fa6-63c4041ea7fa> if you
want to). It led me through some readelf and LD_DEBUG commands until
claiming that the reason is that it uses a relocation type in the
relocation table that officially is only supported on 64-bit systems.
And it seems that more recent glibc is stricter when checking, and
skipping it, which results in dlsym remaining NIL.
It also provided a patch, which would require more #IFs to make it not
break 64-bit, but with that patch, I can build a 32-bit command shell
that at least loads in my 64-bit WSL. Did not test full A2 since setting
up X11 via wslg is a bit of a hassle right now for me.
Here is the patch:
--- a/source/Linux.Glue.Mod
+++ b/source/Linux.Glue.Mod
@@ -98,9 +98,9 @@ VAR
dynamicsection:
DD 05H, base + stringtable
DD 06H, symboltablebegin + base
- DD 07H, dlsymrelocation + base
- DD 08H, dlsymrelocation_end-dlsymrelocation ; size
(relocationtable)
- DD 09H, 0CH
+ DD 11H, dlsymrelocation + base ; DT_REL
+ DD 12H, dlsymrelocation_end-dlsymrelocation ; DT_RELSZ
+ DD 13H, 08H ; DT_RELENT
DD 0AH, stringtable_end - stringtable; size (stringtable)
DD 0BH, 10H
@@ -117,7 +117,7 @@ VAR
DB 01H ; relocation type
#END
DB 01H, 00H, 00H; index of the symbol
- DD 0H
+ ;; DD 0H
dlsymrelocation_end:
stringtable:
Feel free to try it and tell me how far it works for you.
Regards,
Michael
More information about the Oberon
mailing list