From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MQsrp-0002xx-VJ for mharc-grub-devel@gnu.org; Tue, 14 Jul 2009 21:01:06 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MQsro-0002v9-1q for grub-devel@gnu.org; Tue, 14 Jul 2009 21:01:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MQsrj-0002nw-E1 for grub-devel@gnu.org; Tue, 14 Jul 2009 21:01:03 -0400 Received: from [199.232.76.173] (port=50023 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MQsri-0002nk-Vu for grub-devel@gnu.org; Tue, 14 Jul 2009 21:00:59 -0400 Received: from c60.cesmail.net ([216.154.195.49]:63153) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MQsri-00051N-Az for grub-devel@gnu.org; Tue, 14 Jul 2009 21:00:58 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 14 Jul 2009 21:00:57 -0400 Received: from mj.roinet.com (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id E586E34C6D for ; Tue, 14 Jul 2009 21:10:21 -0400 (EDT) To: grub-devel@gnu.org From: Pavel Roskin Date: Tue, 14 Jul 2009 21:00:55 -0400 Message-ID: <20090715010055.17865.4764.stgit@mj.roinet.com> In-Reply-To: <20090715010017.17865.58915.stgit@mj.roinet.com> References: <20090715010017.17865.58915.stgit@mj.roinet.com> User-Agent: StGit/0.15-rc1-4-g4ce8 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jul 2009 01:01:04 -0000 ChangeLog: * boot/i386/pc/boot.S: Declare 0x0-0x7c00 as a discardable .bss segment. Eliminate ABS, rely on the assembler knowing correct addresses. Eliminate .bss segment for the kernel, use direct jump to the kernel address. --- boot/i386/pc/boot.S | 72 +++++++++------------------------------------------ 1 files changed, 12 insertions(+), 60 deletions(-) diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S index e3f5228..0002773 100644 --- a/boot/i386/pc/boot.S +++ b/boot/i386/pc/boot.S @@ -24,20 +24,13 @@ * defines for the code go here */ - /* Absolute addresses - This makes the assembler generate the address without support - from the linker. (ELF can't relocate 16-bit addresses!) */ -#define ABS(x) (x-_start+0x7c00) - /* Print message string */ -#ifdef APPLE_CC -#define MSG(x) x ## _abs = ABS(x); movw $x ## _abs, %si; call message -#else -#define MSG(x) movw $ABS(x), %si; call message -#endif +#define MSG(x) movw $x, %si; call message .file "boot.S" + .bss + . = 0x7c00 .text /* Tell GAS to generate 16-bit instructions so that this code works @@ -126,12 +119,7 @@ boot_drive_check: * ljmp to the next instruction because some bogus BIOSes * jump to 07C0:0000 instead of 0000:7C00. */ -#ifdef APPLE_CC - real_start_abs = ABS(real_start) - ljmp $0, $(real_start_abs) -#else - ljmp $0, $ABS(real_start) -#endif + ljmp $0, $real_start real_start: @@ -148,12 +136,7 @@ real_start: /* * Check if we have a forced disk reference here */ -#ifdef APPLE_CC - boot_drive_abs = ABS (boot_drive) - movb boot_drive_abs, %al -#else - movb ABS(boot_drive), %al -#endif + movb boot_drive, %al cmpb $0xff, %al je 1f movb %al, %dl @@ -165,12 +148,7 @@ real_start: MSG(notification_string) /* set %si to the disk address packet */ -#ifdef APPLE_CC - disk_address_packet_abs = ABS (disk_address_packet) - movw $disk_address_packet_abs, %si -#else - movw $ABS(disk_address_packet), %si -#endif + movw $disk_address_packet, %si /* do not probe LBA if the drive is a floppy */ testb $GRUB_BOOT_MACHINE_BIOS_HD_FLAG, %dl @@ -211,18 +189,10 @@ lba_mode: movw $0x0010, (%si) /* the absolute address */ -#ifdef APPLE_CC - kernel_sector_abs = ABS (kernel_sector) - movl (kernel_sector_abs), %ebx - movl %ebx, 8(%si) - movl (kernel_sector_abs + 4), %ebx - movl %ebx, 12(%si) -#else - movl ABS(kernel_sector), %ebx + movl kernel_sector, %ebx movl %ebx, 8(%si) - movl ABS(kernel_sector + 4), %ebx + movl kernel_sector + 4, %ebx movl %ebx, 12(%si) -#endif /* the segment of buffer address */ movw $GRUB_BOOT_MACHINE_BUFFER_SEG, 6(%si) @@ -289,22 +259,13 @@ final_init: setup_sectors: /* load logical sector start (top half) */ -#ifdef APPLE_CC - kernel_sector_abs = ABS (kernel_sector) - movl (kernel_sector_abs + 4), %eax -#else - movl ABS(kernel_sector + 4), %eax -#endif + movl kernel_sector + 4, %eax orl %eax, %eax jnz geometry_error /* load logical sector start (bottom half) */ -#ifdef APPLE_CC - movl (kernel_sector_abs), %eax -#else - movl ABS(kernel_sector), %eax -#endif + movl kernel_sector, %eax /* zero %edx */ xorl %edx, %edx @@ -389,7 +350,7 @@ copy_buffer: popa /* boot kernel */ - jmp kernel_entry + jmp GRUB_BOOT_MACHINE_KERNEL_ADDR /* END OF MAIN LOOP */ @@ -475,12 +436,7 @@ floppy_probe: * Perform floppy probe. */ -#ifdef APPLE_CC - probe_values_abs = ABS (probe_values) - movw $(probe_values_abs-1), %si -#else - movw $ABS(probe_values-1), %si -#endif + movw $probe_values - 1, %si probe_loop: /* reset floppy controller INT 13h AH=0 */ @@ -524,7 +480,3 @@ fd_probe_error_string: .asciz "Floppy" /* the last 2 bytes in the sector 0 contain the signature */ .word GRUB_BOOT_MACHINE_SIGNATURE - - .bss - . = . + 0x200 -kernel_entry: