Author Topic: MachO and debug formats  (Read 28880 times)

Ivan Ostres

  • Guest
MachO and debug formats
« on: October 13, 2009, 08:46:55 PM »
Hi all!

Are there any plans or current development to add stabs or dSYM debug format to MachO file format?

If not, maybe I could help with stabs if I'll get enough free time and knowledge.

Regards,
Ivan

Offline Cyrill Gorcunov

  • NASM Developer
  • Full Member
  • *****
  • Posts: 179
  • Country: 00
Re: MachO and debug formats
« Reply #1 on: November 30, 2009, 09:09:51 AM »
As far as I know at moment we have in plans to support debug format of MachO.

So don't hesitate to send patches to nasm-devel mailing list. You may need to subscribe to this list just to monitor what is going on here.

Cyrill

Offline ad

  • Jr. Member
  • *
  • Posts: 6
Re: MachO and debug formats
« Reply #2 on: May 10, 2010, 11:13:32 PM »
Hello,
Does anyone know the status of MachO debug support for NASM?  Is someone working on it? Will be happy to help test it out.
Thanks
Ajit

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: MachO and debug formats
« Reply #3 on: May 11, 2010, 01:32:11 AM »
Until someone implements debugging support for Mach-O, Agner Fog's objconv utility may be of assistance, since it does very good conversions from ELF to Mach-O.

Offline ad

  • Jr. Member
  • *
  • Posts: 6
Re: MachO and debug formats
« Reply #4 on: May 16, 2010, 08:38:50 PM »
Hello,
Thanks for your suggestion, tried objconv, but it seems to strip debug symbols...
Any other ideas are appreciated.
Thanks
Ajit



1. generate elf format with debug information

    bin/nasm -felf -Fstabs hello_asm_func.asm -l hello_asm_func.lst

2. use objconv to convert back to osx format

    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 names3. objconv message



3. asm sample code used

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     ;message
len     equ     $ - msg                 ;length of message

4. c code to call asm

#include <stdio.h>

extern "C" {
extern void hello_asm();
}

int main( int argc, char *argv[])
{
    printf("start calling asm\n");

    hello_asm();

    printf("done calling asm\n");

    return 0;
}


« Last Edit: May 16, 2010, 08:45:30 PM by ad »

Offline ad

  • Jr. Member
  • *
  • Posts: 6
Re: MachO and debug formats
« Reply #5 on: May 18, 2010, 02:43:28 AM »
Agner Fog confirmed debug symbol issue with objconv.

http://www.agner.org/software/discuss/read.php?i=627
« Last Edit: May 18, 2010, 04:31:28 AM by ad »

Offline ad

  • Jr. Member
  • *
  • Posts: 6
Re: MachO and debug formats
« Reply #6 on: March 06, 2011, 02:51:21 AM »
Hello,
Does NASm support MachO debug format yet?
Thanks
« Last Edit: March 06, 2011, 03:01:04 AM by ad »

Offline Keith Kanios

  • Full Member
  • **
  • Posts: 383
  • Country: us
    • Personal Homepage
Re: MachO and debug formats
« Reply #7 on: March 06, 2011, 05:46:36 AM »
Nope. Try submitting as a Summer of Code suggestion/request.