Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gsOex-0003Kk-OL for mharc-grub-devel@gnu.org; Sat, 09 Feb 2019 04:10:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gsOev-0003KA-QE for grub-devel@gnu.org; Sat, 09 Feb 2019 04:10:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gsOeu-0003i7-Pw for grub-devel@gnu.org; Sat, 09 Feb 2019 04:10:49 -0500 Received: from outpost18.zedat.fu-berlin.de ([130.133.4.111]:39039) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gsOeu-0003Yd-Hy for grub-devel@gnu.org; Sat, 09 Feb 2019 04:10:48 -0500 Received: from relay1.zedat.fu-berlin.de ([130.133.4.67]) by outpost.zedat.fu-berlin.de (Exim 4.85) with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (envelope-from ) id <1gsOeg-002VXV-Vk>; Sat, 09 Feb 2019 10:10:34 +0100 Received: from z6.physik.fu-berlin.de ([160.45.32.137] helo=z6) by relay1.zedat.fu-berlin.de (Exim 4.85) with esmtps (TLSv1.2:AES256-GCM-SHA384:256) (envelope-from ) id <1gsOeg-002v8J-T7>; Sat, 09 Feb 2019 10:10:34 +0100 Received: from glaubitz by z6 with local (Exim 4.92-RC5) (envelope-from ) id 1gsOcz-0007Dg-PN; Sat, 09 Feb 2019 10:08:49 +0100 From: John Paul Adrian Glaubitz To: grub-devel@gnu.org Cc: Eric Snowberg , John Paul Adrian Glaubitz Subject: [PATCH] ieee1275: Include a.out header in assembly of sparc64 boot loader Date: Sat, 9 Feb 2019 10:08:47 +0100 Message-Id: <20190209090847.27707-1-glaubitz@physik.fu-berlin.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Originating-IP: 160.45.32.137 X-ZEDAT-Hint: RV X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 130.133.4.111 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Feb 2019 09:10:50 -0000 Recent versions of binutils dropped support for the a.out and COFF formats on sparc64 targets. Since the boot loader on sparc64 is supposed to be an a.out binary and the a.out header entries are rather simple to calculate in our case, we just write the header ourselves instead of relying external tools to do that. Signed-off-by: John Paul Adrian Glaubitz --- grub-core/Makefile.core.def | 6 ++---- grub-core/boot/sparc64/ieee1275/boot.S | 18 +++++++++++++++--- include/grub/sparc64/ieee1275/boot.h | 3 +-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index e16fb06ba..f9f845828 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -402,8 +402,7 @@ image = { i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)'; i386_qemu_ccasflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; - sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big'; - sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000'; + sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0'; objcopyflags = '-O binary'; enable = i386_pc; @@ -432,8 +431,7 @@ image = { i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00'; sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S; - sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big'; - sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000'; + sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0'; sparc64_ieee1275_cppflags = '-DCDBOOT=1'; objcopyflags = '-O binary'; diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S index 9ea9b4e06..0b43b6e80 100644 --- a/grub-core/boot/sparc64/ieee1275/boot.S +++ b/grub-core/boot/sparc64/ieee1275/boot.S @@ -21,6 +21,18 @@ .text .align 4 + /* We're writing the a.out header ourselves as newer + * upstream versions of binutils no longer support + * the a.out format on SPARC. + */ + .word 0x1030107 /* magic number */ + .word 512 - GRUB_BOOT_AOUT_HEADER_SIZE /* size of text segment */ + .word 0 /* size of initialized data */ + .word 0 /* size of uninitialized data */ + .word 0 /* size of symbol table || checksum */ + .word _start /* entry point */ + .word 0 /* size of text relocation */ + .word 0 /* size of data relocation */ .globl _start _start: /* OF CIF entry point arrives in %o4 */ @@ -41,9 +53,9 @@ pic_base: * After loading in that block we will execute it by jumping to the * load address plus the size of the prepended A.OUT header (32 bytes). */ - .org GRUB_BOOT_MACHINE_BOOT_DEVPATH + .org GRUB_BOOT_MACHINE_BOOT_DEVPATH + GRUB_BOOT_AOUT_HEADER_SIZE boot_path: - .org GRUB_BOOT_MACHINE_KERNEL_BYTE + .org GRUB_BOOT_MACHINE_KERNEL_BYTE + GRUB_BOOT_AOUT_HEADER_SIZE boot_path_end: kernel_byte: .xword (2 << 9) kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR @@ -52,7 +64,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR #define boot_path_end (_start + 1024) #include - .org 8 + .org 8 + GRUB_BOOT_AOUT_HEADER_SIZE kernel_byte: .xword (2 << 9) kernel_size: .word 512 kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS diff --git a/include/grub/sparc64/ieee1275/boot.h b/include/grub/sparc64/ieee1275/boot.h index 02d53f28e..cc5a941e3 100644 --- a/include/grub/sparc64/ieee1275/boot.h +++ b/include/grub/sparc64/ieee1275/boot.h @@ -46,8 +46,7 @@ #define GRUB_BOOT_MACHINE_KERNEL_BYTE 0x80 -#define GRUB_BOOT_MACHINE_CODE_END \ - (0x1fc - GRUB_BOOT_AOUT_HEADER_SIZE) +#define GRUB_BOOT_MACHINE_CODE_END 0x1fc #define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200 -- 2.20.1