Breaking NASM files into multiple with link errors on OS X

90 Views Asked by At

My base assembler file foidlrt.asm started getting a bit too large so I broke it up into two. Here is the entirety of the second file folder_stdio.asm:

; foidl_stdio.asm

%include   "foidlstnd.inc"


        section .text

        DEFAULT REL

global foidl_fclose           ; Raw file close

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; foidl_close
; Raw file close
; REGISTERS (1):
; RDI file handle
; CALLS:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

foidl_fclose:
    mov       rax,SYSCALL_FILE_CLOSE  ; 0x2000006
    syscall
    ret

However, now when I build I am now getting this error from make despite the global declaration in the new file:

nasm src/foidlrt.asm -f macho64 --prefix _ -g -O0 -Iincludes/ -o asmobjs/foildrt.o
nasm src/foidlrt.asm -f macho64 --prefix _ -g -O0 -Iincludes/ -o asmobjs/foidl_stdio.o
libtool -static -s -o libs/libfoidlrt.a asmobjs/foildrt.o asmobjs/foidl_stdio.o
gcc src/testlink.c -L libs -l foidlrt -Wall -g -L. -Wl,-pie -I. -o bin/testlink
Undefined symbols for architecture x86_64:
  "_foidl_fclose", referenced from:
      _main in testlink-4b5ad3.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Version information:

XCode - 7.2.1 (7C1002)
nasm  - NASM version 2.12 compiled on Feb 28 2016
gcc   - Apple LLVM version 7.0.2 (clang-700.1.81)

RESOLVED

Error was all mine, makefile rule was bad. Working as expected now.

0

There are 0 best solutions below