400-R_X86_64_PLT32.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From 02702bdfe14d8a04643a45b03715f734ae34dbac Mon Sep 17 00:00:00 2001
  2. From: "H.J. Lu" <hjl.tools@gmail.com>
  3. Date: Sat, 17 Feb 2018 06:47:28 -0800
  4. Subject: x86-64: Treat R_X86_64_PLT32 as R_X86_64_PC32
  5. Starting from binutils commit bd7ab16b4537788ad53521c45469a1bdae84ad4a:
  6. https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bd7ab16b4537788ad53521c45469a1bdae84ad4a
  7. x86-64 assembler generates R_X86_64_PLT32, instead of R_X86_64_PC32, for
  8. 32-bit PC-relative branches. Grub2 should treat R_X86_64_PLT32 as
  9. R_X86_64_PC32.
  10. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
  11. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  12. Origin: upstream, https://git.savannah.gnu.org/cgit/grub.git/commit/?id=842c390469e2c2e10b5aa36700324cd3bde25875
  13. Last-Update: 2018-07-30
  14. Patch-Name: R_X86_64_PLT32.patch
  15. ---
  16. grub-core/efiemu/i386/loadcore64.c | 1 +
  17. grub-core/kern/x86_64/dl.c | 1 +
  18. util/grub-mkimagexx.c | 1 +
  19. util/grub-module-verifier.c | 1 +
  20. 4 files changed, 4 insertions(+)
  21. diff --git a/grub-core/efiemu/i386/loadcore64.c b/grub-core/efiemu/i386/loadcore64.c
  22. index e49d0b6ff..18facf47f 100644
  23. --- a/grub-core/efiemu/i386/loadcore64.c
  24. +++ b/grub-core/efiemu/i386/loadcore64.c
  25. @@ -98,6 +98,7 @@ grub_arch_efiemu_relocate_symbols64 (grub_efiemu_segment_t segs,
  26. break;
  27. case R_X86_64_PC32:
  28. + case R_X86_64_PLT32:
  29. err = grub_efiemu_write_value (addr,
  30. *addr32 + rel->r_addend
  31. + sym.off
  32. diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c
  33. index 440690673..3a73e6e6c 100644
  34. --- a/grub-core/kern/x86_64/dl.c
  35. +++ b/grub-core/kern/x86_64/dl.c
  36. @@ -70,6 +70,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
  37. break;
  38. case R_X86_64_PC32:
  39. + case R_X86_64_PLT32:
  40. {
  41. grub_int64_t value;
  42. value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value -
  43. diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
  44. index e63f148e4..f20255a28 100644
  45. --- a/util/grub-mkimagexx.c
  46. +++ b/util/grub-mkimagexx.c
  47. @@ -832,6 +832,7 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections,
  48. break;
  49. case R_X86_64_PC32:
  50. + case R_X86_64_PLT32:
  51. {
  52. grub_uint32_t *t32 = (grub_uint32_t *) target;
  53. *t32 = grub_host_to_target64 (grub_target_to_host32 (*t32)
  54. diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c
  55. index 9179285a5..a79271f66 100644
  56. --- a/util/grub-module-verifier.c
  57. +++ b/util/grub-module-verifier.c
  58. @@ -19,6 +19,7 @@ struct grub_module_verifier_arch archs[] = {
  59. -1
  60. }, (int[]){
  61. R_X86_64_PC32,
  62. + R_X86_64_PLT32,
  63. -1
  64. }
  65. },