linker: join all data sections into one #265
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when using musl's stdio handles (stdin, stdout and stderr), the linker generates additional data sections for their data.
However, (likely) due to the custom linker script, those new data sections' file data isn't loaded, causing it to be zero and breaking the handles. For example, stdout's fd becomes 0.
This patch changes the linker script to tell the linker to join all sections starting with
.data
into one, except for.data.sce_process_param
and.data.rel.ro
.This fixes outputting data to stdout (with printf and all) with musl, along with C++'s iostream.
NOTE: C++ samples aren't working with LLVM 18 (should be from something unrelated), but 16 and 17 are working fine.
You can test this by building and running the graphics sample. You should see some strings originating from it.
Here's a comparison of readelf's output of an eboot.bin before this patch:
And after patching:
Tested on a base PS4, FW 9.00 and (a slightly customized) MiraHEN.