Skip to contentSkip to conversation

macho2img

PATCH In review Vladimir 'phcoder' Serbinenko 1 participant 1 message May 30, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 12/18 macho2img

I found no way to generate a raw image with apple's toolchain so wrote a converter from Mach-O to raw
Thanks to Islam M. Ahmed Zaid for pointing me the options to simplify generated Mach-O.

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
conf/common.rmk +10 -0
index 1b9a6cd..1d0427d 100644
@@ -125,6 +125,16 @@ endif
 grub_pe2elf_SOURCES = util/grub-pe2elf.c util/misc.c
 CLEANFILES += grub-pe2elf
 
+# grub_macho2img assumes a lot about source file.
+# So installing it definitively is useless
+# But adding to bin_UTILITIES is needed for
+# genmk.rb to work
+ifeq (0,1)
+bin_UTILITIES += grub-macho2img
+endif
+grub_macho2img_SOURCES = util/grub-macho2img.c
+CLEANFILES += grub-macho2img
+
 # For grub-mkconfig
 grub-mkconfig: util/grub-mkconfig.in config.status
 	./config.status --file=$@:$<
genmk.rb +10 -0
index 249dcb5..05ecc96 100644
@@ -56,8 +56,18 @@ class Image
     "CLEANFILES += #{@name} #{exe} #{objs_str}
 MOSTLYCLEANFILES += #{deps_str}
 
+ifneq ($(TARGET_APPLE_CC),1)
 #{@name}: #{exe}
 	$(OBJCOPY) -O $(#{prefix}_FORMAT) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id $< $@
+else
+ifneq (#{exe},kernel.exec)
+#{@name}: #{exe} ./grub-macho2img
+	./grub-macho2img $< $@
+else
+#{@name}: #{exe} ./grub-macho2img
+	./grub-macho2img --bss $< $@
+endif
+endif
 
 #{exe}: #{objs_str}
 	$(TARGET_CC) -o $@ $^ $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
kern/i386/pc/startup.S +7 -0
index 23f84ed..6cdc79a 100644
@@ -110,6 +110,13 @@ VARIABLE(grub_prefix)
 
 	. = _start + GRUB_KERNEL_MACHINE_DATA_END
 
+#ifdef APPLE_CC
+bss_start:
+	.long 0
+bss_end:
+	.long 0
+#endif
+
 /*
  * Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
  * This uses the a.out kludge to load raw binary to the area starting at 1MB,
util/grub-macho2img.c new file +116 -0

116 lines not on this page · raw message