bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

c function call issue from assembly program


From: Arpan Man Sainju
Subject: c function call issue from assembly program
Date: Tue, 30 Aug 2022 23:42:22 -0500

Hello, 

I found this interesting issue in binutils v2.38. 
The following code works perfectly fine in ubuntu 20.04 (binutils v2.34)

content of asm_program.asm:
.global main

.text
main:
    mov $message, %rdi
    call c_function
    ret

.data
#where the message is stored
message: .ascii "Hello World\n\0"

content of c_function.c:
#include <stdio.h>
void c_function(const char* message)
{
    puts(message);
      return;
}

compilation code: 
$ as asm_program.asm -o asm_program.o
$ gcc -c c_function.c -o c_function.o
$gcc -no-pie asm_program.o c_function.o -o myprogram

Currently, this code is giving me a segmentation fault error in ubuntu 22.04 but works perfectly fine in ubuntu 20.04.

Regards,
Arpan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]