-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Allow running position-independent executables (PIE) #213
Comments
I just compiled memcached as "-pie" instead of "-shared", and the resulting exectuable seems to be working well in OSv (as well as in Linux, which is nice, because the ".so" can't run directly in Linux, but PIE does). Could it be that whatever problems we had with running PIEs were already solved? One thing to note, however, is that even for PIE, what we do is to run their main() function. Technically, this is probably not the right thing to do - I am guessing we need to jump to some fixed starting point, not find a function called "main". But I think the current state, of calling main() should be good enough for 99% of the use cases. So should we start using PIE instead of ".so", and after a bit more testing close this bug? |
I just changed the memcached and rogue modules to compile with "-pie" instead of "-shared", and they seem to be working fine. So I'm closing this bug which claims PIE don't work, and we should instead open new bugs on specific things which don't work, if and when we find those. |
TLS models may be a problem here. When an executable is linked local exec model is used. That will cause problems because there can be only one object using local exec model and that object is the kernel itself. There is |
On Fri, Jun 20, 2014 at 4:21 PM, Paweł Dziepak [email protected]
"The default without -fpic is "initial-exec"; with -fpic the default is And doesn't say anything about "-pie" changing this.... I have to admit that I'm not (enough) of a dynamic linker expert to
Nadav Har'El |
2014-06-20 22:43 GMT+02:00 nyh [email protected]:
Apparently, the manual is wrong. If an executable is produced initial-exec
#include thread_local int foo = 123; int main() Works with -shared -fpic, doesn't work with -pie (with neither -fpic nor
|
Actually, GCC manual states that:
So, it looks like combination -pie -fpic isn't really correct, but that doesn't changes much. (Well, my earlier accusation of GCC manual being wrong is not really valid). For -fpie we have:
This allows GCC to use local exec model. |
Hi Pawel, you're right about this TLS bug, I'll create a separate, specific On Fri, Jun 20, 2014 at 5:19 PM, Paweł Dziepak [email protected]
Do you have any idea how "-fpie" could possibly differ from "-fpic"?
|
On Sun, Jun 22, 2014 at 4:11 AM, Nadav Har'El [email protected]
I found a good (hopefully) explanation in
Nadav Har'El |
On Linux we can compile a position-independent executable (PIE) - see -pie, -fpie compiler option. We should have no problem running such executables on OSv, because they are position-independent so can be relocated just like shared objects. But, unfortunately, Avi tried and noticed we're still missing a few features for it to work.
This issue is half-way to #190 (which is about running a normal Linux executable): It will be simpler to implement, and will allow us to run the same executable on both Linux and OSv, but we will not be able to take any random Linux executable and run it (it will have to be an executable compiled as PIE).
The text was updated successfully, but these errors were encountered: