Software discussion

Web software | www.agner.org

 
thread objconv - Ajit - 2010-05-16
last reply objconv - Agner - 2010-05-17
 
objconv
Author:  Date: 2010-05-16 20:24
Hello!!!
I am using nasm on mac osx.

However nasm does not generate debug information on osx yet.

So, I generated elf format and used objconv to convert back to macho
(bin/nasm -felf -Fstabs hello_asm_func.asm -l hello_asm_func.lst)

However objconv appears to remove debug symbols

below is the message and simple asm sample

What do I need to do to retain debug symbols? (to debug with gdb)

Thank you in advance for any suggestions
Ajit

$ bin/objconv -fmac32 -nu hello_asm_func.o test.o

Input file: hello_asm_func.o, output file: test.o
Converting from ELF32 to Mach-O Little Endian32
Adding leading underscores to symbol names

2 Debug sections removed
0 Exception sections removed
1 Changes in leading underscores on symbol names

****************** Sample Code ************************

section .text
global _hello_asm ;must be declared for linker (ld)

_syscall:
int 0x80 ;system call
ret

_hello_asm: ;entry point for linker

push ebp ;save callers stack
mov ebp, esp ;establish new stack frame
push esi ;save critical registers
push edi

push dword len ;message length
push dword msg ;message to write
push dword 1 ;file descriptor (stdout)
mov eax,0x4 ;system call number (sys_write)
call _syscall ;call kernel

pop edi ;restore registers
pop esi
mov esp, ebp
pop ebp ;clean up stack
ret

section .data

msg db "hello from asm!",0xa ;our dear string
len equ $ - msg ;length of our dear string

   
objconv
Author: Agner Date: 2010-05-17 06:04
Unfortunately, objconv cannot convert debug information until somebody volunteers to add this feature.
The gnu assembler (gas) has an option for using intel syntax, which is close to nasm syntax, but this feature was not supported under Mac the last time I checked.
The yasm assembler is compatible with nasm. Try if it can do what you want ( www.tortall.net/projects/yasm/ )