Opened 10 years ago

Last modified 3 years ago

#2675 closed defect

[PATCH] x86_x64.cpp fails to build with -fpie on i386 — at Version 2

Reported by: pstumpf Owned by:
Priority: Should Have Milestone: Alpha 18
Component: Core engine Keywords: patch
Cc: Patch:

Description (last modified by historic_bruno)

The cpuid assembler stuff does not compile when using PIE on i386 due to register constraints. One must save and restore the PIC register (%ebx) before and after the call. See also cpuid.h as provided by GCC or Clang.

In all other cases (amd64 and !PIE i386), use the regular code.

Compile and runtime tested on OpenBSD/i386, which uses -fpie by default.

  • x86_x64.cpp

     
    4949#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729
    5050// VC10+ and VC9 SP1: __cpuidex is already available
    5151#elif GCC_VERSION
     52# if defined(__i386__) && defined(__PIC__)
    5253# define __cpuidex(regsArray, level, index)\
     54       __asm__ __volatile__ ("pushl    %%ebx\n" \
     55       " cpuid\n"\
     56       "mov %%ebx,%1\n" \
     57       "popl %%ebx" \
     58       : "=a" ((regsArray)[0]), "=r" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\
     59       : "0" (level), "2" (index));
     60# else
     61# define __cpuidex(regsArray, level, index)\
    5362       __asm__ __volatile__ ("cpuid"\
    5463       : "=a" ((regsArray)[0]), "=b" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\
    5564       : "0" (level), "2" (index));
     65# endif
    5666#else
    5767# error "compiler not supported"
    5868#endif

Change History (3)

by pstumpf, 10 years ago

Attachment: diff added

comment:1 by Stan, 10 years ago

Keywords: unanswered added

comment:2 by historic_bruno, 10 years ago

Description: modified (diff)
Keywords: patch review added; unanswered removed
Milestone: BacklogAlpha 18
Summary: x86_x64.cpp fails to build with -fpie on i386[PATCH] x86_x64.cpp fails to build with -fpie on i386

Hi, please follow the instructions when submitting patches: SubmittingPatches

Note: See TracTickets for help on using tickets.