]> git.proxmox.com Git - grub2.git/blob - debian/patches/sparc64-aout-fix.patch
grub2 (2.02+dfsg1-20) unstable; urgency=medium
[grub2.git] / debian / patches / sparc64-aout-fix.patch
1 From b5148a73117bceb9d831e7b53509893618bff3df Mon Sep 17 00:00:00 2001
2 From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
3 Date: Sat, 9 Feb 2019 09:49:29 +0000
4 Subject: ieee1275: Include a.out header in assembly of sparc64 boot loader
5
6 Recent versions of binutils dropped support for the a.out and COFF
7 formats on sparc64 targets. Since the boot loader on sparc64 is
8 supposed to be an a.out binary and the a.out header entries are
9 rather simple to calculate in our case, we just write the header
10 ourselves instead of relying external tools to do that.
11
12 Signed-off-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
13
14 Bug-Debian: https://bugs.debian.org/921249
15 Forwarded: https://lists.gnu.org/archive/html/grub-devel/2019-02/msg00014.html
16 Last-Update: 2019-02-09
17
18 Patch-Name: sparc64-aout-fix.patch
19 ---
20 grub-core/Makefile.core.def | 6 ++----
21 grub-core/boot/sparc64/ieee1275/boot.S | 16 +++++++++++++---
22 include/grub/sparc64/ieee1275/boot.h | 3 +--
23 3 files changed, 16 insertions(+), 9 deletions(-)
24
25 diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
26 index 94a15f8c7..0f6c5f874 100644
27 --- a/grub-core/Makefile.core.def
28 +++ b/grub-core/Makefile.core.def
29 @@ -381,8 +381,7 @@ image = {
30 i386_qemu_ldflags = '$(TARGET_IMG_BASE_LDOPT),$(GRUB_BOOT_MACHINE_LINK_ADDR)';
31 i386_qemu_ccasflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
32
33 - sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big';
34 - sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000';
35 + sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
36
37 objcopyflags = '-O binary';
38 enable = i386_pc;
39 @@ -411,8 +410,7 @@ image = {
40 i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7C00';
41
42 sparc64_ieee1275 = boot/sparc64/ieee1275/boot.S;
43 - sparc64_ieee1275_objcopyflags = '-O a.out-sunos-big';
44 - sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x4000';
45 + sparc64_ieee1275_ldflags = ' -Wl,-Ttext=0x3fe0';
46 sparc64_ieee1275_cppflags = '-DCDBOOT=1';
47
48 objcopyflags = '-O binary';
49 diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S
50 index 9ea9b4e06..0c8459e35 100644
51 --- a/grub-core/boot/sparc64/ieee1275/boot.S
52 +++ b/grub-core/boot/sparc64/ieee1275/boot.S
53 @@ -21,6 +21,16 @@
54
55 .text
56 .align 4
57 + /* The a.out header, as binutils decided to drop a.out
58 + */
59 + .word 0x1030107 /* A_MAGIC */
60 + .word 512 - GRUB_BOOT_AOUT_HEADER_SIZE /* text size */
61 + .word 0 /* data size */
62 + .word 0 /* bss size */
63 + .word 0 /* symbol table size */
64 + .word _start /* entry point */
65 + .word 0 /* text relocations */
66 + .word 0 /* data relocations */
67 .globl _start
68 _start:
69 /* OF CIF entry point arrives in %o4 */
70 @@ -41,9 +51,9 @@ pic_base:
71 * After loading in that block we will execute it by jumping to the
72 * load address plus the size of the prepended A.OUT header (32 bytes).
73 */
74 - .org GRUB_BOOT_MACHINE_BOOT_DEVPATH
75 + .org GRUB_BOOT_MACHINE_BOOT_DEVPATH + GRUB_BOOT_AOUT_HEADER_SIZE
76 boot_path:
77 - .org GRUB_BOOT_MACHINE_KERNEL_BYTE
78 + .org GRUB_BOOT_MACHINE_KERNEL_BYTE + GRUB_BOOT_AOUT_HEADER_SIZE
79 boot_path_end:
80 kernel_byte: .xword (2 << 9)
81 kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
82 @@ -52,7 +62,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR
83 #define boot_path_end (_start + 1024)
84 #include <grub/offsets.h>
85
86 - .org 8
87 + .org 8 + GRUB_BOOT_AOUT_HEADER_SIZE
88 kernel_byte: .xword (2 << 9)
89 kernel_size: .word 512
90 kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS
91 diff --git a/include/grub/sparc64/ieee1275/boot.h b/include/grub/sparc64/ieee1275/boot.h
92 index 02d53f28e..cc5a941e3 100644
93 --- a/include/grub/sparc64/ieee1275/boot.h
94 +++ b/include/grub/sparc64/ieee1275/boot.h
95 @@ -46,8 +46,7 @@
96
97 #define GRUB_BOOT_MACHINE_KERNEL_BYTE 0x80
98
99 -#define GRUB_BOOT_MACHINE_CODE_END \
100 - (0x1fc - GRUB_BOOT_AOUT_HEADER_SIZE)
101 +#define GRUB_BOOT_MACHINE_CODE_END 0x1fc
102
103 #define GRUB_BOOT_MACHINE_KERNEL_ADDR 0x4200
104