fix init, fix macOS globals, add macOS args, add args + parse_int example #11
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.
Just a bunch of changes that came up while adding Callisto to my tak repo.
rsp
was being saved torsi
inside of__init
instead of outside. This caused two issues. Linux libcargv
handling was broken becausersi
was overwritten before__x86_64_program_init
, and Linux no-libcargv
handling was broken becausersi
was off by 8 bytes because of the__init
return address.Because
__x86_64_program_init
is inlined anyway, I just removed the saved stack pointer and accounted for the offset manually. The alternative would be to save the stack pointer beforecall __init
, but a different register would need to be used to avoid the first issue.Marked macOS core as supporting
Args
feature (implemented in std PR).Fixed globals failing to assemble on macOS due to use of absolute addressing.
Most of this is accomplished with
default rel
, which tells NASM to use RIP-relative addressing wherever possible, but I also had to manually fixCompileAddr
to generatelea + mov
instead of justmov
. This works fine on Linux too.Added
add_args
example. This is basically the program I used while testingArgs
on macOS and theparse_int
function, and I figured it was a nice example to have.