So , I am trying to implement a program where it will use a variable declared in other source file. The book I am reading stated that I can import a variable and function name declared in other file by using
extern < symbolName > where the symbolName is either the function name or a globally declared variable (i.e. in .data and .bss section). However when I am trying to export the variable var
, the declaration of the variable being an external variable is not wrong ,but when trying to use it in code , yasm is notifying me that it is an undeclared name. Why is it happening ?
edit: File1.asm
section .data
var db 123
File2.asm
section .data
SYS_exit equ 60
extern var
section .text
global _start
_start:
mov al,byte[var]
last:
mov rax,SYS_exit
mov rdi,0
syscall
after this, if I assemble, this error happens: ld: Undefined identifier "var"