On Fri, May 03, 2013 at 02:34:11PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > > It does also revert the removal of uboot_get_real_bss_start, since > > this causes GRUB to fail even reaching "Welcome to GRUB!" on my > > Trimslice. It may not be the best solution, but it is in there for a > > reason. > > Why was this revert necessary? The C code and asm code seem to mirror > each other
The diference is in the assigning of grub_modbase, which ends up pointing at an unaligned address, since __bss_start is not pointing to the first variable allocated in BSS, but at the byte immediately following the preceding segment. Since the preceding segment is the license one, containing only strings, that segment may end on any alignment - and currently my build includes license statements in the kernel, since (for example) term/terminfo.c has a GRUB_MOD_LICENSE unconditionally included, even when built into the kernel. I should however simply have moved this assignment into startup.S. Patch attached. / Leif
=== modified file 'grub-core/kern/arm/uboot/startup.S' --- grub-core/kern/arm/uboot/startup.S 2013-04-28 23:59:17 +0000 +++ grub-core/kern/arm/uboot/startup.S 2013-04-30 20:55:46 +0000 @@ -79,6 +79,8 @@ add r3, r0, r2 @ blob end cmp r1, r3 @ _end < blob end? movlt r1, r3 @ dst = blob end + blob size + ldr r12, =EXT_C(grub_modbase) + str r1, [r12] @ grub_modbase = dst 1: ldr r3, [r0], #4 @ r3 = *src++ str r3, [r1], #4 @ *dst++ = r3 === modified file 'grub-core/kern/uboot/init.c' --- grub-core/kern/uboot/init.c 2013-04-28 22:14:05 +0000 +++ grub-core/kern/uboot/init.c 2013-04-30 20:59:19 +0000 @@ -31,8 +31,6 @@ #include <grub/uboot/uboot.h> #include <grub/uboot/api_public.h> -extern char __bss_start[]; -extern char _end[]; extern grub_size_t grub_total_module_size; extern int (*grub_uboot_syscall_ptr) (int, int *, ...); @@ -70,7 +68,6 @@ void grub_machine_init (void) { - grub_addr_t end, real_bss_start; int ver; /* First of all - establish connection with U-Boot */ @@ -86,26 +83,12 @@ grub_uboot_puts ("invalid U-Boot API version\n"); } - /* - * Modules were relocated to _end, or __bss_start + grub_total_module_size, - * whichever greater. (And __bss_start may not point to actual BSS start...) - */ - real_bss_start = grub_uboot_get_real_bss_start (); - end = real_bss_start + grub_total_module_size; - if (end < (grub_addr_t) _end) - end = (grub_addr_t) _end; - grub_modbase = end; - /* Initialize the console so that GRUB can display messages. */ grub_console_init_early (); /* Enumerate memory and initialize the memory management system. */ grub_uboot_mm_init (); - grub_dprintf ("init", "__bss_start: 0x%08x, real_bss_start: 0x%08x\n", - (grub_addr_t) __bss_start, real_bss_start); - grub_dprintf ("init", "end: 0x%08x, _end: 0x%08x\n", - (grub_addr_t) end, (grub_addr_t) _end); grub_dprintf ("init", "grub_modbase: %p\n", (void *) grub_modbase); grub_dprintf ("init", "grub_modules_get_end(): %p\n", (void *) grub_modules_get_end ());
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel