SimEng icon indicating copy to clipboard operation
SimEng copied to clipboard

Add missing auxilary variables to initial stack frame

Open jrprice opened this issue 5 years ago • 1 comments

The ELF loader is supposed to set various auxiliary variables in the initial stack frame, which are subsequently used by the libc runtime. We currently just set AT_PAGESZ (used by malloc), but there are many others that need to be set as well. This should probably be done proactively rather than as needed, since weird things happen when the runtimes are expecting a value that isn't there (speaking from experience from when I needed to add AT_PAGESZ).

https://github.com/UoB-HPC/SimEng/blob/1765300058152d09585142cd3ef17af2d299f729/src/lib/kernel/LinuxProcess.cc#L110

jrprice avatar Nov 09 '19 05:11 jrprice

After #300 entries AT_PHDR, AT_PHENT, AT_PHNUM, AT_PAGESZ, AT_ENTRY and AT_NULL are populated. This is far from all possible entries described here.

Entries that could/should be populated in the future: AT_BASE: base address of dynamic linker AT_PLATFORM: used by the dynamic linker AT_SECURE: used by the dynamic linker AT_SYSINFO/_EHDR: entry point to VDSO which does exist for AArch64 and RISC-V

AT_CLKTCK: the frequency at which times() counts, possibly useful for codes which time themselves? AT_DCACHEBSIZE/ICACHEBSIZE/UCACHEBSIZE: should be easy to populate with new memory hierarchy All group and user ID's: might be needed for threading? AT_EXECFD/FN: file descriptor and pathname of program AT_HWCAP: may be able to generate this from the yaml file but not sure the format AT_RANDOM: pointer to random 16 bytes

A couple more entries are listed here.

dANW34V3R avatar Jun 07 '23 11:06 dANW34V3R