Question

I found "hello world" and wrote it. nano hello.s

this code

.data
msg:
.string  "Hello, world!\n"
len = . - msg
.text
global _start
_start:
    movl    $len,%edx
    movl    $msg,%ecx
    movl    $1,%ebx
    movl    $4,%eax
    int     $0x80
    movl    $0,%ebx
    movl    $1,%eax
    int     $0x80

I've done as -o hello.o hello.s I've given an error

hello.s:6: Error: no such instruction: global _start

delete global _start.

I've done

ld -s -o hello.o hello*

error 

ld: hello: No such file: No such file or directory

Where am I mistaking?

p/s debian, amd64.

Was it helpful?

Solution

Try .globl _start or .global _start.

You may try ununderscored start in case you run into a problem with the entry point.

Finally, if you're making a 64-bit executable, you probably need to use a different system call interface, not int 0x80 but syscall. More on that here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top