bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #34820] Multiboot image not recognized


From: Faustino Ribeiro
Subject: [bug #34820] Multiboot image not recognized
Date: Mon, 14 Nov 2011 16:23:48 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1

URL:
  <http://savannah.gnu.org/bugs/?34820>

                 Summary: Multiboot image not recognized
                 Project: GNU GRUB
            Submitted by: faust_67
            Submitted on: Mon 14 Nov 2011 04:23:47 PM GMT
                Category: Booting
                Severity: Major
                Priority: 5 - Normal
              Item Group: Software Error
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: Faustino Ribeiro
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 
                 Release: other
         Reproducibility: Every Time
         Planned Release: None

    _______________________________________________________

Details:

I created a minimal kernel image that is multiboot compliant (or at least I
hope). The image boots in Grub Legacy but not in Grub 1.99 (final release).
Mbchk recognizes the image as a valid multiboot image. I am stuck and don't
know what I am doing wrong. Here is the code I use to create a minimal kernel
and an iso image I can boot in VirtualBox:

--> loader-test.S

.global start                          # making entry point visible to linker



# setting up the Multiboot header - see GRUB docs for details



.set ALIGN,    1<<0                     # align loaded modules on page
boundaries

.set MEMINFO,  1<<1                     # provide memory map

.set FLAGS,    ALIGN | MEMINFO          # this is the Multiboot 'flag' field

.set MAGIC,    0x1BADB002               # 'magic number' lets bootloader find
the header

.set CHECKSUM, -(MAGIC + FLAGS)         # checksum required



.code32



start:

        jmp      loader



.align 4



.long MAGIC

.long FLAGS

.long CHECKSUM

.long 0         # header_addr   if flags[16] is set

.long 0         # load_addr     if flags[16] is set

.long 0         # load_end_addr         if flags[16] is set

.long 0         # bss_end_addr  if flags[16] is set

.long 0         # entry_addr    if flags[16] is set

.long 0         # mode_type     if flags[2] is set

.long 0         # width         if flags[2] is set

.long 0         # height        if flags[2] is set

.long 0         # depth         if flags[2] is set



# reserve initial kernel stack space



.set STACKSIZE, 0x4000                  # that is, 16k.

.comm stack, STACKSIZE, 32              # reserve 16k stack on a quadword
boundary



loader:

    mov   $(stack + STACKSIZE), %esp    # set up the stack

    push  %eax                          # Multiboot magic number

    push  %ebx                          # Multiboot data structure



    call kernel_main                          # call kernel proper



    cli

hang:

    hlt                                 # halt machine should kernel return

    jmp   hang



---> kernel_main-test.c

        void kernel_main( void* mbd )

        {

                if (mbd == (void*)0)

                {

                }

        }


---> makefile:

BUILD_DIR = build
SRC_DIR = src
ISO_DIR = iso_files
OBJS := loader-test.o kernel_main-test.o
OBJS := $(addprefix $(BUILD_DIR)/, $(OBJS))
EXECUTABLE = kernel.bin

ASM = nasm
ASMFLAGS = -f elf32 -I $(SRC_DIR)/
CC = gcc
#CCFLAGS = -m64 -I include -Wall -Wextra -Werror -m64 -ffreestanding -nostdlib
-mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow
CCFLAGS = -m32 -I include -Wall -Wextra -Werror -nostdlib -fno-builtin
-nostartfiles -nodefaultlibs
LD = ld
LDFLAGS = -T src/linker-test.ld -m elf_i386

all: $(BUILD_DIR)/$(EXECUTABLE)
        cp $(BUILD_DIR)/$(EXECUTABLE) $(ISO_DIR)/boot/$(EXECUTABLE)
#       cd $(ISO_DIR); genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot
-boot-load-size 4 -boot-info-table -o ../MyOS.iso $(ISO_DIR); cd ..
#       genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot 
-boot-load-size 4
-boot-info-table -o MyOS.iso $(ISO_DIR)
        genisoimage -R -b boot/grub/eltorito.img -no-emul-boot -boot-load-size 4
-boot-info-table -o MyOS.iso $(ISO_DIR)

$(BUILD_DIR)/$(EXECUTABLE): $(OBJS)
        $(LD) $(LDFLAGS) -o $(BUILD_DIR)/$(EXECUTABLE) $(OBJS)

$(BUILD_DIR)/loader-test.o : $(SRC_DIR)/loader-test.S
#       $(ASM) $(ASMFLAGS) -o $@ $<
#       $(CC) -o $@ -c $< $(CCFLAGS)
        as -o $@ -c $< --32

$(BUILD_DIR)/%.o : $(SRC_DIR)/%.S
        $(CC) -o $@ -c $< $(CCFLAGS)

$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c
        $(CC) -o $@ -c $< $(CCFLAGS)

If I use a stage2_eltorito image with grub legacy, I can boot the mini-kernel
with no problem. If I build a grub 1.99 image, I receive the message "Error:
no multiboot header found" when I try to boot the same kernel image. Has
multiboot specifications changed (and if yes, I found no documentation
detailing the changes). I work on a Linux 10.04 box, but I don't think it
matters with my problem.

Thank you. 






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?34820>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]