Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Unknown Directive .type func, @function

Tags:

assembly

.data
x: .long 2
r: .long 27

.text

.globl _start

_start:
        pushl x
        movl $0,%eax
        call func
        addl $4,%esp
        movl %eax,r
        movl r,%ebx
        movl $1,%eax
        int $0x80

.type func, @function
func:
        pushl %ebp
        movl %esp,%ebp
        movl 8(%ebp),%eax
        cmpl $0,%eax
        jle if
        jmp else
if:     movl %ebx,%eax
        jmp endif
else:   addl %eax,%ebx
        subl $1,%eax
        pushl %eax
        call func
        addl $4,%esp
endif:  movl %ebp,%esp
        popl %ebp
        ret

Above you see the program i am trying to run. I boiled it down to one last error which i can't seem to find the answer to. The error message sound as following:

test.s:19:1: error: unknown directive
.type func, @function
^

I compiled it on a Macintosh 10.9.1 using gcc -m32 test.s and ggc -c test.s. I browsed Google looking for answers, but i can't seem to find any. It is the AT&T syntax.

like image 689
Michael Nissen Avatar asked Jan 03 '14 16:01

Michael Nissen


1 Answers

This directive simply isn't used by the Mach-O assembler. It You should omit it. There are some other differences here.

like image 103
Brett Hale Avatar answered Nov 02 '22 18:11

Brett Hale