相关疑难解决方法(0)

Can't call C standard library function on 64-bit Linux from assembly (yasm) code

I have a function foo written in assembly and compiled with yasm and GCC on Linux (Ubuntu) 64-bit. It simply prints a message to stdout using puts(), here is how it looks:

bits 64

extern puts
global foo

section .data

message:
  db 'foo() called', 0

section .text

foo:
  push rbp
  mov rbp, rsp
  lea rdi, [rel message]
  call puts
  pop rbp
  ret
Run Code Online (Sandbox Code Playgroud)

It is called by a C program compiled with GCC:

extern void foo();

int main() {
    foo(); …
Run Code Online (Sandbox Code Playgroud)

c linux assembly x86-64 yasm

7
推荐指数
2
解决办法
276
查看次数

标签 统计

assembly ×1

c ×1

linux ×1

x86-64 ×1

yasm ×1