In order for a program to run successfully, it needs two things: an entry symbol, and a return code that represents that success. The following program provides those two things.
.global _start _start: MOV X0, #0 MOV X8, #93 SVC 0
Compile it using the simple Makefile from the previous article.
The symbol _start is a special symbol expected by the linker. If you try to rename like this…….
.global _ADAM _ADAM: MOV X0, #0 MOV X8, #93 SVC 0
…you get the following error:
$ make other as -o other.o other.s ld -o other other.o ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078
Which will still compile and run.
If you leave off the three assembly instructions at the end, you do not return 0 indicating the program success.
.global _start _start:
That gives you this error:]$ ./bad_return -bash: ./bad_return: cannot execute binary file: Exec format error
To be honest, there are no instruction in the code, and I think that is a different problem. If we skip executing the function to send the return code:
.global _start _start: MOV X0, #0 MOV X8, #93
That gives this error when run:
$ ./bad_return Illegal instruction (core dumped)