Open
Conversation
Update memory-layout and calling-convention reading materials to correctly reflect the 64-bit System V AMD64 ABI. Add the missing `xor rax, rax` before variadic function calls and convert 32-bit stack argument examples to 64-bit register arguments. Fix #141 Signed-off-by: alexf05 <alexfechet16@gmail.com>
Correct multiple issues introduced during the x86_64 transition: - max-c-calls: Fix signedness comparison by using `jae` and fix pointer initialization bug in the solution. Revert support file. - regs-preserve: Add required 16-byte stack alignment before calling printf and fix the order of stack restoration in the solution. Fix #141 Signed-off-by: alexf05 <alexfechet16@gmail.com>
Signed-off-by: alexf05 <alexfechet16@gmail.com>
This file contains hidden or 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
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.
Prerequisite Checklist
Description of changes
This PR resolves the remaining bugs, ABI violations, and typos from the x86_64 transition in
lab-09.Specific fixes include:
raxfor variadic functions likeprintfand updating 32-bit stack argument examples to 64-bit register arguments).max-c-calls: Fixed a logical bug by changing the signed comparison (jge) to unsigned (jae). Fixed pointer initialization in the solution.regs-preserve: Added the required 16-byte stack alignment (sub rsp, 8) to the support code before callingprintfto prevent immediate segfaults. Corrected the stack restoration order (pop rbxvsadd rsp, 8) in the solution.Question for Reviewer (@teodutu): I noticed that the
max-c-calls-x86task currently contains 64-bit code instead of 32-bit, and themax-assembly-calls-x86task is missingadd esp, Xstack cleanups for thecdeclcalling convention. Should I convert these files back to proper 32-bit assembly in a follow-up commit, or are these x86 legacy folders planned for deletion?Fix #141