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

How to change the start/main entrypoint of x86-64 assembly with NASM?

$
0
0

I have this:

$ make buildread.o: In function `_start':read.asm:(.text+0x0): multiple definition of `_start'/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':(.text+0x20): undefined reference to `main'collect2: error: ld returned 1 exit statusMakefile:3: recipe for target 'build' failedmake: *** [build] Error 1

From this asm:

global mainsection   .textmain:   mov       rax, 1                  ; system call for write          mov       rdi, 1                  ; file handle 1 is stdout          mov       rsi, message            ; address of string to output          mov       rdx, 13                 ; number of bytes          syscall                           ; invoke operating system to do the write          mov       rax, 60                 ; system call for exit          xor       rdi, rdi                ; exit code 0          syscall                           ; invoke operating system to exitsection   .datamessage:  db        "Hello, World", 10      ; note the newline at the end

I am running it with this:

$ nasm -felf64 read.asm -o read.o && gcc read.o -o store && ./store

How do I change the word main to something other than main or _start, such as begin or myentrypoint? I would like to customize it. Can it even be customized?


Viewing all articles
Browse latest Browse all 22137

Trending Articles



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