uninitialize glo" /> uninitialize glo" /> uninitialize glo"/>

Why the call to 32 bit syscall write work if i generate 64 bits object using GNU "as" command?

27 Views Asked by At

I am trying to find out that why when I use the command "as --64" with this assembly code it works?

# see the memory layout
# .bss -> uninitialize global data
.section .bss

# .data -> initialize global data
.section .data
  msg:
      .ascii "Hello World\n"
# .text -> code instruction is here (different from the stack)
# le label _start est le point d'entré de notre programme
.section .text
.globl _start
_start:
        movl $4,   %eax # 4 is for the write syscall on my machine
        movl $1,   %ebx # file descriptor
        movl $msg, %ecx # ptr of the first letter 'H'
        movl $13,  %edx # size of the mesh buffer
        int $0x80 # interruption call

        movl $1, %eax # 4 is for the exit syscall on my machine
        movl $0, %ebx # 0 is the argument of the exist call  like return 0
        int $0x80 # interruption call
# "sudo find /usr/include -name unistd_32.h" pour rechercher unistd_32.h..
# "cat /usr/include/x86_64-linux-gnu/asm/unistd_32.h" to see what is the number of the write syscall used by computer.... (used by print in c ...)

Because I am using the syscall "4" which is the syscall for write function on a 32bits system and I am generating a 64 bits object with the command "as --64" ?

Note : I am using Linux Ubuntu distribution / 64 bits system

ChatGPT could not help me

0

There are 0 best solutions below