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

猜你喜欢

转载自blog.csdn.net/wenshifang/article/details/68489813