x86: Do not dump DS/CS segment overrides for branch hints

Borislav Petkov bp@suse.de
Fri Dec 11 23:12:24 GMT 2020


Hi,

ok, below is what I got and it passes the checks.

I've made all labels normal labels so that there's no confusion between
the different targets which is which and I match them in the .d files
with .* as Alan suggested.

Hex offsets I match with [0-9a-fx]+ since some targets prefix them with
0x, some don't, etc.

So pls have a look and let me know whether that makes sense.

Thx.

---
diff --git a/gas/testsuite/gas/i386/align-branch-9.d b/gas/testsuite/gas/i386/align-branch-9.d
index 2d5ceef09b1a..643ca283bc07 100644
--- a/gas/testsuite/gas/i386/align-branch-9.d
+++ b/gas/testsuite/gas/i386/align-branch-9.d
@@ -19,7 +19,7 @@ Disassembly of section .text:
   18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   1e:	39 c5                	cmp    %eax,%ebp
-  20:	70 62                	jo     84 <foo\+0x84>
+  20:	70 62                	jo     84 <.*>
   22:	89 73 f4             	mov    %esi,-0xc\(%ebx\)
   25:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   28:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
@@ -31,9 +31,9 @@ Disassembly of section .text:
   3a:	5d                   	pop    %ebp
   3b:	5d                   	pop    %ebp
   3c:	5d                   	pop    %ebp
-  3d:	74 45                	je     84 <foo\+0x84>
+  3d:	74 45                	je     84 <.*>
   3f:	5d                   	pop    %ebp
-  40:	74 42                	je     84 <foo\+0x84>
+  40:	74 42                	je     84 <.*>
   42:	89 44 24 fc          	mov    %eax,-0x4\(%esp\)
   46:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   49:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
@@ -43,25 +43,27 @@ Disassembly of section .text:
   55:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   58:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   5b:	5d                   	pop    %ebp
-  5c:	eb 2c                	jmp    8a <foo\+0x8a>
+  5c:	eb 2c                	jmp    8a <.*>
   5e:	66 90                	xchg   %ax,%ax
-  60:	eb 28                	jmp    8a <foo\+0x8a>
-  62:	eb 26                	jmp    8a <foo\+0x8a>
+  60:	eb 28                	jmp    8a <.*>
+  62:	eb 26                	jmp    8a <.*>
   64:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
   67:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   6a:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
   6d:	5d                   	pop    %ebp
   6e:	5d                   	pop    %ebp
   6f:	40                   	inc    %eax
-  70:	72 12                	jb     84 <foo\+0x84>
+  70:	72 12                	jb     84 <.*>
   72:	36 36 89 45 fc       	ss mov %eax,%ss:-0x4\(%ebp\)
   77:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   7a:	89 7d f8             	mov    %edi,-0x8\(%ebp\)
   7d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
   80:	21 c3                	and    %eax,%ebx
-  82:	7c 06                	jl     8a <foo\+0x8a>
+  82:	7c 06                	jl     8a <.*>
+00000084 <label2>:
   84:	8b 45 f4             	mov    -0xc\(%ebp\),%eax
   87:	89 45 fc             	mov    %eax,-0x4\(%ebp\)
+0000008a <label3>:
   8a:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
   90:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
   96:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
@@ -73,6 +75,6 @@ Disassembly of section .text:
   b6:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
   bc:	89 b5 50 fb ff ff    	mov    %esi,-0x4b0\(%ebp\)
   c2:	89 75 00             	mov    %esi,0x0\(%ebp\)
-  c5:	74 c3                	je     8a <foo\+0x8a>
-  c7:	74 c1                	je     8a <foo\+0x8a>
+  c5:	74 c3                	je     8a <.*>
+  c7:	74 c1                	je     8a <.*>
 #pass
diff --git a/gas/testsuite/gas/i386/align-branch-9.s b/gas/testsuite/gas/i386/align-branch-9.s
index 357abe30f97f..acba220b7a85 100644
--- a/gas/testsuite/gas/i386/align-branch-9.s
+++ b/gas/testsuite/gas/i386/align-branch-9.s
@@ -15,7 +15,7 @@ foo:
   movl  %esi, -12(%ebp)
   movl  %esi, -12(%ebp)
   cmp  %eax, %ebp
-  jo  .L_2
+  jo  label2
   movl  %esi, -12(%ebx)
   movl  %esi, -12(%ebp)
   movl  %edi, -8(%ebp)
@@ -27,9 +27,9 @@ foo:
   popl  %ebp
   popl  %ebp
   popl  %ebp
-  je  .L_2
+  je  label2
   popl  %ebp
-  je  .L_2
+  je  label2
   movl  %eax, -4(%esp)
   movl  %esi, -12(%ebp)
   movl  %edi, -8(%ebp)
@@ -39,26 +39,26 @@ foo:
   movl  %esi, -12(%ebp)
   movl  %esi, -12(%ebp)
   popl  %ebp
-  jmp  .L_3
-  jmp  .L_3
-  jmp  .L_3
+  jmp  label3
+  jmp  label3
+  jmp  label3
   movl  %eax, -4(%ebp)
   movl  %esi, -12(%ebp)
   movl  %edi, -8(%ebp)
   popl  %ebp
   popl  %ebp
   inc  %eax
-  jc  .L_2
+  jc  label2
   movl  %eax, -4(%ebp)
   movl  %esi, -12(%ebp)
   movl  %edi, -8(%ebp)
   movl  %esi, -12(%ebp)
   and  %eax, %ebx
-  jl  .L_3
-.L_2:
+  jl  label3
+label2:
   movl  -12(%ebp), %eax
   movl  %eax, -4(%ebp)
-.L_3:
+label3:
   movl  %esi, -1200(%ebp)
   movl  %esi, -1200(%ebp)
   movl  %esi, -1200(%ebp)
@@ -70,5 +70,5 @@ foo:
   movl  %esi, -1200(%ebp)
   movl  %esi, -1200(%ebp)
   movl  %esi, (%ebp)
-  je .L_3
-  je .L_3
+  je label3
+  je label3
diff --git a/gas/testsuite/gas/i386/branch.d b/gas/testsuite/gas/i386/branch.d
index 6d25b950830f..343544b3757a 100644
--- a/gas/testsuite/gas/i386/branch.d
+++ b/gas/testsuite/gas/i386/branch.d
@@ -6,7 +6,7 @@
 
 Disassembly of section .text:
 
-0+ <.text>:
-[ 	]*[a-f0-9]+:	3e 74 03[ 	]+je,pt  +0x[0-9a-f]+
-[ 	]*[a-f0-9]+:	2e 74 00[ 	]+je,pn  +0x[0-9a-f]+
+0+ <.*>:
+[ 	]*[a-f0-9]+:	3e 74 03[ 	]+je,pt  +[0-9a-fx]+ <.*>
+[ 	]*[a-f0-9]+:	2e 74 00[ 	]+je,pn  +[0-9a-fx]+ <.*>
 #pass
diff --git a/gas/testsuite/gas/i386/branch.s b/gas/testsuite/gas/i386/branch.s
index 968a1818970f..3a8078957578 100644
--- a/gas/testsuite/gas/i386/branch.s
+++ b/gas/testsuite/gas/i386/branch.s
@@ -1,4 +1,4 @@
 .text
-	jz,pt .Llabel
-	jz,pn .Llabel
-.Llabel:
+	jz,pt label
+	jz,pn label
+label:
diff --git a/gas/testsuite/gas/i386/ilp32/x86-64-branch.d b/gas/testsuite/gas/i386/ilp32/x86-64-branch.d
index d5f2358546fc..acf8c42ca97c 100644
--- a/gas/testsuite/gas/i386/ilp32/x86-64-branch.d
+++ b/gas/testsuite/gas/i386/ilp32/x86-64-branch.d
@@ -7,7 +7,7 @@
 
 Disassembly of section .text:
 
-0+ <.text>:
+[0-9a-f]+ <.*>:
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	66 ff d0             	data16 call \*%rax
@@ -18,15 +18,16 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff 20             	data16 jmp \*\(%rax\)
-[ 	]*[a-f0-9]+:	e8 00 00 00 00       	call   0x1f	1b: R_X86_64_PC32	\*ABS\*\+0x10003c
-[ 	]*[a-f0-9]+:	e9 00 00 00 00       	jmp    0x24	20: R_X86_64_PC32	\*ABS\*\+0x10003c
-[ 	]*[a-f0-9]+:	66 e8 00 00 00 00    	data16 call 0x2a	26: R_X86_64_PLT32	foo-0x4
-[ 	]*[a-f0-9]+:	66 e9 00 00 00 00    	data16 jmp 0x30	2c: R_X86_64_PLT32	foo-0x4
-[ 	]*[a-f0-9]+:	66 0f 82 00 00 00 00 	data16 jb 0x37	33: R_X86_64_PLT32	foo-0x4
+[ 	]*[a-f0-9]+:	e8 00 00 00 00       	call   (0x)?1f <.*>	1b: R_X86_64_PC32	\*ABS\*\+0x10003c
+[ 	]*[a-f0-9]+:	e9 00 00 00 00       	jmp    (0x)?24 <.*>	20: R_X86_64_PC32	\*ABS\*\+0x10003c
+[ 	]*[a-f0-9]+:	66 e8 00 00 00 00    	data16 call (0x)?2a <.*>	26: R_X86_64_PLT32	foo-0x4
+[ 	]*[a-f0-9]+:	66 e9 00 00 00 00    	data16 jmp (0x)?30 <.*>	2c: R_X86_64_PLT32	foo-0x4
+[ 	]*[a-f0-9]+:	66 0f 82 00 00 00 00 	data16 jb (0x)?37 <.*>	33: R_X86_64_PLT32	foo-0x4
 [ 	]*[a-f0-9]+:	66 c3                	data16 ret *
 [ 	]*[a-f0-9]+:	66 c2 08 00          	data16 ret \$0x8
-[ 	]*[a-f0-9]+:	3e 74 03[ 	]+je,pt  +0x[0-9a-f]+
-[ 	]*[a-f0-9]+:	2e 74 00[ 	]+je,pn  +0x[0-9a-f]+
+[ 	]*[a-f0-9]+:	3e 74 03[ 	]+je,pt  +[0-9a-fx]+ <.*>
+[ 	]*[a-f0-9]+:	2e 74 00[ 	]+je,pn  +[0-9a-fx]+ <.*>
+[0-9a-f]+ <.*>:
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	66 ff d0             	data16 call \*%rax
@@ -37,8 +38,8 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff 20             	data16 jmp \*\(%rax\)
-[ 	]*[a-f0-9]+:	e8 00 00 00 00       	call   0x[0-9a-f]*	[0-9a-f]*: R_X86_64_PC32	\*ABS\*\+0x10003c
-[ 	]*[a-f0-9]+:	e9 00 00 00 00       	jmp    0x[0-9a-f]*	[0-9a-f]*: R_X86_64_PC32	\*ABS\*\+0x10003c
+[ 	]*[a-f0-9]+:	e8 00 00 00 00       	call   [0-9a-fx]* <.*>	[0-9a-f]*: R_X86_64_PC32	\*ABS\*\+0x10003c
+[ 	]*[a-f0-9]+:	e9 00 00 00 00       	jmp    [0-9a-fx]* <.*>	[0-9a-f]*: R_X86_64_PC32	\*ABS\*\+0x10003c
 [ 	]*[a-f0-9]+:	66 c3                	data16 ret *
 [ 	]*[a-f0-9]+:	66 c2 08 00          	data16 ret \$0x8
 #pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-9.d b/gas/testsuite/gas/i386/x86-64-align-branch-9.d
index 1041fd048331..35f56ad8ddad 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-9.d
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-9.d
@@ -7,6 +7,7 @@ Disassembly of section .text:
 
 0+ <foo>:
    0:	c1 e9 02             	shr    \$0x2,%ecx
+[0-9a-f]+ <.*>:
    3:	c1 e9 02             	shr    \$0x2,%ecx
    6:	c1 e9 02             	shr    \$0x2,%ecx
    9:	89 d1                	mov    %edx,%ecx
@@ -18,9 +19,11 @@ Disassembly of section .text:
   19:	c1 e9 02             	shr    \$0x2,%ecx
   1c:	c1 e9 02             	shr    \$0x2,%ecx
   1f:	80 fa 02             	cmp    \$0x2,%dl
-  22:	70 df                	jo     3 <foo\+0x3>
+  22:	70 df                	jo     [0-9a-fx]+ <.*>
   24:	2e 2e 2e 2e 31 c0    	cs cs cs cs xor %eax,%eax
   2a:	c1 e9 02             	shr    \$0x2,%ecx
+
+[0-9a-f]+ <.*>:
   2d:	c1 e9 02             	shr    \$0x2,%ecx
   30:	c1 e9 02             	shr    \$0x2,%ecx
   33:	89 d1                	mov    %edx,%ecx
@@ -29,8 +32,10 @@ Disassembly of section .text:
   3a:	c1 e9 02             	shr    \$0x2,%ecx
   3d:	c1 e9 02             	shr    \$0x2,%ecx
   40:	f6 c2 02             	test   \$0x2,%dl
-  43:	75 e8                	jne    2d <foo\+0x2d>
+  43:	75 e8                	jne    [0-9a-fx]+ <.*>
   45:	31 c0                	xor    %eax,%eax
+
+[0-9a-f]+ <.*>:
   47:	c1 e9 02             	shr    \$0x2,%ecx
   4a:	c1 e9 02             	shr    \$0x2,%ecx
   4d:	89 d1                	mov    %edx,%ecx
@@ -41,6 +46,6 @@ Disassembly of section .text:
   5a:	89 d1                	mov    %edx,%ecx
   5c:	31 c0                	xor    %eax,%eax
   5e:	ff c0                	inc    %eax
-  60:	76 cb                	jbe    2d <foo\+0x2d>
+  60:	76 cb                	jbe    [0-9a-fx]+ <.*>
   62:	31 c0                	xor    %eax,%eax
 #pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-9.s b/gas/testsuite/gas/i386/x86-64-align-branch-9.s
index 917579bda401..59507f8ad26e 100644
--- a/gas/testsuite/gas/i386/x86-64-align-branch-9.s
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-9.s
@@ -2,7 +2,7 @@
 	.p2align 4,,15
 foo:
 	shrl	$2, %ecx
-.L1:
+l1:
 	shrl	$2, %ecx
 	shrl	$2, %ecx
 	movl	%edx, %ecx
@@ -14,10 +14,10 @@ foo:
 	shrl	$2, %ecx
 	shrl	$2, %ecx
 	cmpb	$2, %dl
-	jo	.L1
+	jo	l1
 	xorl	%eax, %eax
 	shrl	$2, %ecx
-.L2:
+l2:
 	shrl	$2, %ecx
 	shrl	$2, %ecx
 	movl	%edx, %ecx
@@ -26,9 +26,9 @@ foo:
 	shrl	$2, %ecx
 	shrl	$2, %ecx
 	testb	$2, %dl
-	jne	.L2
+	jne	l2
 	xorl	%eax, %eax
-.L3:
+l3:
 	shrl	$2, %ecx
 	shrl	$2, %ecx
 	movl	%edx, %ecx
@@ -39,5 +39,5 @@ foo:
 	movl	%edx, %ecx
 	xorl	%eax, %eax
 	inc	%eax
-	jbe	.L2
+	jbe	l2
 	xorl	%eax, %eax
diff --git a/gas/testsuite/gas/i386/x86-64-branch.d b/gas/testsuite/gas/i386/x86-64-branch.d
index b963f9f051e4..02509d21bc33 100644
--- a/gas/testsuite/gas/i386/x86-64-branch.d
+++ b/gas/testsuite/gas/i386/x86-64-branch.d
@@ -6,7 +6,7 @@
 
 Disassembly of section .text:
 
-0+ <.text>:
+[0-9a-f]+ <.*>:
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	66 ff d0             	data16 call \*%rax
@@ -17,15 +17,16 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff 20             	data16 jmp \*\(%rax\)
-[ 	]*[a-f0-9]+:	e8 (00|5b) 00 (00|10) 00       	call   (0x1f|10007a <.text\+0x10007a>)
-[ 	]*[a-f0-9]+:	e9 (00|60) 00 (00|10) 00       	jmp    (0x24|100084 <.text\+0x100084>)
-[ 	]*[a-f0-9]+:	66 e8 00 00 00 00    	data16 call (0x2a|2a <.text\+0x2a>)
-[ 	]*[a-f0-9]+:	66 e9 00 00 00 00    	data16 jmp (0x30|30 <.text\+0x30>)
-[ 	]*[a-f0-9]+:	66 0f 82 00 00 00 00 	data16 jb (0x37|37 <.text\+0x37>)
+[ 	]*[a-f0-9]+:	e8 (00|5b) 00 (00|10) 00       	call   ((0x)?1f|10007a) <.*>
+[ 	]*[a-f0-9]+:	e9 (00|60) 00 (00|10) 00       	jmp    ((0x)?24|100084) <.*>
+[ 	]*[a-f0-9]+:	66 e8 00 00 00 00    	data16 call (0x2a|2a <.*>)
+[ 	]*[a-f0-9]+:	66 e9 00 00 00 00    	data16 jmp (0x30|30 <.*>)
+[ 	]*[a-f0-9]+:	66 0f 82 00 00 00 00 	data16 jb (0x37|37 <.*>)
 [ 	]*[a-f0-9]+:	66 c3                	data16 ret *
 [ 	]*[a-f0-9]+:	66 c2 08 00          	data16 ret \$0x8
-[ 	]*[a-f0-9]+:	3e 74 03[ 	]+je,pt  +0x[0-9a-f]+
-[ 	]*[a-f0-9]+:	2e 74 00[ 	]+je,pn  +0x[0-9a-f]+
+[ 	]*[a-f0-9]+:	3e 74 03[ 	]+je,pt  +[0-9a-fx]+ <.*>
+[ 	]*[a-f0-9]+:	2e 74 00[ 	]+je,pn  +[0-9a-fx]+ <.*>
+[0-9a-f]+ <label>:
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	ff d0                	call   \*%rax
 [ 	]*[a-f0-9]+:	66 ff d0             	data16 call \*%rax
@@ -36,8 +37,8 @@ Disassembly of section .text:
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff e0             	data16 jmp \*%rax
 [ 	]*[a-f0-9]+:	66 ff 20             	data16 jmp \*\(%rax\)
-[ 	]*[a-f0-9]+:	e8 .. 00 (00|10) 00       	call   (0x[0-9a-f]*|100[0-9a-f]* <.text\+0x100[0-9a-f]*>)
-[ 	]*[a-f0-9]+:	e9 .. 00 (00|10) 00       	jmp    (0x[0-9a-f]*|100[0-9a-f]* <.text\+0x100[0-9a-f]*>)
+[ 	]*[a-f0-9]+:	e8 .. 00 (00|10) 00       	call   [0-9a-fx]* <.*>
+[ 	]*[a-f0-9]+:	e9 .. 00 (00|10) 00       	jmp    [0-9a-fx]* <.*>
 [ 	]*[a-f0-9]+:	66 c3                	data16 ret *
 [ 	]*[a-f0-9]+:	66 c2 08 00          	data16 ret \$0x8
 #pass
diff --git a/gas/testsuite/gas/i386/x86-64-branch.s b/gas/testsuite/gas/i386/x86-64-branch.s
index 496e1bb089fb..75db8f599942 100644
--- a/gas/testsuite/gas/i386/x86-64-branch.s
+++ b/gas/testsuite/gas/i386/x86-64-branch.s
@@ -22,9 +22,9 @@
 	retw
 	retw	$8
 
-	jz,pt .Llabel
-	jz,pn .Llabel
-.Llabel:
+	jz,pt label
+	jz,pn label
+label:
 
 	.intel_syntax noprefix
 	call	rax


More information about the Binutils mailing list