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

fix handling of cpuid and PIC on i386 systems #26

Closed
GoogleCodeExporter opened this issue Sep 10, 2015 · 5 comments
Closed

fix handling of cpuid and PIC on i386 systems #26

GoogleCodeExporter opened this issue Sep 10, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

the current cpuid logic clobbers %ebx.  this is OK if the code is not PIC, but 
if you're building PIEs, it'll fail because %ebx is the PIC register and gcc 
doesn't let you clobber it.

simple fix:
  int ax, bx, cx, dx;
  __asm__ __volatile__ (
      "mov %%ebx, %%edi;"
      "cpuid;"
      "mov %%ebx, %%esi;"
      "mov %%edi, %%ebx;"
      :"=a" (ax), "=S" (bx), "=c" (cx), "=d" (dx) : "a"(1) :"edi");

it's a few more insns on x86_64 or i386/non-pic, so if you want, you could do 
something like:
#if defined(STRESSAPPTEST_CPU_I686) && defined(__PIC__)
 ... do pic version here ...
#else
 ... do non-pic version here ...
#endif

Original issue reported on code.google.com by vapier@gmail.com on 27 Nov 2012 at 7:19

@GoogleCodeExporter
Copy link
Author

simpler patch:
http://sources.gentoo.org/dev-util/stressapptest/files/stressapptest-1.0.4-cpuid
-pic.patch

Original comment by vap...@google.com on 5 Jan 2013 at 7:32

@GoogleCodeExporter
Copy link
Author

The similar problem appears in worker.cc line 88.

Original comment by bruce3...@gmail.com on 6 Jan 2013 at 6:32

@GoogleCodeExporter
Copy link
Author

i've updated the patch in Gentoo to handle that file too

Original comment by vapier@chromium.org on 6 Jan 2013 at 7:21

@GoogleCodeExporter
Copy link
Author

Thanks a lot!

Original comment by bruce3...@gmail.com on 6 Jan 2013 at 7:25

@GoogleCodeExporter
Copy link
Author

I've imported vapier's patch. Should be fixed now.

Original comment by nsanders@google.com on 7 Jan 2013 at 10:14

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant