[binutils-gdb] x86/APX: use CS: in place of ES: in @gotpcrel and @gottpoff relaxation
Jan Beulich
jbeulich@sourceware.org
Fri Feb 21 09:27:07 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=922fe9449a0632b8facb586860a510d5f2bd628c
commit 922fe9449a0632b8facb586860a510d5f2bd628c
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Feb 21 10:23:21 2025 +0100
x86/APX: use CS: in place of ES: in @gotpcrel and @gottpoff relaxation
H.J. requested this adjustment; I'm unaware of any specific technical
background.
Diff:
---
bfd/elf64-x86-64.c | 22 +++++++++++-----------
ld/testsuite/ld-x86-64/load3a.d | 16 ++++++++--------
ld/testsuite/ld-x86-64/load3b.d | 16 ++++++++--------
ld/testsuite/ld-x86-64/tlsbindesc.dd | 8 ++++----
4 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 0e360771d12..5accb752a43 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2362,13 +2362,13 @@ elf_x86_64_convert_load_reloc (bfd *abfd,
bfd_put_8 (abfd, opcode, contents + roff - 2);
- /* For MOVRS zap the 0f38 or EVEX prefix, applying meaningless ES
+ /* For MOVRS zap the 0f38 or EVEX prefix, applying meaningless CS
segment overrides instead. When necessary also install the REX2
prefix and payload (which may not have been written yet). */
if (movrs)
{
- bfd_put_8 (abfd, 0x26, contents + roff - movrs);
- bfd_put_8 (abfd, 0x26, contents + roff - movrs + 1);
+ bfd_put_8 (abfd, 0x2e, contents + roff - movrs);
+ bfd_put_8 (abfd, 0x2e, contents + roff - movrs + 1);
if (movrs == 6)
{
bfd_put_8 (abfd, 0xd5, contents + roff - 4);
@@ -4361,11 +4361,11 @@ elf_x86_64_relocate_section (bfd *output_bfd,
byte. */
if (type == 0x8b)
{
- /* For MOVRS emit meaningless ES prefixes. */
+ /* For MOVRS emit meaningless CS prefixes. */
if (bfd_get_8 (input_bfd, contents + roff - 4) == 0x0f)
{
- bfd_put_8 (output_bfd, 0x26, contents + roff - 4);
- rex2 = 0x26;
+ bfd_put_8 (output_bfd, 0x2e, contents + roff - 4);
+ rex2 = 0x2e;
rex2_mask = 0;
}
type = 0xc7;
@@ -4403,10 +4403,10 @@ elf_x86_64_relocate_section (bfd *output_bfd,
unsigned int reg = bfd_get_8 (input_bfd, contents + roff - 1);
reg >>= 3;
- /* Replace 0f38 by meaningless ES prefixes, shifting the REX
+ /* Replace 0f38 by meaningless CS prefixes, shifting the REX
prefix forward. */
- bfd_put_8 (output_bfd, 0x26, contents + roff - 5);
- bfd_put_8 (output_bfd, 0x26, contents + roff - 4);
+ bfd_put_8 (output_bfd, 0x2e, contents + roff - 5);
+ bfd_put_8 (output_bfd, 0x2e, contents + roff - 4);
bfd_put_8 (output_bfd, rex, contents + roff - 3);
bfd_put_8 (output_bfd, 0xc7, contents + roff - 2);
bfd_put_8 (output_bfd, 0xc0 | reg, contents + roff - 1);
@@ -4455,8 +4455,8 @@ elf_x86_64_relocate_section (bfd *output_bfd,
rex2 |= REX_W;
- bfd_put_8 (output_bfd, 0x26, contents + roff - 6);
- bfd_put_8 (output_bfd, 0x26, contents + roff - 5);
+ bfd_put_8 (output_bfd, 0x2e, contents + roff - 6);
+ bfd_put_8 (output_bfd, 0x2e, contents + roff - 5);
bfd_put_8 (output_bfd, 0xd5, contents + roff - 4);
bfd_put_8 (output_bfd, rex2, contents + roff - 3);
bfd_put_8 (output_bfd, 0xc7, contents + roff - 2);
diff --git a/ld/testsuite/ld-x86-64/load3a.d b/ld/testsuite/ld-x86-64/load3a.d
index 0feee16785d..e9323594388 100644
--- a/ld/testsuite/ld-x86-64/load3a.d
+++ b/ld/testsuite/ld-x86-64/load3a.d
@@ -10,12 +10,12 @@ Disassembly of section .text:
#...
[a-f0-9]+ <_start>:
-[ ]*[a-f0-9]+: 26 26 c7 c0 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%eax
-[ ]*[a-f0-9]+: 26 26 41 c7 c3 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%r11d
-[ ]*[a-f0-9]+: 26 26 d5 10 c7 c5 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%r21d
-[ ]*[a-f0-9]+: 26 26 48 c7 c0 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%rax
-[ ]*[a-f0-9]+: 26 26 49 c7 c3 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%r11
-[ ]*[a-f0-9]+: 26 26 d5 18 c7 c5 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%r21
-[ ]*[a-f0-9]+: 26 26 48 c7 c0 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%rax
-[ ]*[a-f0-9]+: 26 26 49 c7 c3 ([0-9a-f]{2} ){4} * (es ){2}mov \$0x[a-f0-9]+,%r11
+[ ]*[a-f0-9]+: 2e 2e c7 c0 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%eax
+[ ]*[a-f0-9]+: 2e 2e 41 c7 c3 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%r11d
+[ ]*[a-f0-9]+: 2e 2e d5 10 c7 c5 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%r21d
+[ ]*[a-f0-9]+: 2e 2e 48 c7 c0 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%rax
+[ ]*[a-f0-9]+: 2e 2e 49 c7 c3 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%r11
+[ ]*[a-f0-9]+: 2e 2e d5 18 c7 c5 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%r21
+[ ]*[a-f0-9]+: 2e 2e 48 c7 c0 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%rax
+[ ]*[a-f0-9]+: 2e 2e 49 c7 c3 ([0-9a-f]{2} ){4} * (cs ){2}mov \$0x[a-f0-9]+,%r11
#pass
diff --git a/ld/testsuite/ld-x86-64/load3b.d b/ld/testsuite/ld-x86-64/load3b.d
index f555fcbc1d9..d38f9e227f8 100644
--- a/ld/testsuite/ld-x86-64/load3b.d
+++ b/ld/testsuite/ld-x86-64/load3b.d
@@ -10,12 +10,12 @@ Disassembly of section .text:
#...
[a-f0-9]+ <_start>:
-[ ]*[a-f0-9]+: 26 26 8d 05 ([0-9a-f]{2} ){4} * (es ){2}lea -0x[a-f0-9]+\(%rip\),%eax # [a-f0-9]+ <foo>
-[ ]*[a-f0-9]+: 26 26 44 8d 1d ([0-9a-f]{2} ){4} * (es ){2}lea 0x[a-f0-9]+\(%rip\),%r11d # [a-f0-9]+ <bar>
-[ ]*[a-f0-9]+: 26 26 d5 40 8d 2d ([0-9a-f]{2} ){4} * (es ){2}lea 0x[a-f0-9]+\(%rip\),%r21d # [a-f0-9]+ <bar>
-[ ]*[a-f0-9]+: 26 26 48 8d 05 ([0-9a-f]{2} ){4} * (es ){2}lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
-[ ]*[a-f0-9]+: 26 26 4c 8d 1d ([0-9a-f]{2} ){4} * (es ){2}lea 0x[a-f0-9]+\(%rip\),%r11 # [a-f0-9]+ <bar>
-[ ]*[a-f0-9]+: 26 26 d5 48 8d 2d ([0-9a-f]{2} ){4} * (es ){2}lea 0x[a-f0-9]+\(%rip\),%r21 # [a-f0-9]+ <bar>
-[ ]*[a-f0-9]+: 26 26 48 8d 05 ([0-9a-f]{2} ){4} * (es ){2}lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
-[ ]*[a-f0-9]+: 26 26 4c 8d 1d ([0-9a-f]{2} ){4} * (es ){2}lea 0x[a-f0-9]+\(%rip\),%r11 # [a-f0-9]+ <(__stop_my_section|pad)>
+[ ]*[a-f0-9]+: 2e 2e 8d 05 ([0-9a-f]{2} ){4} * (cs ){2}lea -0x[a-f0-9]+\(%rip\),%eax # [a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 2e 2e 44 8d 1d ([0-9a-f]{2} ){4} * (cs ){2}lea 0x[a-f0-9]+\(%rip\),%r11d # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 2e 2e d5 40 8d 2d ([0-9a-f]{2} ){4} * (cs ){2}lea 0x[a-f0-9]+\(%rip\),%r21d # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 2e 2e 48 8d 05 ([0-9a-f]{2} ){4} * (cs ){2}lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
+[ ]*[a-f0-9]+: 2e 2e 4c 8d 1d ([0-9a-f]{2} ){4} * (cs ){2}lea 0x[a-f0-9]+\(%rip\),%r11 # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 2e 2e d5 48 8d 2d ([0-9a-f]{2} ){4} * (cs ){2}lea 0x[a-f0-9]+\(%rip\),%r21 # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 2e 2e 48 8d 05 ([0-9a-f]{2} ){4} * (cs ){2}lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+[ ]*[a-f0-9]+: 2e 2e 4c 8d 1d ([0-9a-f]{2} ){4} * (cs ){2}lea 0x[a-f0-9]+\(%rip\),%r11 # [a-f0-9]+ <(__stop_my_section|pad)>
#pass
diff --git a/ld/testsuite/ld-x86-64/tlsbindesc.dd b/ld/testsuite/ld-x86-64/tlsbindesc.dd
index ae10e8f8170..72757bab143 100644
--- a/ld/testsuite/ld-x86-64/tlsbindesc.dd
+++ b/ld/testsuite/ld-x86-64/tlsbindesc.dd
@@ -256,18 +256,18 @@ Disassembly of section .text:
+[0-9a-f]+: d5 18 c7 c5 90 ff ff[ ]+mov \$0xf+90,%r21
# sl5
+[0-9a-f]+: ff *
- +[0-9a-f]+: 26 26 49 c7 c3 90 ff[ ]+(es ){2}mov \$0xf+90,%r11
+ +[0-9a-f]+: 2e 2e 49 c7 c3 90 ff[ ]+(cs ){2}mov \$0xf+90,%r11
# sl5
+[0-9a-f]+: ff ff *
- +[0-9a-f]+: 26 26 d5 18 c7 c5 90[ ]+(es ){2}mov \$0xf+90,%r21
+ +[0-9a-f]+: 2e 2e d5 18 c7 c5 90[ ]+(cs ){2}mov \$0xf+90,%r21
# sl5
+[0-9a-f]+: ff ff ff *
# IE->LE against hidden var
+[0-9a-f]+: d5 18 c7 c6 b0 ff ff[ ]+mov \$0xf+b0,%r22
+[0-9a-f]+: ff *
- +[0-9a-f]+: 26 26 49 c7 c4 b0 ff[ ]+(es ){2}mov \$0xf+b0,%r12
+ +[0-9a-f]+: 2e 2e 49 c7 c4 b0 ff[ ]+(cs ){2}mov \$0xf+b0,%r12
+[0-9a-f]+: ff ff *
- +[0-9a-f]+: 26 26 d5 18 c7 c6 b0[ ]+(es ){2}mov \$0xf+b0,%r22
+ +[0-9a-f]+: 2e 2e d5 18 c7 c6 b0[ ]+(cs ){2}mov \$0xf+b0,%r22
+[0-9a-f]+: ff ff ff *
# GD -> IE because variable is not defined in executable
+[0-9a-f]+: d5 48 8b 05 ([0-9a-f]{2} ){3}[ ]+mov 0x[0-9a-f]+\(%rip\),%r16 +# [0-9a-f]+ <sG1>
More information about the Binutils-cvs
mailing list