]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
fix(elf): skip SHN_UNDEF symbols in GLOB_DAT/32 relocations
authorTulio A M Mendes <[email protected]>
Thu, 16 Apr 2026 05:36:15 +0000 (02:36 -0300)
committerTulio A M Mendes <[email protected]>
Thu, 16 Apr 2026 05:36:15 +0000 (02:36 -0300)
commitfbaa14ed8d5c576db36f9f2e212b7ca7a0628868
treed42e1ff3eec9f498f3ed3ad55249f518b91f8417
parenta9222fcf9b4f1d227783f775ad268de9337a6efc
fix(elf): skip SHN_UNDEF symbols in GLOB_DAT/32 relocations

The kernel's elf32_process_relocations incorrectly resolved R_386_GLOB_DAT
relocations for SHN_UNDEF symbols (st_shndx == 0) by setting the GOT
entry to base_offset. For libc.so loaded at 0x11000000, this meant
symbols like __init_array_start, __fini_array_end, and _init were
resolved to 0x11000000 (the ELF header), causing __libc_init_array
to execute garbage code at the ELF header and crash with SIGSEGV
at eip=0x11000012.

Now, SHN_UNDEF symbols are set to 0 in the GOT, leaving them for
the dynamic linker to resolve. Defined symbols (st_shndx != 0)
continue to be resolved as sym->st_value + base_offset.

Also removed debug kprintf from elf32_load_needed_libs.
src/arch/x86/elf.c