On Mon, May 11, 2009 at 8:04 PM, step21 <f...@terrorpop.de> wrote:
> It compiles for me, but even with outcommented line in grub-mkimage.c
> it does not start.
It's a bug in objconv with 64-bit images. Add this patch workaround
(prefix workaround still applies). Also this patch-on-patch contains
another improvement for 64-bit apple compiler
>
> On Mon, May 11, 2009 at 6:45 PM, Vladimir 'phcoder' Serbinenko
> <phco...@gmail.com> wrote:
>> On Mon, May 11, 2009 at 6:30 PM, Vladimir 'phcoder' Serbinenko
>> <phco...@gmail.com> wrote:
>>> On Mon, May 11, 2009 at 12:48 PM, Peter Cros <pxwp...@gmail.com> wrote:
>>>>
>>>> Hi,
>>>> patches were applied with grub2 rev 2202, compiles and builds grub.efi in 
>>>> Mac OSX 10.5.6 , i686-apple-darwin9-gcc-4.0.1, with no errors, but fails 
>>>> to run grub.efi.
>>>> ./configure  --with-platform=efi --target=x86_64
>>>> ./grub-mkimage -d . -o grubosx.efi appleldr boot cat cmp chain configfile 
>>>> crc date echo ext2 fixvideo fat fs_uuid gpt gptsync halt help hexdump hfs  
>>>> hfsplus iso9660 linux loopback loadbios lspci ls minicmd memrw ntfs pc pci 
>>>> reboot reiserfs read scsi sleep search sh video videotest xfs
>>>> rEFIt then gives -
>>>>     Starting grubosx.efi
>>>> and hangs there (i.e. before the Welcome to GRUB).
>>>
>> Also it looks like the problems are limited to kernel.mod. If you take
>> this file from linux build rest should be fine
>>> It's a bug in grub-mkimage - it inappropriately assumes that text is a
>>> first segment. I'll fix it. Temporarily you can just comment out the
>>> following line:
>>> util/i386/efi/grub-mkimage.c: line 104: strcpy (kernel_image + sizeof
>>> (Elf_Ehdr) + GRUB_KERNEL_MACHINE_PREFIX, prefix);
>>>>
>>>> Attempt to compile macho2img.c gave error, but is this needed for x86_64?
>>>>
>>>> On Mon, May 11, 2009 at 2:46 AM, Vladimir 'phcoder' Serbinenko 
>>>> <phco...@gmail.com> wrote:
>>>>>
>>>>> Hello. With this patch you can compile grub2 using Apple's gcc. Only 
>>>>> partially tested. You need objconv available from 
>>>>> http://www.agner.org/optimize/ licensed under GPL and additionally 
>>>>> patched with attached patch
>>>>> Then you need to patch grub2 with attached patch. If you compile for 
>>>>> i386-pcbefore you begin you need to compile execute:
>>>>> gcc -o macho2img util/macho2img.c -Iinclude
>>>>> Then just compile grub2 normally. I will look how to automatise the 
>>>>> compilation of macho2img
>>>>> --
>>>>> Regards
>>>>> Vladimir 'phcoder' Serbinenko
>>>>>
>>>>> _______________________________________________
>>>>> Grub-devel mailing list
>>>>> Grub-devel@gnu.org
>>>>> http://lists.gnu.org/mailman/listinfo/grub-devel
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Cros (pxw)
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Grub-devel mailing list
>>>> Grub-devel@gnu.org
>>>> http://lists.gnu.org/mailman/listinfo/grub-devel
>>>>
>>>
>>>
>>>
>>> --
>>> Regards
>>> Vladimir 'phcoder' Serbinenko
>>>
>>
>>
>>
>> --
>> Regards
>> Vladimir 'phcoder' Serbinenko
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> http://lists.gnu.org/mailman/listinfo/grub-devel
>>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Regards
Vladimir 'phcoder' Serbinenko
diff --git a/configure.ac b/configure.ac
index ad45e2c..9d0a8b9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -344,16 +344,21 @@ if test "x$target_m64" = x1; then
   TARGET_MODULE_FORMAT="elf64"
 fi
 
-if test "$target_cpu"-"$platform" = x86_64-efi && test x$TARGET_APPLE_CC == x0; then
+if test "$target_cpu"-"$platform" = x86_64-efi; then
   # Use large model to support 4G memory
   AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
+    SAVED_CFLAGS=$CFLAGS
     CFLAGS="$CFLAGS -m64 -mcmodel=large"
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
 		      [grub_cv_cc_mcmodel=yes],
 		      [grub_cv_cc_mcmodel=no])
   ])
-  if test "x$grub_cv_cc_no_mcmodel" = xno; then
-    AC_MSG_ERROR([-mcmodel=large not supported, upgrade your gcc])
+  if test "x$grub_cv_cc_mcmodel" = xno; then
+    CFLAGS="$SAVED_CFLAGS -m64 -DMCMODEL_SMALL=1"
+    TARGET_CFLAGS="$TARGET_CFLAGS -DMCMODEL_SMALL=1"    
+    AC_MSG_WARN([-mcmodel=large not supported. You wan't be able to use the memory over 4GiB. Upgrade your gcc])
+  else
+    TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
   fi
 
   # EFI writes to stack below %rsp, we must not use the red zone
@@ -367,7 +372,7 @@ if test "$target_cpu"-"$platform" = x86_64-efi && test x$TARGET_APPLE_CC == x0;
     AC_MSG_ERROR([-mno-red-zone not supported, upgrade your gcc])
   fi
 
-  TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large -mno-red-zone"
+  TARGET_CFLAGS="$TARGET_CFLAGS -mno-red-zone"
 fi
 
 #
diff --git a/kern/efi/mm.c b/kern/efi/mm.c
index 4635776..be85353 100644
--- a/kern/efi/mm.c
+++ b/kern/efi/mm.c
@@ -63,7 +63,8 @@ grub_efi_allocate_pages (grub_efi_physical_address_t address,
   /* Limit the memory access to less than 4GB for 32-bit platforms.  */
   if (address > 0xffffffff)
     return 0;
-  
+#endif
+#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
   if (address == 0)
     {
       type = GRUB_EFI_ALLOCATE_MAX_ADDRESS;
@@ -218,7 +219,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
        desc = NEXT_MEMORY_DESCRIPTOR (desc, desc_size))
     {
       if (desc->type == GRUB_EFI_CONVENTIONAL_MEMORY
-#if GRUB_TARGET_SIZEOF_VOID_P < 8
+#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
 	  && desc->physical_start <= 0xffffffff
 #endif
 	  && desc->physical_start + PAGES_TO_BYTES (desc->num_pages) > 0x100000
@@ -234,7 +235,7 @@ filter_memory_map (grub_efi_memory_descriptor_t *memory_map,
 	      desc->physical_start = 0x100000;
 	    }
 	  
-#if GRUB_TARGET_SIZEOF_VOID_P < 8
+#if GRUB_TARGET_SIZEOF_VOID_P < 8 || defined (MCMODEL_SMALL)
 	  if (BYTES_TO_PAGES (filtered_desc->physical_start)
 	      + filtered_desc->num_pages
 	      > BYTES_TO_PAGES (0x100000000LL))
diff --git a/util/i386/efi/grub-mkimage.c b/util/i386/efi/grub-mkimage.c
index db88a0f..90e61a2 100644
--- a/util/i386/efi/grub-mkimage.c
+++ b/util/i386/efi/grub-mkimage.c
@@ -386,8 +386,8 @@ relocate_addresses (Elf_Ehdr *e, Elf_Shdr *sections,
 	    sym_addr = get_symbol_address (e, symtab_section,
 					   ELF_R_SYM (info));
 
-            value = (s->sh_type == grub_cpu_to_le32 (SHT_RELA)) ?
-               (Elf_Addr *) &r->r_addend : target;
+            value = /*(s->sh_type == grub_cpu_to_le32 (SHT_RELA)) ?
+		      (Elf_Addr *) &r->r_addend :*/ target;
 
             switch (ELF_R_TYPE (info))
 	      {
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to