Web lists-archives.org

Re: [Mingw-msys] MSYS and Windows XP x64




haibin zhang wrote:

> .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
Mingw-msys@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/mingw-msys