Terraspace / UASM

UASM - Macro Assembler
http://www.terraspace.co.uk/uasm.html
Other
222 stars 49 forks source link

mach-o symbol table extends beyond end of file #166

Closed johnothwolo closed 3 months ago

johnothwolo commented 2 years ago

When declaring function prototypes in a header, the compiler seems to allocate more string space for the unused prototypes. For example:

;  Header.inc

_printf PROTO, format:PTR BYTE, args:VARARG
_scanf PROTO, format:PTR BYTE, args:VARARG
;  test.asm
;  uasm -macho64 test.asm 
;  ld test.o -lSystem -o test 

INCLUDE Header.inc

.data
fmt DB "Hello %s"
message DB "World", 0ah

.code
_main PROC
    lea r14, fmt
    invoke _printf, r14, message
    ret
_main ENDP

END

This produces:

ld: mach-o string pool extends beyond end of file file 'test.o' for architecture x86_64

But if scanf is commented out, it links perfectly fine.

Additionally, if I comment out the lines below and force uasm not to skip unused symbols, it works fine. https://github.com/Terraspace/UASM/blob/bffb18461dd541479064990c3b2750ab50ae23e2/macho64.c#L651-L652

john-terraspace commented 2 years ago

I'll check this one, I would think that all public symbols should be included even if unused due to possible linkage, it might be that it needs to check for external as well.

john-terraspace commented 2 years ago

Fixed in 2.56 branch.