Fix asm() instruction consistency #2144
Merged
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.
Fix asm() instruction consistency
Expected Behaviour
When using either
asm()
with thevma
parameter or theELF.asm()
function with an instruction likenop
I expect it to write 1 byte0x90
at the specified position.Actual behaviour
Depending on the memory address specified (either as
vma
or as first parameter ofELF.asm()
) it will add paddingnop
bytes before the instruction. More specifically, if the address is not a multiple of 4 (address % 4 != 0
) it will add4 - (address % 4)
padding bytes making it sometimes hard to patch instructions smaller than 4 bytes.Example Script
Running this script will quickly demonstrate the effect
Output before changes
Output after changes
Testing
I was not able to start the whole test suite but I tried testing at least the
asm
part which doesn't start on only one architecture (it isn't failing, I'm missing some dependency).The Docker image also seems to fail to build at the
apt update
step.E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
This, therefore, might require at least someone who can run all the tests to test them again
(First time contributing to a project, I hope I did this right, I apologize if I made a mistake either choosing the wrong target branch or in the rest of the pull request)