G***m 发帖数: 55 | 1 I'm writing some code which needs to call assembly function in C++ code.
it works fine under windows, however, it does not work under linux, i googled
lot, could not figure out the problem, can anybody help me out of this.
Here is the code.
// header file a.h
#define __ASM_NAME(name) "_" name
#define __ASM_TYPE(name) ".type " __ASM_NAME(#name) ",@function\n"
#define __ASM_GLOBAL_FUNC(name,code) \
__asm__( ".align 4\n\t" \
".globl " __ASM_NAME(#name) "\n\t" \
| t****t 发帖数: 6806 | 2 Sorry I can't write chinese.
This is most probably name inconsistent problem, including c++ name mangling
and assembly naming convention.
It seems in your original "windows" program, you used __ASM_NAME to write
name, which is just put underscore before name. This is traditional and you
said it worked. I am not very sure about windows executable naming convention,
but I heard it does use this prefix underscore. Seems there's no c++ name
mangling problem here, did you put extern "C" {} around you
【在 G***m 的大作中提到】 : I'm writing some code which needs to call assembly function in C++ code. : it works fine under windows, however, it does not work under linux, i googled : lot, could not figure out the problem, can anybody help me out of this. : Here is the code. : // header file a.h : #define __ASM_NAME(name) "_" name : #define __ASM_TYPE(name) ".type " __ASM_NAME(#name) ",@function\n" : #define __ASM_GLOBAL_FUNC(name,code) \ : __asm__( ".align 4\n\t" \ : ".globl " __ASM_NAME(#name) "\n\t" \
|
|