MinGW as 与 Linux as的一些微小差异

.globl cpuidfunc
.def .type cpuidfunc, @function; .enddef

ELF and PE/COFF are different platforms; they have different assembler
syntaxes. Just because they both use the GNU assembler and the intel
x86 architecture doesn’t mean you can feed ELF style assembly to a
PE/COFF gas and expect it to work. Example:

linux

$ echo “void a_function_definition () { }” | gcc -S -x c - -o -
.file “”
.text
.globl a_function_definition
.type a_function_definition, @function
a_function_definition:
pushl %ebp
movl %esp, %ebp
popl %ebp
ret
.size a_function_definition, .-a_function_definition
.ident “GCC: (GNU) 4.0.4 20060507 (prerelease) (Debian
4.0.3-3)”
.section .note.GNU-stack,”“,@progbits

cygwin

$ echo “void a_function_definition () { }” | gcc -S -x c - -o -
.file “”
.text
.globl _a_function_definition
.def _a_function_definition; .scl 2; .type 32;
.endef
_a_function_definition:
pushl %ebp
movl %esp, %ebp
popl %ebp
ret

See the difference? “.type foo, @funtion” is not valid PE/COFF syntax.
This is why most people use gcc’s inline asm() instead of writing direct
.s files, because it lets gcc do all the platform specific busywork
while you just write the relevant assembly parts.

Brian


This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/


Mingw-msys mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mingw-msys

来源: http://mingw.5.n7.nabble.com/Assemble-problem-in-Mingw32-binutils-2-17-50-20070129-1-tar-gz-td28323.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值