Re: generating mach-o executable files by hand
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=kju709W+kxbfBEb6zkaw59vSaNqRgTwArp5ufH/PmAE=; b=TSKpo9hidNiPzfThpISRtPqG2hdJVsHetukFdyppvlLRetotFYfxzfmQ24Gh+zBhow RN+kK2htwBYDMK92lbOouxn8k4Kc0efY2zE97Cm2w+5X8/b7dGvAOJbRZ7AAWuR4KaYx QJikD3bE+W7S8wH5Ub1SvTEHeMfGrQmuy56nI= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=lzpZGnZ1azR3VVo39nNZAj5BC027zWHOMKvwGN3Snb84SUW4vRgb63iH+gxW94uaxv oXvLomsD3UsqQ4uvtA/vc2YCSOZU5knFtM1oMSGyFaZYIvRj2FIVHSpF0R6M1Vj9AafK NJfar72AkR5vgqt/Hs8tO1vJxMQomSPa5Rh4A= User-agent: Thunderbird 2.0.0.19 (X11/20090105) On Jan 7, 2009, at 2:48 PM, Terry Lambert wrote: It only took me a week. nasm -f bin -o hello hello.asm && chmod +x hello ./hello Hello, World! otool -l hello hello: Load command 0 cmd LC_SEGMENT cmdsize 56 segname __PAGEZERO vmaddr 0x00000000 vmsize 0x00001000 fileoff 0 filesize 0 maxprot 0x00000000 initprot 0x00000000 nsects 0 flags 0x0 Load command 1 cmd LC_SEGMENT cmdsize 124 segname __TEXT vmaddr 0x00001000 vmsize 0x00001000 fileoff 0 filesize 4096 maxprot 0x00000007 initprot 0x00000005 nsects 1 flags 0x0 Section sectname __text segname __TEXT addr 0x00001308 size 0x00000039 offset 776 align 2^0 (1) reloff 0 nreloc 0 flags 0x80000400 reserved1 0 reserved2 0 Load command 2 cmd LC_SEGMENT cmdsize 124 segname __DATA vmaddr 0x00002000 vmsize 0x00001000 fileoff 4096 filesize 4096 maxprot 0x00000007 initprot 0x00000003 nsects 1 flags 0x0 Section sectname __const segname __DATA addr 0x00002000 size 0x0000000f offset 4096 align 2^0 (1) reloff 0 nreloc 0 flags 0x00000000 reserved1 0 reserved2 0 Load command 3 cmd LC_SEGMENT cmdsize 124 segname __IMPORT vmaddr 0x00003000 vmsize 0x00001000 fileoff 8192 filesize 4096 maxprot 0x00000007 initprot 0x00000007 nsects 1 flags 0x0 Section sectname __jump_table segname __IMPORT addr 0x00003000 size 0x0000000a offset 8192 align 2^6 (64) reloff 0 nreloc 0 flags 0x04000008 reserved1 0 (index into indirect symbol table) reserved2 5 (size of stubs) Load command 4 cmd LC_SEGMENT cmdsize 56 segname __LINKEDIT vmaddr 0x00004000 vmsize 0x00001000 fileoff 12288 filesize 108 maxprot 0x00000007 initprot 0x00000001 nsects 0 flags 0x0 Load command 5 cmd LC_SYMTAB cmdsize 24 symoff 12288 nsyms 4 stroff 12344 strsize 52 Load command 6 cmd LC_DYSYMTAB cmdsize 80 ilocalsym 0 nlocalsym 1 iextdefsym 1 nextdefsym 2 iundefsym 2 nundefsym 2 tocoff 0 ntoc 0 modtaboff 0 nmodtab 0 extrefsymoff 0 nextrefsyms 0 indirectsymoff 12336 nindirectsyms 2 extreloff 0 nextrel 0 locreloff 0 nlocrel 0 Load command 7 cmd LC_LOAD_DYLINKER cmdsize 28 name /usr/lib/dyld (offset 12) Load command 8 cmd LC_UNIXTHREAD cmdsize 80 flavor i386_THREAD_STATE count i386_THREAD_STATE_COUNT eax 0x00000000 ebx 0x00000000 ecx 0x00000000 edx 0x00000000 edi 0x00000000 esi 0x00000000 ebp 0x00000000 esp 0x00000000 ss 0x00000000 eflags 0x00000000 eip 0x00001308 cs 0x00000000 ds 0x00000000 es 0x00000000 fs 0x00000000 gs 0x00000000 Load command 9 cmd LC_LOAD_DYLIB cmdsize 52 name /usr/lib/libSystem.B.dylib (offset 24) time stamp 2 Thu Jan 1 01:00:02 1970 current version 111.1.3 compatibility version 1.0.0 --- http://twitter.com/wagerlabs _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/rutski89%40gmail.com This email sent to rutski89@gmail.com Congrats :-) _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Joel Reymont wrote: I also rather expect you aren't going to get help from the tools folks to deal with these issues, or to document how to generate a valid Mach-o. I'm happy to report that I can generate a proper "hello world" in assembler and without using a linker. I _am_ using printf and exit from libc. otool -h hello hello: Mach header magic cputype cpusubtype caps filetype ncmds sizeofcmds flags 0xfeedface 7 3 0x00 2 10 748 0x00000085 This email sent to site_archiver@lists.apple.com
participants (1)
-
Patrick Rutkowski