grub2: added relocation patch

This commit is contained in:
Matt Housh 2019-02-28 22:45:12 -06:00
parent 22960e7081
commit c53ceac1e5
3 changed files with 71 additions and 4 deletions

View File

@ -1,6 +1,6 @@
untrusted comment: verify with /etc/ports/opt.pub
RWSE3ohX2g5d/YhN32DfpemzZbt0aouooLKFFpTn7DZwNyhK8yHTxCuqEmCpdO1wQqupU+tcu8kCZ+5QagbbYdw/mH6kx+DcTAI=
SHA256 (Pkgfile) = cb7a11d83303262e313fdfd1038ea68ad4aa714678561ecbfb41eabd61cc5548
RWSE3ohX2g5d/YuKz2ciZJj2pWg7ahuEi9zVjiUXdlN0OVLK7FtyJ7mYnK9CNUP+yaUSBSsLy0TeVZUNXU8njZWseZCHQ7GGogk=
SHA256 (Pkgfile) = 12d6392ccaba90e55bd8910aec825f9951d0b59a5f6dca2d18488e4b4d97fd3f
SHA256 (.footprint) = b592950a75c1fb931e49e42b9f2b27c5eb2e23d5c4a2c24d27a80d1ccdcac054
SHA256 (grub-2.02.tar.xz) = 810b3798d316394f94096ec2797909dbf23c858e48f7b3830826b8daa06b7b0f
SHA256 (unifont-9.0.06.pcf.gz) = 6d23e82ea3fd3d79849d675c0c30129b62a3973a83b4cdc05f9994efef773b86
@ -8,3 +8,4 @@ SHA256 (grub2-00_header.diff) = e4b30c60aa0fa37d48cad2c4e5a53278f1cd5f4ae2df075f
SHA256 (grub2-10_linux.diff) = 5621b312a199647909a09e94e710bb4fca1a2be687d61e2ce7a3cf529f09d1ef
SHA256 (grub.cfg.sample) = c2e72228c1dd150f727e8d611d6f14956080ce078651b03eb14fcf65b0917dda
SHA256 (grub2-intel-ucode.diff) = c20d9f0d207e30c930815bee5b833757da771535ea13436dd94274360f601f0f
SHA256 (grub2-relocation.patch) = 51562fa1016c54567dbf42a86c0cfc902372ab579bbee17879a81aff09b76b99

View File

@ -5,11 +5,11 @@
name=grub2
version=2.02
release=1
release=2
source=(http://ftp.gnu.org/gnu/grub/grub-$version.tar.xz \
http://jaeger.morpheus.net/linux/crux/files/unifont-9.0.06.pcf.gz \
$name-00_header.diff $name-10_linux.diff grub.cfg.sample \
$name-intel-ucode.diff)
$name-intel-ucode.diff $name-relocation.patch)
build() {
export CFLAGS="${CFLAGS} -Wno-error"
@ -21,6 +21,7 @@ build() {
patch -i $SRC/$name-00_header.diff util/grub.d/00_header.in
patch -i $SRC/$name-10_linux.diff util/grub.d/10_linux.in
patch -i $SRC/$name-intel-ucode.diff util/grub.d/10_linux.in
patch -p1 -i $SRC/$name-relocation.patch
./configure --prefix=/usr \
--sysconfdir=/etc \

View File

@ -0,0 +1,65 @@
commit 842c390469e2c2e10b5aa36700324cd3bde25875
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sat Feb 17 06:47:28 2018 -0800
x86-64: Treat R_X86_64_PLT32 as R_X86_64_PC32
Starting from binutils commit bd7ab16b4537788ad53521c45469a1bdae84ad4a:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bd7ab16b4537788ad53521c45469a1bdae84ad4a
x86-64 assembler generates R_X86_64_PLT32, instead of R_X86_64_PC32, for
32-bit PC-relative branches. Grub2 should treat R_X86_64_PLT32 as
R_X86_64_PC32.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
diff --git a/grub-core/efiemu/i386/loadcore64.c b/grub-core/efiemu/i386/loadcore64.c
index e49d0b6ff..18facf47f 100644
--- a/grub-core/efiemu/i386/loadcore64.c
+++ b/grub-core/efiemu/i386/loadcore64.c
@@ -98,6 +98,7 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
break;
case R_X86_64_PC32:
+ case R_X86_64_PLT32:
err = grub_efiemu_write_value (addr,
*addr32 + rel->r_addend
+ sym.off
diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c
index 440690673..3a73e6e6c 100644
--- a/grub-core/kern/x86_64/dl.c
+++ b/grub-core/kern/x86_64/dl.c
@@ -70,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
break;
case R_X86_64_PC32:
+ case R_X86_64_PLT32:
{
grub_int64_t value;
value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index a2bb05439..39d7efb91 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -841,6 +841,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
break;
case R_X86_64_PC32:
+ case R_X86_64_PLT32:
{
grub_uint32_t *t32 = (grub_uint32_t *) target;
*t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c
index 9179285a5..a79271f66 100644
--- a/util/grub-module-verifier.c
+++ b/util/grub-module-verifier.c
@@ -19,6 +19,7 @@ struct grub_module_verifier_arch archs[] = {
-1
}, (int[]){
R_X86_64_PC32,
+ R_X86_64_PLT32,
-1
}
},