From: Pavel Roskin <proski@gnu.org>
To: grub-devel@gnu.org
Subject: [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations
Date: Tue, 14 Jul 2009 21:00:55 -0400 [thread overview]
Message-ID: <20090715010055.17865.4764.stgit@mj.roinet.com> (raw)
In-Reply-To: <20090715010017.17865.58915.stgit@mj.roinet.com>
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:
next prev parent reply other threads:[~2009-07-15 1:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-15 1:00 [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Pavel Roskin
2009-07-15 1:00 ` [PATCH 2/7] Remove unused version information from boot/i386/pc/boot.S Pavel Roskin
2009-07-15 1:00 ` [PATCH 3/7] Eliminate kernel_segment Pavel Roskin
2009-07-16 15:45 ` Robert Millan
2009-07-15 1:00 ` [PATCH 4/7] Eliminate kernel_address Pavel Roskin
2009-07-16 15:52 ` Robert Millan
2009-07-15 1:00 ` [PATCH 5/7] Add newline after "Error" in bootsector Pavel Roskin
2009-07-15 1:00 ` [PATCH 6/7] Increase BPB size to accommodate FAT32 Pavel Roskin
2009-07-15 1:00 ` Pavel Roskin [this message]
2009-07-15 15:33 ` [PATCH 7/7] RFC: Use correct addresses, eliminate manual relocations Pavel Roskin
2009-07-15 22:41 ` Vladimir 'phcoder' Serbinenko
2009-07-15 23:40 ` Pavel Roskin
2009-07-16 3:44 ` Pavel Roskin
2009-07-16 15:36 ` Vladimir 'phcoder' Serbinenko
2009-07-16 15:43 ` [PATCH 1/7] Make boot/i386/pc/boot.S safer to modify Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090715010055.17865.4764.stgit@mj.roinet.com \
--to=proski@gnu.org \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.