Previously the user stack was obtained using the kern.usrstack
sysctl. This has been moved to auxv in FreeBSD 14. Without
this change all programs linked with libthr fail with a panic
when they fail to get a valid user stack address.
Note also in FreeBSD 14 ASLR has been enabled. This means that
there is now some extra difference between the address layout of
a standalone executable and the same executable under valgrind.
Pre-FreeBSD 14 and under valgrind:
lib rtld is loaded after the executable (though a much smaller gap
inder valgrind)
user stack starts at 0x7ffffffff000
FreeBSD 14
lib rtld is loaded at a much higher address, around 0xeeeecc15000
user stack is at a much lower address, around 0x82073d000
This means that valgrind behaves somewhat as thogh the
kern.elf(64|32).aslr.stack sysctl were set to 0.
Some more work will be needed for the stack size.
There are no plans at the moment to match the FreeBSD 14 memory
layout.
// case AT_KPRELOAD:
#endif
+#if (FREEBSD_VERS >= FREEBSD_14)
+ case AT_USRSTACKBASE:
+ auxv->u.a_val = VG_(get_usrstack)();
+ break;
+ case AT_USRSTACKLIM:
+ auxv->a_type = AT_IGNORE;
+ break;
+#endif
+
case AT_PHDR:
if (info->phdr == 0)
auxv->a_type = AT_IGNORE;