Skip to content
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

macho: Pass sections by pointer when slicing names #12175

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

topolarity
Copy link
Contributor

@topolarity topolarity commented Jul 20, 2022

Thought these were fishy in the debug(link) logs:

debug(link): putting section ' ,@"���' as an Atom
debug(link): putting section ' ,@"����' as an Atom
...
debug(link):  ,81���� => size: 0x18, alignment: 0x3
debug(link):  ,81��� => size: 0x980, alignment: 0x4
... etc.

Turns out, we were accidentally returning a pointer to a parameter - Stage 1 just happened to pass the parameter by reference.

stage3/bin/zig build-exe test3.zig -target x86_64-macos-none works on my machine now.

One more stepping stone for #12111

We were accidentally returning a pointer to stack memory, because these
arguments were passed by value. It's just an accident that stage 1 was
passing these by reference, so things were alright until stage 3.
@andrewrk andrewrk merged commit de62bd0 into ziglang:master Jul 20, 2022
@andrewrk
Copy link
Member

Nice find! I think an important language goal will be having safety for this kind of problem. Possibly by changing aliasing rules and possibly by doing something along the lines of #3180 (comment).

@topolarity topolarity deleted the macho-fix branch July 20, 2022 14:19
@topolarity
Copy link
Contributor Author

Big +1

I have some other crazy ideas in the space I want to try out at some point - Looking forward to the experimental phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants