[PATCH 4/5] x86-64: further tighten convert-load-reloc checking
H.J. Lu
hjl.tools@gmail.com
Mon Feb 3 22:41:05 GMT 2025
On Mon, Feb 3, 2025 at 7:41 PM Jan Beulich <jbeulich@suse.com> wrote:
>
> REX2.M affects what insn we're actually dealing with, so we better check
> this to avoid transforming (future) insns we must not touch.
>
> --- a/bfd/elf64-x86-64.c
> +++ b/bfd/elf64-x86-64.c
> @@ -2282,14 +2282,14 @@ elf_x86_64_convert_load_reloc (bfd *abfd
> if (to_reloc_pc32)
> return true;
>
> - if (opcode == 0x85)
> + if (opcode == 0x85 && !(rex2 & (REX2_M << 4)))
> {
> /* Convert "test %reg, foo@GOTPCREL(%rip)" to
> "test $foo, %reg". */
> modrm = 0xc0 | (modrm & 0x38) >> 3;
> opcode = 0xf7;
> }
> - else if ((opcode | 0x38) == 0x3b)
> + else if ((opcode | 0x38) == 0x3b && !(rex2 & (REX2_M << 4)))
> {
> /* Convert "binop foo@GOTPCREL(%rip), %reg" to
> "binop $foo, %reg". */
>
Please add a testcase to show it makes a difference.
Thanks.
--
H.J.
More information about the Binutils
mailing list