feat(posix): implement gethostbyname #1796

Merged
Mouhand-Kaddo merged 4 commits from upstream-pr/1796 into main 2026-10-09 22:02:16 +00:00
Mouhand-Kaddo commented 2026-10-08 19:24:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-08T19:24:29Z.


What

Implements gethostbyname in libScePosixForWebKit, one of EVO-PLAYER-PS5's missing imports reported in #1578.

Parses numeric IPv4 addresses with FreeBSD semantics before native hostname lookup. Supports decimal, octal and hexadecimal forms, one through four components, trailing whitespace and FreeBSD 64-bit accumulation. For example, 0x7f.1 resolves to 127.0.0.1. Copies the name, aliases and address list into per-thread storage with the guest hostent layout. Linux uses reentrant lookup. Windows converts its 16-bit host fields into guest 32-bit fields. Failures update sceNetErrnoLoc, the error location used by the public SDK's __h_errno. A successful numeric lookup clears that error.

The ABI and SDK error location follow SDK v0.43 netdb.h, SDK netdb.c, and FreeBSD 11 netdb.h. Numeric parsing and success errors follow FreeBSD 11.4 inet_aton and fakeaddr. Exact PS5 semantics remain unverified and are recorded in TechnicalDebt. Windows conversion follows Microsoft HOSTENT.

Tested

  • Arch Linux, GCC, Release build. The new behavioral check first failed with undefined reference to gethostbyname_nid_postfix.
  • guest_resolver and guest_sce_net pass. Checks cover numeric address bytes, guest field widths, names, aliases, address lists, per-thread result lifetime, and the SDK error location.
  • Loaded the NID-patched module and called 5T4SHQqzoGo: numeric lookup and shared error reporting pass.
  • The new 0x7f.1 regression check failed before the compatibility fix and passes after it. Sixteen numeric fixtures cover shorthand, octal, hexadecimal, whitespace, wrapping and component boundaries.
  • 2,009 numeric inputs match a locally compiled FreeBSD 11.4 inet_aton reference.
  • A consumer compiled for FreeBSD against SDK v0.43 headers passes guest hostent layout, numeric lookup and error-slot checks. It uses the SDK's actual __h_errno function. SDK tooling remains outside the repository.
  • Native Windows 11 Pro (build 26300), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: reproduced the reported guest_resolver_tests link failure with undefined reference to __gxx_personality_v0 on a1e2781f. Linking libc and applying configure_windows_unwind fixes the build. guest_resolver, guest_sce_net and windows_exceptions pass (3/3); the resolver executable has the required .ehfram section.
  • WSL2 Arch Linux, GCC 15.2.1, Release: built the same patched source. guest_resolver, guest_sce_net, exception_runtime, exception_personality and exception_c_cleanup pass (5/5). Linux .eh_frame and .eh_frame_hdr sections remain intact.
  • Conventions and independent Standards and Spec reviews pass. The Windows and WSL runs above cover targeted regression tests; the full suite, console behavior and EVO-PLAYER startup were not tested in these runs.

Checklist

  • Based on current main
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4791750566 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1796). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-08T19:24:29Z. --- ### What Implements `gethostbyname` in `libScePosixForWebKit`, one of EVO-PLAYER-PS5's missing imports reported in #1578. Parses numeric IPv4 addresses with FreeBSD semantics before native hostname lookup. Supports decimal, octal and hexadecimal forms, one through four components, trailing whitespace and FreeBSD 64-bit accumulation. For example, `0x7f.1` resolves to `127.0.0.1`. Copies the name, aliases and address list into per-thread storage with the guest `hostent` layout. Linux uses reentrant lookup. Windows converts its 16-bit host fields into guest 32-bit fields. Failures update `sceNetErrnoLoc`, the error location used by the public SDK's `__h_errno`. A successful numeric lookup clears that error. The ABI and SDK error location follow [SDK v0.43 netdb.h](https://github.com/ps5-payload-dev/sdk/blob/v0.43/include/freebsd/netdb.h), [SDK netdb.c](https://github.com/ps5-payload-dev/sdk/blob/v0.43/libc/netdb.c), and [FreeBSD 11 netdb.h](https://github.com/freebsd/freebsd-src/blob/releng/11.0/include/netdb.h). Numeric parsing and success errors follow FreeBSD 11.4 [inet_aton](https://github.com/freebsd/freebsd-src/blob/releng/11.4/lib/libc/inet/inet_addr.c) and [fakeaddr](https://github.com/freebsd/freebsd-src/blob/releng/11.4/lib/libc/net/gethostnamadr.c). Exact PS5 semantics remain unverified and are recorded in TechnicalDebt. Windows conversion follows [Microsoft HOSTENT](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/ns-winsock2-hostent). ### Tested - Arch Linux, GCC, Release build. The new behavioral check first failed with `undefined reference to gethostbyname_nid_postfix`. - `guest_resolver` and `guest_sce_net` pass. Checks cover numeric address bytes, guest field widths, names, aliases, address lists, per-thread result lifetime, and the SDK error location. - Loaded the NID-patched module and called `5T4SHQqzoGo`: numeric lookup and shared error reporting pass. - The new `0x7f.1` regression check failed before the compatibility fix and passes after it. Sixteen numeric fixtures cover shorthand, octal, hexadecimal, whitespace, wrapping and component boundaries. - 2,009 numeric inputs match a locally compiled FreeBSD 11.4 `inet_aton` reference. - A consumer compiled for FreeBSD against SDK v0.43 headers passes guest `hostent` layout, numeric lookup and error-slot checks. It uses the SDK's actual `__h_errno` function. SDK tooling remains outside the repository. - Native Windows 11 Pro (build 26300), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: reproduced the reported guest_resolver_tests link failure with undefined reference to __gxx_personality_v0 on a1e2781f. Linking libc and applying configure_windows_unwind fixes the build. guest_resolver, guest_sce_net and windows_exceptions pass (3/3); the resolver executable has the required .ehfram section. - WSL2 Arch Linux, GCC 15.2.1, Release: built the same patched source. guest_resolver, guest_sce_net, exception_runtime, exception_personality and exception_c_cleanup pass (5/5). Linux .eh_frame and .eh_frame_hdr sections remain intact. - Conventions and independent Standards and Spec reviews pass. The Windows and WSL runs above cover targeted regression tests; the full suite, console behavior and EVO-PLAYER startup were not tested in these runs. ### Checklist - [x] Based on current `main` - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; silent stubs are listed in TechnicalDebt - [x] No notes, investigation .md files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
popcoder565 commented 2026-10-09 15:44:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:44:50Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. I first hit this with 44964a1b in a batch build of PRs with no Windows run, then rechecked the current head a1e2781f alone on main d70b8998.

guest_resolver_tests doesn't link on Windows:

GuestResolver.cpp:(.data+0x458): undefined reference to `__gxx_personality_v0'

On MinGW, core/libs is built with -fno-asynchronous-unwind-tables, and the personality routine for that unwinding comes from libc.prx. The new test code needs it, but the test only links libScePosixForWebKit and libSceNet. Linking libc and adding configure_windows_unwind, as guest_sce_net_tests does, fixes it:

-    target_link_libraries(guest_resolver_tests PRIVATE libScePosixForWebKit libSceNet)
+    target_link_libraries(guest_resolver_tests PRIVATE libScePosixForWebKit libSceNet libc)
+    configure_windows_unwind(guest_resolver_tests)

With that change, guest_resolver passes 3 of 3 on a1e2781f. In the batch build with 44964a1b, the full suite passed too (519 of 519).

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084245873 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1796#issuecomment-6084245873). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:44:50Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. I first hit this with `44964a1b` in a batch build of PRs with no Windows run, then rechecked the current head `a1e2781f` alone on `main` d70b8998. **`guest_resolver_tests` doesn't link on Windows:** ``` GuestResolver.cpp:(.data+0x458): undefined reference to `__gxx_personality_v0' ``` On MinGW, `core/libs` is built with `-fno-asynchronous-unwind-tables`, and the personality routine for that unwinding comes from `libc.prx`. The new test code needs it, but the test only links `libScePosixForWebKit` and `libSceNet`. Linking `libc` and adding `configure_windows_unwind`, as `guest_sce_net_tests` does, fixes it: ```diff - target_link_libraries(guest_resolver_tests PRIVATE libScePosixForWebKit libSceNet) + target_link_libraries(guest_resolver_tests PRIVATE libScePosixForWebKit libSceNet libc) + configure_windows_unwind(guest_resolver_tests) ``` With that change, `guest_resolver` passes 3 of 3 on `a1e2781f`. In the batch build with `44964a1b`, the full suite passed too (519 of 519). _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
Mouhand-Kaddo commented 2026-10-09 16:08:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Mouhand-Kaddo on 2026-10-09T16:08:29Z.


Fixed in c80bea9b.

I reproduced the reported failure on the PR head a1e2781f with a native Windows Release build: guest_resolver_tests failed to link with undefined reference to __gxx_personality_v0. The fix links the test to libc and adds configure_windows_unwind, matching guest_sce_net_tests.

Tested on Windows 11 Pro (build 26300), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release:

  • guest_resolver, guest_sce_net and windows_exceptions pass: 3/3.
  • Verified the resolver executable has the required .ehfram section.

Also tested the same patch in WSL2 Arch Linux, GCC 15.2.1, Release:

  • guest_resolver, guest_sce_net, exception_runtime, exception_personality and exception_c_cleanup pass: 5/5.
  • Linux .eh_frame and .eh_frame_hdr sections remain intact.

Repository conventions and whitespace checks pass. These were targeted regression tests; the full suite, console behavior and EVO-PLAYER startup were not tested in these runs.

The PR testing notes have been updated. AI-assisted fix and validation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084641458 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1796#issuecomment-6084641458). Originally posted by [Mouhand-Kaddo](https://github.com/Mouhand-Kaddo) on 2026-10-09T16:08:29Z. --- Fixed in c80bea9b. I reproduced the reported failure on the PR head a1e2781f with a native Windows Release build: guest_resolver_tests failed to link with undefined reference to __gxx_personality_v0. The fix links the test to libc and adds configure_windows_unwind, matching guest_sce_net_tests. Tested on Windows 11 Pro (build 26300), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: - guest_resolver, guest_sce_net and windows_exceptions pass: 3/3. - Verified the resolver executable has the required .ehfram section. Also tested the same patch in WSL2 Arch Linux, GCC 15.2.1, Release: - guest_resolver, guest_sce_net, exception_runtime, exception_personality and exception_c_cleanup pass: 5/5. - Linux .eh_frame and .eh_frame_hdr sections remain intact. Repository conventions and whitespace checks pass. These were targeted regression tests; the full suite, console behavior and EVO-PLAYER startup were not tested in these runs. The PR testing notes have been updated. AI-assisted fix and validation.
adriadam10 commented 2026-10-09 22:02:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:02:12Z.


Checked on Linux (GCC, merged onto current main): guest_resolver passes, and the new test fails to build without the change. Diff matches the description, TechnicalDebt line is in place, and the Windows link fix matches guest_sce_net_tests (also confirmed by @popcoder565's Windows run); merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089990971 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1796#issuecomment-6089990971). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:02:12Z. --- Checked on Linux (GCC, merged onto current main): `guest_resolver` passes, and the new test fails to build without the change. Diff matches the description, TechnicalDebt line is in place, and the Windows link fix matches `guest_sce_net_tests` (also confirmed by @popcoder565's Windows run); merging.
github-actions[bot] commented 2026-10-09 22:14:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:14:34Z.


Progress report (d70b899 → c80bea9)

📈 System libraries: 84.7% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libScePosixForWebKit gethostbyname_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090141097 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1796#issuecomment-6090141097). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T22:14:34Z. --- <!-- progress-report --> ### Progress report (d70b899 → c80bea9) 📈 **System libraries**: 84.7% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libScePosixForWebKit | `gethostbyname_nid_postfix` | </details>
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!1796
No description provided.