fix(libc): count call trace offsets from the first page of a non-PIE executable #8974

Merged
rooklz merged 1 commit from upstream-pr/8974 into main 2026-10-22 02:24:58 +00:00
rooklz commented 2026-10-21 08:00:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T08:00:09Z.


What

On Linux the call trace (APS5_TRACE_CALLS) names a caller as module+offset, with the offset taken from dlpi_addr. For a non-PIE image dlpi_addr is 0, so a caller in an executable converted with --linux-fixed-base is printed with its absolute address, app.elf+0x402716, while the same caller in a PIE output is printed as app.elf+0x2716.

Each module's base is now its lowest PT_LOAD page (dlpi_addr plus the first segment's page-aligned vaddr), which is where dladdr puts dli_fbase. Nothing changes for a PIE executable or library whose first segment starts at 0. For an executable placed at a fixed base the offset is counted from that base, so it is again the caller's virtual address in the input executable, and it matches how the Windows report counts from the image base.

This becomes the usual case with #8973, which places Linux executables at 0x400000 by default; the two PRs don't depend on each other.

guest_call_trace_fixed_base_abort builds GuestCallTrace.cpp once more as a non-PIE executable, the way guest_dynamic_loader_fixed_base does, and checks that the abort report names the caller with an offset inside the image rather than its absolute address.

Tested

  • Ubuntu 24.04 x86-64 container (GCC 13.3), full build: guest_call_trace_fixed_base_abort fails on main, where the caller is printed as guest_call_trace_fixed_base_tests+0x402716, and passes with the change (+0x2716). guest_call_trace, guest_call_trace_abort and guest_call_trace_abort_race pass before and after; the PIE test's caller is still printed as guest_call_trace_tests+0x2734.
  • Ubuntu 24.04 x86-64 (GitHub-hosted runner), GCC 13.3, full build with the CI configure flags, run on my fork for this branch and its base a07e985c8: the four guest_call_trace* tests pass, and the rest matches the base apart from agc_driver_sgpr_pattern_fill_keys, which failed on the branch run only ("the dispatch completed 17 times without a pending write over the keys"). That AGC check is intermittent under parallel ctest (#8708) and failed on both sides of an earlier run of mine on another base. The three net_dontwait_blocking_* tests fail on both.
  • Windows is not affected: the module map is built only on Linux, and Windows names callers through CrashReport.cpp.
  • check_conventions.py passes.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4948347179 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8974). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T08:00:09Z. --- ### What On Linux the call trace (`APS5_TRACE_CALLS`) names a caller as `module+offset`, with the offset taken from `dlpi_addr`. For a non-PIE image `dlpi_addr` is 0, so a caller in an executable converted with `--linux-fixed-base` is printed with its absolute address, `app.elf+0x402716`, while the same caller in a PIE output is printed as `app.elf+0x2716`. Each module's base is now its lowest `PT_LOAD` page (`dlpi_addr` plus the first segment's page-aligned vaddr), which is where `dladdr` puts `dli_fbase`. Nothing changes for a PIE executable or library whose first segment starts at 0. For an executable placed at a fixed base the offset is counted from that base, so it is again the caller's virtual address in the input executable, and it matches how the Windows report counts from the image base. This becomes the usual case with #8973, which places Linux executables at `0x400000` by default; the two PRs don't depend on each other. `guest_call_trace_fixed_base_abort` builds `GuestCallTrace.cpp` once more as a non-PIE executable, the way `guest_dynamic_loader_fixed_base` does, and checks that the abort report names the caller with an offset inside the image rather than its absolute address. ### Tested - Ubuntu 24.04 x86-64 container (GCC 13.3), full build: `guest_call_trace_fixed_base_abort` fails on `main`, where the caller is printed as `guest_call_trace_fixed_base_tests+0x402716`, and passes with the change (`+0x2716`). `guest_call_trace`, `guest_call_trace_abort` and `guest_call_trace_abort_race` pass before and after; the PIE test's caller is still printed as `guest_call_trace_tests+0x2734`. - Ubuntu 24.04 x86-64 (GitHub-hosted runner), GCC 13.3, full build with the CI configure flags, run on my fork for this branch and its base `a07e985c8`: the four `guest_call_trace*` tests pass, and the rest matches the base apart from `agc_driver_sgpr_pattern_fill_keys`, which failed on the branch run only ("the dispatch completed 17 times without a pending write over the keys"). That AGC check is intermittent under parallel ctest (#8708) and failed on both sides of an earlier run of mine on another base. The three `net_dontwait_blocking_*` tests fail on both. - Windows is not affected: the module map is built only on Linux, and Windows names callers through `CrashReport.cpp`. - `check_conventions.py` passes. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
github-actions[bot] commented 2026-10-21 08:21:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-21T08:21:54Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 9439 core/libs/prx/libc/src/specifics/x86_64/CallTrace.cpp L18

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3965 core/libs/prx/libc/CMakeLists.txt
PR 4627 core/libs/prx/libc/CMakeLists.txt
PR 5021 core/libs/prx/libc/CMakeLists.txt
PR 6044 core/libs/prx/libc/CMakeLists.txt
PR 7081 core/libs/prx/libc/CMakeLists.txt
PR 7201 core/libs/prx/libc/CMakeLists.txt
PR 7715 core/libs/prx/libc/CMakeLists.txt
PR 8150 core/libs/prx/libc/CMakeLists.txt
PR 8965 core/libs/prx/libc/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6311450684 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8974#issuecomment-6311450684). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-21T08:21:54Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 9439](https://www.github.com/boykopovar/AnyPS5/pull/9439) | `core/libs/prx/libc/src/specifics/x86_64/CallTrace.cpp` [L18](https://github.com/boykopovar/AnyPS5/blob/a6dcea9279b53b3a39c13695eac66f7c8b5b503c/core/libs/prx/libc/src/specifics/x86_64/CallTrace.cpp#L18) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 3965](https://www.github.com/boykopovar/AnyPS5/pull/3965) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 4627](https://www.github.com/boykopovar/AnyPS5/pull/4627) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7081](https://www.github.com/boykopovar/AnyPS5/pull/7081) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 7715](https://www.github.com/boykopovar/AnyPS5/pull/7715) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 8150](https://www.github.com/boykopovar/AnyPS5/pull/8150) | `core/libs/prx/libc/CMakeLists.txt` | | [PR 8965](https://www.github.com/boykopovar/AnyPS5/pull/8965) | `core/libs/prx/libc/CMakeLists.txt` |
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!8974
No description provided.