Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22079

Creating main-Function using gcc in x86-Assembly [duplicate]

$
0
0

Following code:

.intel_syntax noprefix.text .global _start_start:  ret

compiles using GCC: gcc -o main -nostartfiles -nostdlib main.SBut this does throw a memory-access-error when calling ./main

So I thought - maybe Stack-Alignment:

.intel_syntax noprefix.text .global _start_start:  sub rsp, 8  ret

This code also compiles using the same flags.However, this code does never return.

So how do I create a main()-Assembly-Procedure using Gcc?

This, however, works:

.intel_syntax noprefix.text .global _start_start:    mov rax, 60 ;Linux Syscall: exit()    mov rdi, 13    syscall

Are there any workarounds, so calling ret would suffice?


Viewing all articles
Browse latest Browse all 22079

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>