| Summary: | [patch] PIC support in Hermes | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Sam Lantinga <slouken> |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | codepro, vapier |
| Version: | don't know | ||
| Hardware: | x86 | ||
| OS: | All | ||
| URL: | http://dev.gentoo.org/~vapier/patches/nasm-elf-visibility.patch | ||
| Attachments: |
libsdl-PIC-hermes-call-dont-jump.patch
libsdl-hidden-nasm.patch |
||
|
Description
Sam Lantinga
2006-03-08 01:10:32 UTC
Created attachment 82 [details]
libsdl-PIC-hermes-call-dont-jump.patch
I think the proper way to resolve these TEXTREL problems is to apply the libsdl-PIC-hermes-call-dont-jump.patch mentioned on the list. This will get rid of the _mmxreturn and and _x86return labels, period. Using jumps in those cases serves no real purpose from the optimizations' point of view -- saving and reloading the return address from the stack is so cheap compared to other operations inside the loop.
maybe, but it's even cheaper to not even touch the stack (In reply to comment #0) > Date: Tue, 7 Mar 2006 02:05:09 -0500 > From: Mike Frysinger <vapier@gentoo.org> > Subject: Re: [SDL] [patch] PIC support in Hermes > > On Wednesday 01 March 2006 19:32, Mike Frysinger wrote: > > rather than doing all the funky stuff with PIC, just mark all the symbols > > hidden ... then you dont have to change anything else ... > > you can find my patch to add elf visibility support to nasm here: > http://dev.gentoo.org/~vapier/patches/nasm-elf-visibility.patch > > then simply add 'hidden' to the decl: > GLOBAL _mmxreturn:function hidden Can you explain to me how this fixes the problem? Doesn't the address still have to be relocated at object load? > Doesn't the address still have to be relocated at object load?
it doesnt ... that's the magic part :)
default visibility means the symbol is exported and usuable by any external program ... so currently, people could declare an extern '_mmxreturn' function in their code and then call that location (even though it'd prob crash horribly)
but since the symbol is exported, the actual address wont really be known until load time so all of the absolute references need to be fixed up at runtime
if the symbol is marked as hidden, the linker will know that the symbol is not supposed to be exported and can rewrite all references to it at link time so that it no longer exists ... so all of the 'jmp _mmxreturn' lines get rewritten with relative jump's ... thus there's nothing left to fixup at runtime
the other nice benefit is you shrink the exported symbol table a little bit so there's less symbols to process at runtime ... all such private non-static SDL functions could benefit from being marked hidden
Created attachment 132 [details] libsdl-hidden-nasm.patch here's the patch i posted here: http://www.libsdl.org/pipermail/sdl/2006-March/073618.html this will hide the symbols dynamically if the build nasm/yasm supports the hidden stuff ... in other words, this patch should be safe with both older and new versions of nasm/yasm This is in subversion, thanks! I tweaked the patch slightly to handle older versions of nasm, which don't support :function syntax on Win32. erm, sorry, but i forgot to update the patch here ... the file "common.asm" needs to be renamed to "common.inc" otherwise the build system will try and compile it into the library: SOURCES="$SOURCES $srcdir/src/hermes/*.asm" Got it, thanks! |