the assembly used in some parts of libSDL arent very PIC friendly thus causing
some ugly TEXTREL’s in the final library … the PaX team has put together a
bunch of fixes which i’m forwarding (along with some test cases to show that
the code is sane) … there may be a little conflict between these patches,
but hopefully not
-
libsdl-SDL_stretch-PIC.patch
ignoring the general fact of how SDL_stretch relies on executing dynamic code,
the inline asm should let gcc handle the a details for getting the actual
address for _copy_row as it will do the right thing
test case: http://dev.gentoo.org/~vapier/libsdl/sdl-stretch.tar.bz2 -
libsdl-no-exec-stack.patch
this makes sure that the nasm code declares itself as not needing executable
stacks. if GNU stack is not found in assembly files, binutils assumes that
it requires a read/write/executable stack. before the patch, runningreadelf -l libSDL.so
would show a GNU_STACK program header marked as RWE … after
the patch, the GNU_STACK should be marked as just RW. -
libsdl-PIC-hermes-cpuid.patch
rewrites the code in _Hermes_X86_CPU so that it doesnt require the local
cpu_flags memory variable, it just uses registers.
test case: http://dev.gentoo.org/~vapier/libsdl/hermes-cpuid-test.tar.bz2 -
libsdl-PIC-hermes-call-dont-jump.patch
call, dont jmp, with _mmxreturn and _x86return labels. if you try to jmp to
them, nasm will generate relocations which ld is unable to resolve while
linking, so the resulting library will contain a ton of TEXTREL’s (one per
jmp pretty much). simply calling and returning in a normal function fashion
resolves this. no test case as i’m not well versed enough in SDL to put
together a comprehensive one … but it does compile and my games dont
segfault -
libsdl-PIC-load-mmx-masks-from-stack.patch
this one may be a little controversial … the fix here is again that you cant
reference the memory addresses like this to load into a mmx register, so the
way to do it is to push two 32bit words onto the stack, load the 64bit value
off of the stack into the mmx register, and then adjust the stack so that
it’s back to normal.
-mike
-------------- next part --------------
A non-text attachment was scrubbed…
Name: libsdl-PIC-hermes-cpuid.patch
Type: text/x-diff
Size: 405 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050929/9098f15e/attachment.patch
-------------- next part --------------
A non-text attachment was scrubbed…
Name: libsdl-SDL_stretch-PIC.patch
Type: text/x-diff
Size: 639 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050929/9098f15e/attachment-0001.patch
-------------- next part --------------
A non-text attachment was scrubbed…
Name: libsdl-PIC-hermes-call-dont-jump.patch
Type: text/x-diff
Size: 4868 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050929/9098f15e/attachment-0002.patch
-------------- next part --------------
A non-text attachment was scrubbed…
Name: libsdl-PIC-load-mmx-masks-from-stack.patch
Type: text/x-diff
Size: 1803 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050929/9098f15e/attachment-0003.patch
-------------- next part --------------
A non-text attachment was scrubbed…
Name: libsdl-PIC-load-mmx-masks-from-stack.patch
Type: text/x-diff
Size: 4184 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050929/9098f15e/attachment-0004.patch