mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 08:33:12 -05:00
Export getopt (VUtibKJCt1o) and getopt_long (8VVXJxB5nlk) from libSceLibcInternal together with the guest variables optind (zCnSJWp-Qj8), optarg (zG0BNJOZdm4), opterr (yaFXXViLWPw), optopt (FwzVaZ8Vnus) and optreset (CZNm+oNmB-I). The NIDs were computed with tools/nid_names.py and all seven are in aerolib; the PS5 payload SDK f5d40f02 lists the functions and the five objects in sce_stubs/libSceLibcInternal.c. Titles (predicted stops from registry order, not observed runs): - XPSemu PPSA97358, after execv/execve, the signal waits, the credential setters, mlockall and tcsendbreak: "FAIL: unresolved ELF import VUtibKJCt1o from libSceLibcInternal.prx" (getopt idx 204, 10 call sites from 0xF6C23D), then optind (207), optreset (208), optarg (209). - RetroArch PPSA99169: getopt_long (idx 554, call sites 0xD2FC0C, 0xD3002A), optind (553), optarg (555). Behaviour follows FreeBSD release/11.4.0 8c639945: getopt is lib/libc/stdlib/getopt.c (no permutation, GNU "::" optional argument, lone "-" as an option when listed), getopt_long is getopt_internal from lib/libc/stdlib/getopt_long.c with GNU_COMPATIBLE (permutation, POSIXLY_CORRECT read through the guest getenv on the first call and on optreset, "+" and "-" prefixes, "W;", optind 0 as a reset, abbreviation and ambiguity rules and the GNU warning texts). Warnings are written to the guest stderr stream as "<__progname>: <message>", as warnx does. The struct option layout and argument kinds are include/getopt.h. The code lives in libSceLibcInternal because __progname is a libkernel export that libc cannot link. A null getopt option string, a null argument vector or argument, a negative optind and an optind moved inside a pending permutation throw where FreeBSD faults. getopt_long_only is not exported. guest_getopt runs the FreeBSD getopt_test cases (contrib/netbsd-tests t_getopt.sh with the h_getopt and h_getopt_long result format) plus grouped and optional arguments, "--", permutation order, "+" and "-" prefixes, optreset and optind 0 restarts, POSIXLY_CORRECT, all three long argument kinds, abbreviations, ambiguity, flag pointers, "W;", optopt with opterr 0 and the exact stderr text. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit a2740166d93920c301e1add23ceea762b4acad27)
3.5 KiB
3.5 KiB
libSceLibcInternal technical debt
Unknown function info
- _sceLibcInternalThreadAtexit, _sceLibcInternalThreadDtors (libSceLibcInternal) - FreeBSD
__cxa_thread_atexitsemantics assumed; a null or non-image destructor and an allocation failure throw - _sceLibcInternalForceTlsDestructor (libSceLibcInternal) - behaviour follows
sceLibcForceTlsDestructor(int)in a title'slibc.prx(disassembly): the calling thread's destructors whose dso belongs to the module run newest first, only if the dso's module is loaded and the dso points to itself, in up to 4 passes. The return type is unknown (that function returns nothing), 0 is returned. The module of each dso is looked up when the destructors are forced, not when they are registered aslibc.prxdoes
Functional
- makecontext (libSceLibcInternal) follows FreeBSD 11's
lib/libc/amd64/gen/makecontext.c: at most six arguments, a stack of at leastMINSIGSTKSZ(2048) bytes, andexit(0)when the function returns with nouc_link. The console's version is not verified - makecontext (libSceLibcInternal) on Windows pins its stack writable until a later
makecontextstack overlaps it, since nothing tells the library when the guest frees the stack - Thread exit destructors (libSceLibcInternal) run when a libkernel thread finishes; on the main or a host thread only
_sceLibcInternalThreadDtorsruns them, asexitdoes, else they are dropped - fstatvfs (libSceLibcInternal) converts
_fstatfsto the 88-bytestruct statvfsas FreeBSD 9.2'ssfs2svfsdoes (f_bsizefrom the transfer size,f_frsizefrom the block size,f_favailequal tof_ffree,f_fsid0,ST_RDONLYandST_NOSUIDonly). Differences:f_namemaxis thestatfsvalue, notfpathconf(_PC_NAME_MAX); negativef_bavailandf_ffreewrap to unsigned withoutEOVERFLOW, as the same-width copy in FreeBSD does; inode counts are 0 on Windows, inherited from_fstatfs; a null output returnsEFAULTafter the descriptor is validated, where FreeBSD would fault. Layout and conversion are unverified against the PS5 library (PS5MC importsfstatvfsbut was not run) - getopt, getopt_long (libSceLibcInternal) follow FreeBSD 11 getopt.c and getopt_long.c with
GNU_COMPATIBLE:getoptdoes not permute,getopt_longpermutes unlessPOSIXLY_CORRECTis set in the guest environment or the option string starts with+, and the exportedopterr,optind,optopt,optresetandoptargstart at 1, 1, 0, 0 and null. Warnings go to the guest's currentstderrprefixed with__progname, where FreeBSD'swarnxkeeps thestderrof its first call. A nullgetoptoption string, a null argument vector or argument, a negativeoptindand anoptindmoved inside a pending permutation throw where FreeBSD faults.getopt_long_onlyis not exported. That the console'slibSceLibcInternaluses this FreeBSD code is unverified