Gcc inlined assembler address jmp; Bare functions

I can use jmp for the address using Visual Studio 2012. When it comes to gcc / mingw, I can't tell if my transition works correctly.

How can I go to an address in gcc?

I tried:

__declspec(naked) void DXHook_D3DPERF_BeginEvent()
{
    #ifdef _MSC_VER  //If using visual studio..
    __asm{jmp[Addr]} //Jump to: Address stored in Addr.
    #else            //else using gcc..
    __asm("jmp *%0"
          : /*No Outputs*/
          : "r" (Addr)
          : "%eax");
    #endif
}

It is right? Also, is there a way to make gcc stop bothering me:

warning: 'naked' attribute directive ignored.

Why does he ignore my bare attribute?

+1
source share
2 answers

TL DR In GCC, it is only available for: ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU

It is NOT available on x86 .

Workaround (suggested by Brandon in the comments) .

( , )

, Windows, __declspec GCC.

MSDN __declspec:

Microsoft C ++.

GCC.

GCC:

. Windows GCC - , __declspec (dllexport) void (* foo) (void) void (__declspec (dllexport) * foo) (void) - GCC.

, , __declspec GCC ( ).

, __declspec, GCC, __declspec(dllexport) ( GCC ).

, , GCC

( ) , , . , . ,

 __attribute__((noreturn)) void d0 (void),
     __attribute__((format(printf, 1, 2))) d1 (const char *, ...),
      d2 (void)

noreturn ; format d1.

, :

#ifdef __GNUC__
#define ATTRIBUTE_NAKED __attribute__((naked))
#else
#define ATTRIBUTE_NAKED __declspec(naked)
#endif

ATTRIBUTE_NAKED void DXHook_D3DPERF_BeginEvent()
{
    #ifdef _MSC_VER  //If using visual studio..
    __asm{jmp[Addr]} //Jump to: Address stored in Addr.
    #else            //else using gcc..
    __asm("jmp *%0"
          : /*No Outputs*/
          : "r" (Addr)
          : "%eax");
    #endif
}

Edit:

, . :

ARM, AVR, MCORE, MSP430, NDS32, RL78, RX SPU. , - . /, . asm (. Basic Asm). asm asm C , , , .

GCC .

clang ( , GCC), , , GCC.

+1

Visual ++, , ( ) asm.

0

All Articles