-
-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace strings in ELF .rodata sections #1344
Open
ahgamut
wants to merge
8
commits into
jart:master
Choose a base branch
from
ahgamut:rename-str
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
replacement string needs one more byte also
ahgamut
added a commit
to ahgamut/superconfigure
that referenced
this pull request
Jan 11, 2025
jart/cosmopolitan#1344 the renamestr program written in the above PR means the build process for binaries in superconfigure does not require the existence of /zip or equivalent folder as an absolute path to copy necessary assets. we build the binaries setting $COSMOS as the target folder for all files and then patch the .rodata section in the debug binaries right before running apelink (actually, we run apelink with copies of the binaries so that the originals can be used like regular ELF binaries installed on a traditional Linux system.) Now, assuming binfmt_misc details are satisfied, we should be able to build software without needing sudo. /zip was needed in the build configuration of packages because it was (at the time) the only way to ensure the final APE binary had correct locations for reading assets. But /zip had several side effects: need of sudo for creating the folder, COSMOPOLITAN_DISABLE_ZIPOS=1 for all steps of superconfigure, debug binaries were difficult to use in case we needed to fix a bug, some build flakes due to builds writing files to the same subfolder of /zip, et cetera. Now, the build procedure of superconfigure should (ideally) result in ELF binaries installed from using cosmocc, and the /zip features are activated right when the fat binary is created, which means finding errors is far more streamlined
jart
reviewed
Jan 12, 2025
also use a string struct
if the string to replace is at the absolute end of the .rodata section, it may not have a null terminating byte. In that case alone, we replace one less byte than earlier, so as to avoid overwriting some other data.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
With
tool/build/renamestr
(or an equivalent feature), I hope to avoid the/zip
folder when building binaries with https://github.com/ahgamut/superconfigure. Most of the folder locations involving/zip
are stored in the.rodata
section of the ELF binary, and/zip
is more useful for the APE than the debug ELF binaries.The current build process on
superconfigure
involves:/zip
folder using sudoterminfo
entries, SSL certs) is copied to/zip
/zip
folder (or crash)With this PR, the build process hopefully becomes:
/zip
folder with sudo$LOCATION/superconfigure/cosmos/$ARCH/$SUBFOLDER
)renamestr
on the ELF binary to replace$LOCATION/superconfigure/cosmos/$ARCH/
to/zip
, before runningapelink
Perhaps this feature can be part of
apelink
itself (the structure and some code ofrenamestr
is copied fromapelink
), but I wrote a separate tool in a draft PR, for an initial exploration.