docs(debt): count the flags local titles pass to sceNetSend and sceNetSendto #12707

Merged
xXPBSXx merged 3 commits from upstream-pr/12707 into main 2026-10-29 06:44:12 +00:00
xXPBSXx commented 2026-10-29 03:57:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-29T03:57:18Z.


What

The entry then reads (the new part is its last sentence; a full stop was added before it):

MSG_NOSIGNAL (libSceNet) - sceNetSend, sceNetSendto and sceNetSendmsg accept 0x20000, FreeBSD's MSG_NOSIGNAL (sys/sys/socket.h), which ProsperoTV (PPSA99003) passes on every phone-remote reply. Firmware 13.42's libSceNet.sprx adds 0x40020000 to the flags of every send and refuses no flag itself (measured in an emulator), so passing the flag changes nothing on the console. What 0x40000000 means and which flags the kernel refuses are unknown; other flags still fail with EOPNOTSUPP here. Host sends outside Windows already pass MSG_NOSIGNAL and Windows raises no SIGPIPE, so a send on a stream whose write side is shut down fails with EPIPE. 35 of 53 local titles call sceNetSend/sceNetSendto directly from the executable (title libraries, function pointers, 2 tail jumps not read) with flags 0 at 86 sites, 0x80 at 10, non-constant at 2.

Changed: docs/dev/debt/libSceNet.md, one existing entry extended by one sentence. No code change.

Method: for each of 53 local titles the import table of the title's executable was read, and every direct call to the sceNetSend or sceNetSendto import was located in that executable. The flags argument (the fourth, ecx) is read from the last instruction before the call that writes ecx/rcx: xor %ecx,%ecx counts as 0 and mov $imm,%ecx as that constant; any other writer counts as not constant. Tail jumps (jmp) to the import are counted separately and not read. Title libraries (sce_module, prx) were not read, and calls through function pointers are not found. Static reading only, nothing run on a console; no game code is attached.

Per-title results and the counting script are attached to this PR. Counting: a site is a direct call to the import; the 2 tail jumps to sceNetSendto (one title) are listed but not read, so sceNetSendto has 49 read sites plus 2 tail jumps (51). A site whose last writer of ecx is not xor or mov $imm is counted as not constant (1 for each function; both are pass-through wrappers that load the value from memory).

Limitation of the reading: the backward walk stops at the first branch or call, but does not detect a branch target between the writer and the call, so a writer on another path could be counted. One of ten hand-checked sites had its writer further back than six instructions; it was still on the straight-line path. Calls through the GOT (call [rip+got]) would not be read either; in these executables every registry call site of both imports is a stub jmp [rip+got], so there are none.

Per-title result (35 titles call at least one of the two)
Title sceNetSend sites (flag) sceNetSendto sites (flag)
PPSA01285 - (-) 5 (0 x1, 0x80 x4)
PPSA01325 5 (0 x5) 2 (0 x2)
PPSA01530 2 (0 x1, 0x80 x1) 1 (0x80 x1)
PPSA01746 - (-) 1 (0 x1)
PPSA02100 - (-) 1 (0 x1)
PPSA02225 5 (0 x5) 1 (0x80 x1)
PPSA02530 1 (0 x1) 2 (0 x1, 0x80 x1)
PPSA02801 3 (0 x3) 1 (0 x1)
PPSA03001 - (-) 1 (0 x1)
PPSA03490 - (-) 2 (0 x1, not constant x1)
PPSA03685 - (-) 1 (0 x1)
PPSA04354 3 (0 x3) 1 (0 x1)
PPSA05347 1 (not constant x1) 2 (0 x1, 0x80 x1)
PPSA06465 3 (0 x3) 1 (0 x1)
PPSA07057 3 (0 x3) 1 (0 x1)
PPSA07411 1 (0 x1) 2 (0 x1, 0x80 x1)
PPSA07426 - (-) 1 (0 x1)
PPSA09076 3 (0 x3) 1 (0 x1)
PPSA09682 3 (0 x3) 1 (0 x1)
PPSA10261 - (-) 1 (0 x1)
PPSA10264 - (-) 2 (0 x2)
PPSA10600 - (-) 1 (0 x1)
PPSA12544 3 (0 x3) 1 (0 x1)
PPSA15065 3 (0 x3) 1 (0 x1)
PPSA16827 3 (0 x3) 1 (0 x1)
PPSA17226 - (-) 1 (0 x1)
PPSA20612 - (-) 1 (0 x1)
PPSA23126 - (-) 2 (0 x2)
PPSA25936 3 (0 x3) 1 (0 x1)
PPSA26223 - (-) 2 (0 x2)
PPSA26679 - (-) 2 (0 x2)
PPSA27752 - (-) 2 (0 x2)
PPSA29413 3 (0 x3) 1 (0 x1)
PPSA30601 1 (0 x1) 3 (0 x1, jmp x2)
PPSA35154 - (-) 1 (0 x1)

Totals: sceNetSend 49 sites (0 x47, 0x80 x1, not constant x1); sceNetSendto 51 (0 x39, 0x80 x9, not constant x1, tail jump x2). Titles without either import are not listed.

Overlap

Twelve open PRs change docs/dev/debt/libSceNet.md; none changes this entry. #12665 changes the sceNetInetPton/sceNetInetNtop entry; #12455, #12104, #11968, #11966, #11571, #11272, #10629, #9948 and #9578 change other entries, and git merge-tree of this branch against each of their heads is clean. #9932 and #5836 already conflict with main in other parts of the file (and, for #5836, in code); their conflicts are the same with this branch. Measured on the file sets of all open PRs (git diff --name-only from each PR head's merge base with main).

Tested

Documentation only. tools/check_conventions.py --base upstream/main passes; based on current main b433c40f2f. Not built, not run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5061864592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12707). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-29T03:57:18Z. --- ### What The entry then reads (the new part is its last sentence; a full stop was added before it): > [MSG_NOSIGNAL](../../../core/libs/prx/libSceNet/Export.cpp) (libSceNet) - `sceNetSend`, `sceNetSendto` and `sceNetSendmsg` accept `0x20000`, FreeBSD's `MSG_NOSIGNAL` (`sys/sys/socket.h`), which ProsperoTV (PPSA99003) passes on every phone-remote reply. Firmware 13.42's `libSceNet.sprx` adds `0x40020000` to the flags of every send and refuses no flag itself ([measured in an emulator](https://github.com/boykopovar/AnyPS5/pull/11037#issuecomment-6400759240)), so passing the flag changes nothing on the console. What `0x40000000` means and which flags the kernel refuses are unknown; other flags still fail with `EOPNOTSUPP` here. Host sends outside Windows already pass `MSG_NOSIGNAL` and Windows raises no `SIGPIPE`, so a send on a stream whose write side is shut down fails with `EPIPE`. 35 of 53 local titles call `sceNetSend`/`sceNetSendto` directly from the executable (title libraries, function pointers, 2 tail jumps not read) with flags 0 at 86 sites, 0x80 at 10, non-constant at 2. Changed: `docs/dev/debt/libSceNet.md`, one existing entry extended by one sentence. No code change. Method: for each of 53 local titles the import table of the title's executable was read, and every direct `call` to the `sceNetSend` or `sceNetSendto` import was located in that executable. The flags argument (the fourth, `ecx`) is read from the last instruction before the call that writes `ecx`/`rcx`: `xor %ecx,%ecx` counts as 0 and `mov $imm,%ecx` as that constant; any other writer counts as not constant. Tail jumps (`jmp`) to the import are counted separately and not read. Title libraries (`sce_module`, `prx`) were not read, and calls through function pointers are not found. Static reading only, nothing run on a console; no game code is attached. Per-title results and the counting script are attached to this PR. Counting: a site is a direct `call` to the import; the 2 tail jumps to `sceNetSendto` (one title) are listed but not read, so `sceNetSendto` has 49 read sites plus 2 tail jumps (51). A site whose last writer of `ecx` is not `xor` or `mov $imm` is counted as not constant (1 for each function; both are pass-through wrappers that load the value from memory). Limitation of the reading: the backward walk stops at the first branch or call, but does not detect a branch target between the writer and the call, so a writer on another path could be counted. One of ten hand-checked sites had its writer further back than six instructions; it was still on the straight-line path. Calls through the GOT (`call [rip+got]`) would not be read either; in these executables every registry call site of both imports is a stub `jmp [rip+got]`, so there are none. <details><summary>Per-title result (35 titles call at least one of the two)</summary> | Title | `sceNetSend` sites (flag) | `sceNetSendto` sites (flag) | |---|---|---| | PPSA01285 | - (-) | 5 (0 x1, 0x80 x4) | | PPSA01325 | 5 (0 x5) | 2 (0 x2) | | PPSA01530 | 2 (0 x1, 0x80 x1) | 1 (0x80 x1) | | PPSA01746 | - (-) | 1 (0 x1) | | PPSA02100 | - (-) | 1 (0 x1) | | PPSA02225 | 5 (0 x5) | 1 (0x80 x1) | | PPSA02530 | 1 (0 x1) | 2 (0 x1, 0x80 x1) | | PPSA02801 | 3 (0 x3) | 1 (0 x1) | | PPSA03001 | - (-) | 1 (0 x1) | | PPSA03490 | - (-) | 2 (0 x1, not constant x1) | | PPSA03685 | - (-) | 1 (0 x1) | | PPSA04354 | 3 (0 x3) | 1 (0 x1) | | PPSA05347 | 1 (not constant x1) | 2 (0 x1, 0x80 x1) | | PPSA06465 | 3 (0 x3) | 1 (0 x1) | | PPSA07057 | 3 (0 x3) | 1 (0 x1) | | PPSA07411 | 1 (0 x1) | 2 (0 x1, 0x80 x1) | | PPSA07426 | - (-) | 1 (0 x1) | | PPSA09076 | 3 (0 x3) | 1 (0 x1) | | PPSA09682 | 3 (0 x3) | 1 (0 x1) | | PPSA10261 | - (-) | 1 (0 x1) | | PPSA10264 | - (-) | 2 (0 x2) | | PPSA10600 | - (-) | 1 (0 x1) | | PPSA12544 | 3 (0 x3) | 1 (0 x1) | | PPSA15065 | 3 (0 x3) | 1 (0 x1) | | PPSA16827 | 3 (0 x3) | 1 (0 x1) | | PPSA17226 | - (-) | 1 (0 x1) | | PPSA20612 | - (-) | 1 (0 x1) | | PPSA23126 | - (-) | 2 (0 x2) | | PPSA25936 | 3 (0 x3) | 1 (0 x1) | | PPSA26223 | - (-) | 2 (0 x2) | | PPSA26679 | - (-) | 2 (0 x2) | | PPSA27752 | - (-) | 2 (0 x2) | | PPSA29413 | 3 (0 x3) | 1 (0 x1) | | PPSA30601 | 1 (0 x1) | 3 (0 x1, jmp x2) | | PPSA35154 | - (-) | 1 (0 x1) | Totals: `sceNetSend` 49 sites (0 x47, 0x80 x1, not constant x1); `sceNetSendto` 51 (0 x39, 0x80 x9, not constant x1, tail jump x2). Titles without either import are not listed. </details> ### Overlap Twelve open PRs change `docs/dev/debt/libSceNet.md`; none changes this entry. #12665 changes the `sceNetInetPton`/`sceNetInetNtop` entry; #12455, #12104, #11968, #11966, #11571, #11272, #10629, #9948 and #9578 change other entries, and `git merge-tree` of this branch against each of their heads is clean. #9932 and #5836 already conflict with `main` in other parts of the file (and, for #5836, in code); their conflicts are the same with this branch. Measured on the file sets of all open PRs (`git diff --name-only` from each PR head's merge base with `main`). ### Tested Documentation only. `tools/check_conventions.py --base upstream/main` passes; based on current `main` `b433c40f2f`. Not built, not run. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
rooklz commented 2026-10-29 04:04:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T04:04:45Z.

Review: COMMENTED


I reviewed the attached data and script. I ran nothing on title code: I don't have the 53 executables, and I only ran the posted script on synthetic input.

What I checked (head ae4fbac236, main b433c40f2f)

Check Result
git merge-tree --write-tree upstream/main clean
check_conventions.py --base upstream/main --head passed
git diff --check clean
Body table vs the per-site output in the comment (recounted with a script) 35 titles, sceNetSend 49 = 47×0 / 1×0x80 / 1 non-constant; sceNetSendto 51 = 39×0 / 9×0x80 / 1 non-constant / 2 tail jumps → 86 / 10 / 2 / 2. These match the new sentence
Per-site output vs Export.cpp L1273/L1300 (DONTWAIT | NOSIGNAL accepted) every constant flag in the output (0, 0x80) is already accepted, so the sentence correctly says nothing changes for these titles

The attachment has what #12665's reviewers asked for: per-site addresses, the script, and how tail jumps and non-constant values were handled. Thanks.

Two gaps in the posted script (tested on synthetic input)

1. classify() skips some instructions that write ecx. DEST = r',%(rcx|ecx|cx|cl)$' only matches a register in the last operand after a comma. When one of these instructions sits between the counted writer and the call, the script still reports the earlier constant:

sequence before call posted script correct
xor %ecx,%ecx; push %rax; pop %rcx 0 not constant
xor %ecx,%ecx; inc %ecx 0 not constant (1)
mov $0x80,%ecx; neg %ecx 0x80 not constant
xor %ecx,%ecx; bswap %ecx / xchg %ecx,%eax / mov $0x2,%ch / cpuid 0 not constant
mov $0x10,%rcx; rep stos … 0x10 not constant (rcx = 0 afterwards)
mov $0x80,%ecx; bnd jmp … 0x80 stop at the branch

None of these is likely right before a call in compiler output, so the totals probably don't change. Still, the sentence's "never 0x40000000 or 0x20000" and "0 at 86" rest on this walk. A stricter classify (diff below) gives the right column for all 18 synthetic cases I tried and the same answer as the posted script for the 9 ordinary ones (xor, mov imm, movq, lea, memory load, cmp/push/source reads of ecx). Could you rerun with it and say in the body whether any site changes?

-DEST = re.compile(r',%(rcx|ecx|cx|cl)$')
+DEST = re.compile(r'(^|,)%(rcx|ecx|cx|cl|ch)$')
+ANY = re.compile(r'%(rcx|ecx|cx|cl|ch)\b')
+IMPLICIT = ('rep', 'loop', 'cpuid', 'rdtscp', 'rdpid', 'syscall', 'xgetbv', 'rdmsr', 'rdpmc', 'cmpxchg8b', 'cmpxchg16b')
 ...
-        if op in ('call', 'ret') or op.startswith('j'): return 'not constant (no writer before branch)'
-        if not DEST.search(text.replace(' ', '')): continue
+        if op in ('call', 'ret', 'bnd', 'notrack') or op.startswith('j'): return 'not constant (no writer before branch)'
+        if op.startswith(IMPLICIT) or (op.startswith(('xchg', 'xadd')) and ANY.search(text)): return 'not constant (' + op + ')'
+        if not DEST.search(text[len(op):].replace(' ', '')) or op.startswith(('push', 'cmp', 'test', 'bt ')): continue

2. Calls straight through the GOT are not counted. The relinker's callSites (CallSiteResolver.cpp L67-104) are every RIP-relative FF /2../6 or REX.W 8B that refers to the import's slot. That includes the PLT stub's jmp [rip+got], and also a title's own call [rip+got] (FF 15) and mov rax,[rip+got]. The script treats each listed address as a stub and only counts E8/E9 rel32 that target one. I built a one-segment ELF plus registry with a PLT jmp [got], a tail jmp to it, a call [rip+got] and a mov rax,[rip+got], all on sceNetSend. The script reports only the tail jump; the FF 15 call is silently left out. The body says "every direct call to the sceNetSend or sceNetSendto import was located", so could you report, per title, how many registry callSites are not stub-start FF 25 (0 would settle it)? Otherwise, add "calls through the GOT (call [rip+…]) are not read" to the limits.

Wording nit

"(libraries, 2 tail jumps unread)" is hard to parse. Maybe: "in their executables (title libraries and 2 tail jumps not read), flags are …".

Docs-only change, and the sentence is consistent with the code. Neither gap is likely to change the numbers, so this is a comment, not a change request.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692717706 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12707#pullrequestreview-5692717706). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-29T04:04:45Z. **Review:** COMMENTED --- I reviewed the attached data and script. I ran nothing on title code: I don't have the 53 executables, and I only ran the posted script on synthetic input. ### What I checked (head `ae4fbac236`, main `b433c40f2f`) | Check | Result | |---|---| | `git merge-tree --write-tree upstream/main` | clean | | `check_conventions.py --base upstream/main --head` | passed | | `git diff --check` | clean | | Body table vs the per-site output in the comment (recounted with a script) | 35 titles, `sceNetSend` 49 = 47×0 / 1×0x80 / 1 non-constant; `sceNetSendto` 51 = 39×0 / 9×0x80 / 1 non-constant / 2 tail jumps → 86 / 10 / 2 / 2. These match the new sentence | | Per-site output vs `Export.cpp` L1273/L1300 (`DONTWAIT \| NOSIGNAL` accepted) | every constant flag in the output (0, 0x80) is already accepted, so the sentence correctly says nothing changes for these titles | The attachment has what #12665's reviewers asked for: per-site addresses, the script, and how tail jumps and non-constant values were handled. Thanks. ### Two gaps in the posted script (tested on synthetic input) **1. `classify()` skips some instructions that write `ecx`.** `DEST = r',%(rcx|ecx|cx|cl)$'` only matches a register in the *last operand after a comma*. When one of these instructions sits between the counted writer and the call, the script still reports the earlier constant: | sequence before `call` | posted script | correct | |---|---|---| | `xor %ecx,%ecx; push %rax; pop %rcx` | `0` | not constant | | `xor %ecx,%ecx; inc %ecx` | `0` | not constant (1) | | `mov $0x80,%ecx; neg %ecx` | `0x80` | not constant | | `xor %ecx,%ecx; bswap %ecx` / `xchg %ecx,%eax` / `mov $0x2,%ch` / `cpuid` | `0` | not constant | | `mov $0x10,%rcx; rep stos …` | `0x10` | not constant (rcx = 0 afterwards) | | `mov $0x80,%ecx; bnd jmp …` | `0x80` | stop at the branch | None of these is likely right before a call in compiler output, so the totals probably don't change. Still, the sentence's "never 0x40000000 or 0x20000" and "0 at 86" rest on this walk. A stricter `classify` (diff below) gives the right column for all 18 synthetic cases I tried and the same answer as the posted script for the 9 ordinary ones (xor, mov imm, movq, lea, memory load, `cmp`/`push`/source reads of ecx). Could you rerun with it and say in the body whether any site changes? ```diff -DEST = re.compile(r',%(rcx|ecx|cx|cl)$') +DEST = re.compile(r'(^|,)%(rcx|ecx|cx|cl|ch)$') +ANY = re.compile(r'%(rcx|ecx|cx|cl|ch)\b') +IMPLICIT = ('rep', 'loop', 'cpuid', 'rdtscp', 'rdpid', 'syscall', 'xgetbv', 'rdmsr', 'rdpmc', 'cmpxchg8b', 'cmpxchg16b') ... - if op in ('call', 'ret') or op.startswith('j'): return 'not constant (no writer before branch)' - if not DEST.search(text.replace(' ', '')): continue + if op in ('call', 'ret', 'bnd', 'notrack') or op.startswith('j'): return 'not constant (no writer before branch)' + if op.startswith(IMPLICIT) or (op.startswith(('xchg', 'xadd')) and ANY.search(text)): return 'not constant (' + op + ')' + if not DEST.search(text[len(op):].replace(' ', '')) or op.startswith(('push', 'cmp', 'test', 'bt ')): continue ``` **2. Calls straight through the GOT are not counted.** The relinker's `callSites` (`CallSiteResolver.cpp` L67-104) are every RIP-relative `FF /2../6` or `REX.W 8B` that refers to the import's slot. That includes the PLT stub's `jmp [rip+got]`, and also a title's own `call [rip+got]` (`FF 15`) and `mov rax,[rip+got]`. The script treats each listed address as a stub and only counts `E8`/`E9 rel32` that target one. I built a one-segment ELF plus registry with a PLT `jmp [got]`, a tail `jmp` to it, a `call [rip+got]` and a `mov rax,[rip+got]`, all on `sceNetSend`. The script reports only the tail jump; the `FF 15` call is silently left out. The body says "every direct `call` to the `sceNetSend` or `sceNetSendto` import was located", so could you report, per title, how many registry `callSites` are not stub-start `FF 25` (0 would settle it)? Otherwise, add "calls through the GOT (`call [rip+…]`) are not read" to the limits. ### Wording nit "(libraries, 2 tail jumps unread)" is hard to parse. Maybe: "in their executables (title libraries and 2 tail jumps not read), flags are …". Docs-only change, and the sentence is consistent with the code. Neither gap is likely to change the numbers, so this is a comment, not a change request. AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!12707
No description provided.