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

Issue 13938 & 13939 - Disallow non-trivial variable accesses in iasm #4260

Merged
merged 2 commits into from Jan 11, 2015

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Jan 6, 2015

Issue 13938 - IASM shouldn't be able to access TLS variables
Issue 13939 - IASM shouldn't access global symbol with PIC code

@yebblies
Copy link
Member

yebblies commented Jan 6, 2015

Ok, but then how do you load the tls/got offset of the variable?

@9rnsr
Copy link
Contributor Author

9rnsr commented Jan 6, 2015

Isn't it platform dependent? A portable way is, first load the TLS in a local var, then access the local from iasm.

void main()
{
    static int val;
    int tmp = val;   // portable load
    asm { mov EAX, tmp;}
}

@9rnsr
Copy link
Contributor Author

9rnsr commented Jan 6, 2015

@MartinNowak In OSX platform, -fPIC is enabled by default. So all __gshared variables cannot be accessible from iasm code. Is it correct behavior?

@yebblies
Copy link
Member

yebblies commented Jan 6, 2015

I dunno, loading the variable outside the asm won't work in naked functions. Can we disable the obvious way, but still allow some way to do it?

https://issues.dlang.org/show_bug.cgi?id=7720

@MartinNowak
Copy link
Member

Ok, but then how do you load the tls/got offset of the variable?

Oh, I tried at some point, it wasn't possible because you need a special relocation for that (on i386 which doesn't support RIP relative addressing).

That might be a way to get it.
https://issues.dlang.org/show_bug.cgi?id=12085

@MartinNowak
Copy link
Member

@MartinNowak In OSX platform, -fPIC is enabled by default. So all __gshared variables cannot be accessible from iasm code. Is it correct behavior?

That might a bit too harsh, I commented on the tickets.

@MartinNowak
Copy link
Member

Ultimatively I think it's the right choice to disable them (see Issue 9378 unless we add a more features to the IASM (like emitting relocations).

WalterBright added a commit that referenced this pull request Jan 11, 2015
Issue 13938 & 13939 - Disallow non-trivial variable accesses in iasm
@WalterBright WalterBright merged commit 756cda4 into dlang:master Jan 11, 2015
@9rnsr 9rnsr deleted the fix_iasm branch January 11, 2015 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants