From 7393df7f3fb404a605af9f2b9d4b8698c6fcc7df Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Sat, 12 Dec 2020 00:12:24 +0100 Subject: [PATCH] x86: Do not dump DS/CS segment overrides for branch hints 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. * testsuite/gas/i386/align-branch-9.s: Don't use labels that are automatically local for ELF targets. * testsuite/gas/i386/branch.s: Likewise. * testsuite/gas/i386/x86-64-align-branch-9.s: Likewise. * testsuite/gas/i386/x86-64-branch.s: Likewise. * testsuite/gas/i386/align-branch-9.d: Adjust to match more targets. * testsuite/gas/i386/branch.d: Likewise. * testsuite/gas/i386/ilp32/x86-64-branch.d: Likewise. * testsuite/gas/i386/x86-64-align-branch-9.d: Likewise. * testsuite/gas/i386/x86-64-branch.d: Likewise. --- gas/ChangeLog | 13 ++++++++++ gas/testsuite/gas/i386/align-branch-9.d | 22 +++++++++-------- gas/testsuite/gas/i386/align-branch-9.s | 24 +++++++++---------- gas/testsuite/gas/i386/branch.d | 6 ++--- gas/testsuite/gas/i386/branch.s | 6 ++--- gas/testsuite/gas/i386/ilp32/x86-64-branch.d | 21 ++++++++-------- .../gas/i386/x86-64-align-branch-9.d | 11 ++++++--- .../gas/i386/x86-64-align-branch-9.s | 12 +++++----- gas/testsuite/gas/i386/x86-64-branch.d | 21 ++++++++-------- gas/testsuite/gas/i386/x86-64-branch.s | 6 ++--- 10 files changed, 82 insertions(+), 60 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 71644af918b..42bab19b2c8 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,16 @@ +2020-12-13 Borislav Petkov + + * testsuite/gas/i386/align-branch-9.s: Don't use labels that are + automatically local for ELF targets. + * testsuite/gas/i386/branch.s: Likewise. + * testsuite/gas/i386/x86-64-align-branch-9.s: Likewise. + * testsuite/gas/i386/x86-64-branch.s: Likewise. + * testsuite/gas/i386/align-branch-9.d: Adjust to match more targets. + * testsuite/gas/i386/branch.d: Likewise. + * testsuite/gas/i386/ilp32/x86-64-branch.d: Likewise. + * testsuite/gas/i386/x86-64-align-branch-9.d: Likewise. + * testsuite/gas/i386/x86-64-branch.d: Likewise. + 2020-12-11 Sergey Belyashov Nick Clifton diff --git a/gas/testsuite/gas/i386/align-branch-9.d b/gas/testsuite/gas/i386/align-branch-9.d index 2d5ceef09b1..643ca283bc0 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 + 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 + 3d: 74 45 je 84 <.*> 3f: 5d pop %ebp - 40: 74 42 je 84 + 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 + 5c: eb 2c jmp 8a <.*> 5e: 66 90 xchg %ax,%ax - 60: eb 28 jmp 8a - 62: eb 26 jmp 8a + 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 + 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 + 82: 7c 06 jl 8a <.*> +00000084 : 84: 8b 45 f4 mov -0xc\(%ebp\),%eax 87: 89 45 fc mov %eax,-0x4\(%ebp\) +0000008a : 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 - c7: 74 c1 je 8a + 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 357abe30f97..acba220b7a8 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 6d25b950830..343544b3757 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 968a1818970..3a807895757 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 d5f2358546f..acf8c42ca97 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 1041fd04833..35f56ad8dda 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+ : 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 + 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 + 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 + 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 917579bda40..59507f8ad26 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 b963f9f051e..02509d21bc3 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]+