irx.h: make IRX import/export tables work when built with clang #15

Merged
techwritescode merged 1 commit from llvm-irx-tables into main 2026-10-12 04:45:42 +00:00

With LLVM, DECLARE_IMPORT_TABLE and DECLARE_EXPORT_TABLE put the table header in a section literally named .text\n\t# (GNU as treats it as .text plus a comment). That section is not part of the loaded image, so the module's imports were never linked and RegisterLibraryEntries returned garbage.

Under __clang__ the headers are now written as assembly in .text, in order with the stubs and pointers. GCC output is unchanged.

Needs LLVM PR ps2/llvm#4 and the -mllvm -mips-split-hi16 IOP flag for the module to be IRX1. Verified with a clean-SDK build: iomanX, fileXio, usbd, bdm, bdmfs_fatfs and usbmass_bd built with LLVM load in PCSX2 and the std::filesystem example passes (0 failures).

🤖 Generated with Claude Code

With LLVM, `DECLARE_IMPORT_TABLE` and `DECLARE_EXPORT_TABLE` put the table header in a section literally named `.text\n\t#` (GNU as treats it as `.text` plus a comment). That section is not part of the loaded image, so the module's imports were never linked and `RegisterLibraryEntries` returned garbage. Under `__clang__` the headers are now written as assembly in `.text`, in order with the stubs and pointers. GCC output is unchanged. Needs LLVM PR ps2/llvm#4 and the `-mllvm -mips-split-hi16` IOP flag for the module to be IRX1. Verified with a clean-SDK build: iomanX, fileXio, usbd, bdm, bdmfs_fatfs and usbmass_bd built with LLVM load in PCSX2 and the std::filesystem example passes (0 failures). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
irx.h: define import and export table headers in assembly under clang
All checks were successful
Build / build (pull_request) Successful in 44s
Build / build (push) Successful in 26s
7006dffcbe
The GNU assembler reads section(".text\n\t#") as .text followed by a comment.
Clang takes it literally and puts each table header in a section named
".text\n\t#", outside the loaded image and away from the stubs and function
pointers that follow it, so the loader never linked the module's imports.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
techwritescode deleted branch llvm-irx-tables 2026-10-12 04:45:42 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
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.

Dependencies

No dependencies set

Reference
ps2/sdk-core!15
No description provided.