From 4a54cb06585f568031dfd291d0fe45979ad75e98 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 8 Jun 2023 12:12:48 -0700 Subject: gold: Handle R_X86_64_CODE_4_GOTPCRELX Handle R_X86_64_CODE_4_GOTPCRELX and convert mov name@GOTPCREL(%rip), %r31 to lea name@GOTPCREL(%rip), %r31 if the instruction is encoded with the REX2 prefix when possible. elfcpp/ * x86_64.h (R_X86_64_CODE_4_GOTPCRELX): New. gold/ * x86_64.cc (Target_x86_64::can_convert_mov_to_lea): Handle R_X86_64_CODE_4_GOTPCRELX. (Target_x86_64::Scan::get_reference_flags): Likewise. (Target_x86_64::Scan::local): Likewise. (Target_x86_64::Scan::possible_function_pointer_reloc): Likewise. (Target_x86_64::Scan::global): Likewise. (Target_x86_64::Relocate::relocate): Likewise. * testsuite/x86_64_mov_to_lea1.s: Add a test for R_X86_64_CODE_4_GOTPCRELX. * testsuite/x86_64_mov_to_lea2.s: Likewise. * testsuite/x86_64_mov_to_lea3.s: Likewise. * testsuite/x86_64_mov_to_lea4.s: Likewise. * testsuite/x86_64_mov_to_lea5.s: Likewise. * testsuite/x86_64_mov_to_lea.sh: Updated. --- elfcpp/x86_64.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'elfcpp') diff --git a/elfcpp/x86_64.h b/elfcpp/x86_64.h index 0377e77..97a87ae 100644 --- a/elfcpp/x86_64.h +++ b/elfcpp/x86_64.h @@ -95,9 +95,13 @@ enum R_X86_64_PC32_BND = 39, // PC relative 32 bit signed with BND prefix R_X86_64_PLT32_BND = 40, // 32 bit PLT address with BND prefix R_X86_64_GOTPCRELX = 41, // 32 bit signed PC relative offset to GOT - // without REX prefix, relaxable. + // without REX nor REX2 prefixes, relaxable. R_X86_64_REX_GOTPCRELX = 42, // 32 bit signed PC relative offset to GOT // with REX prefix, relaxable. + R_X86_64_CODE_4_GOTPCRELX = 43, // 32 bit signed PC relative offset to + // GOT if the instruction starts at 4 + // bytes before the relocation offset, + // relaxable. // GNU vtable garbage collection extensions. R_X86_64_GNU_VTINHERIT = 250, R_X86_64_GNU_VTENTRY = 251 -- cgit v1.1