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

Various ASM PIC issues... #1156

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

Various ASM PIC issues... #1156

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: don't know
Reported for operating system, platform: Other, x86

Comments on the original bug report:

On 2006-01-03 12:03:28 +0000, Ryan C. Gordon wrote:

From: Mike Frysinger vapier@gentoo.org
To: sdl@libsdl.org
Date: Thu, 29 Sep 2005 05:57:04 -0400
Subject: [SDL] clean up some of the PIC issues in libSDL asm

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, running readelf -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

On 2006-01-03 12:03:57 +0000, Ryan C. Gordon wrote:

Created attachment 10
no-exec-stack

On 2006-01-03 12:04:18 +0000, Ryan C. Gordon wrote:

Created attachment 11
hermes-call-dont-jump

On 2006-01-03 12:04:33 +0000, Ryan C. Gordon wrote:

Created attachment 12
hermes-cpuid

On 2006-01-03 12:05:00 +0000, Ryan C. Gordon wrote:

Created attachment 13
load-mmx-masks-from-stack

On 2006-01-03 12:05:57 +0000, Ryan C. Gordon wrote:

Please note that some (or all?) of these might have been applied to CVS, and some (or all?) might have been declared broken by Mike later on. Please follow up with Mike before committing!

--ryan.

On 2006-01-03 12:07:14 +0000, Ryan C. Gordon wrote:

Created attachment 14
SDL_stretch-PIC

On 2006-01-04 22:17:43 +0000, Mike Frysinger wrote:

Comment on attachment 10
no-exec-stack

this has been committed

On 2006-01-04 22:19:02 +0000, Mike Frysinger wrote:

Comment on attachment 12
hermes-cpuid

this hermes-cpuid patch is still applicable

On 2006-01-04 22:19:23 +0000, Mike Frysinger wrote:

Comment on attachment 14
SDL_stretch-PIC

this SDL_stretch change is safe and still applicable

On 2006-01-04 22:19:46 +0000, Mike Frysinger wrote:

Comment on attachment 13
load-mmx-masks-from-stack

this load mmx masks is safe and still applicable

On 2006-01-04 22:20:24 +0000, Mike Frysinger wrote:

Comment on attachment 11
hermes-call-dont-jump

i would put this on hold as it can be solved with just a few lines of code once ELF visibility is added to nasm, so i wouldnt bother changing it now

On 2006-01-05 02:09:36 +0000, Ryan C. Gordon wrote:

hermes-cpuid is in CVS.

--ryan.

On 2006-01-05 02:13:17 +0000, Ryan C. Gordon wrote:

Comment on attachment 12
hermes-cpuid

(Tagging cpuid patch as obsolete so I know it's done with.)

--ryan.

On 2006-01-05 02:20:37 +0000, Ryan C. Gordon wrote:

Comment on attachment 14
SDL_stretch-PIC

SDL_stretch patch is in CVS now.

--ryan.

On 2006-01-05 02:26:09 +0000, Ryan C. Gordon wrote:

Mike,

In the mmx-masks-from-stack patch:

Why was this a problem:
movq mm6, qword [mmx32_rgb888_mask]

But this one in _ConvertMMXpII32_16RGB555 wasn't:
movq mm7,qword [mmx32_rgb555_mul]

(and a few others)

--ryan.

On 2006-01-05 09:35:35 +0000, Mike Frysinger wrote:

Created attachment 17
libsdl-1.2.9-PIC-load-mmx-masks-from-stack.patch

hrm, it looks like in my original e-mail i attached two patches named the samething ... the first one was incomplete and is the one you see here

here is the "full" version :)

On 2006-01-05 10:25:48 +0000, Ryan C. Gordon wrote:

Comment on attachment 17
libsdl-1.2.9-PIC-load-mmx-masks-from-stack.patch

MMX patch is in CVS now.

--ryan.

On 2006-01-05 10:26:17 +0000, Ryan C. Gordon wrote:

Look at that, we're out of patches! :)

I'm resolving this bug now.

Thanks, Mike!

--ryan.

On 2006-01-05 10:54:34 +0000, Mike Frysinger wrote:

awesome ... i'll file a new bug for the other issue once i can get the nasm guys to wake up

On 2006-01-27 11:23:03 +0000, Ryan C. Gordon wrote:

Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

On 2007-03-19 15:19:55 +0000, Ryan C. Gordon wrote:

*** Bug 418 has been marked as a duplicate of this bug. ***

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

No branches or pull requests

1 participant