This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: V3 [PATCH 4/4] i386: Add tests for -malign-branch-boundary and -malign-branch


Hi HJ,

The call instructions in the 2 test cases below are on 32 byte boundaries while -malign-branch-boundary=32 and -malign-branch=indirect+call are set. It seems to me that this is exactly when those test cases should fail. Am I missing something here or is there a mistake? If the former, can you please explain me why these are correct?

Thanks
Egeyar


On 12/6/19 8:11 PM, H.J. Lu wrote:
Add tests for -malign-branch-boundary, -malign-branch and
-mbranches-within-32B-boundaries.


diff --git a/gas/testsuite/gas/i386/align-branch-3.d b/gas/testsuite/gas/i386/align-branch-3.d
new file mode 100644
index 0000000000..da31b6f503
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-3.d
@@ -0,0 +1,33 @@
+#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+   6:	55                   	push   %ebp
+   7:	55                   	push   %ebp
+   8:	55                   	push   %ebp
+   9:	55                   	push   %ebp
+   a:	89 e5                	mov    %esp,%ebp
+   c:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+   f:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  1e:	e8 fc ff ff ff       	call   1f <foo\+0x1f>
+  23:	55                   	push   %ebp
+  24:	55                   	push   %ebp
+  25:	64 a3 01 00 00 00    	mov    %eax,%fs:0x1
+  2b:	89 e5                	mov    %esp,%ebp
+  2d:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  30:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+  3c:	ff 91 00 00 00 00    	call   \*0x0\(%ecx\)
+  42:	89 75 f4             	mov    %esi,-0xc\(%ebp\)
+#pass
diff --git a/gas/testsuite/gas/i386/align-branch-3.s b/gas/testsuite/gas/i386/align-branch-3.s
new file mode 100644
index 0000000000..e3e6c447c4
--- /dev/null
+++ b/gas/testsuite/gas/i386/align-branch-3.s
@@ -0,0 +1,28 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  pushl  %ebp
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  call	___tls_get_addr
+  pushl  %ebp
+  pushl  %ebp
+  movl  %eax, %fs:0x1
+  movl  %esp, %ebp
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  movl  %esi, -12(%ebp)
+  call *___tls_get_addr@GOT(%ecx)
+  movl  %esi, -12(%ebp)

diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-3.d b/gas/testsuite/gas/i386/x86-64-align-branch-3.d
new file mode 100644
index 0000000000..18767a7045
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-3.d
@@ -0,0 +1,32 @@
+#as: -malign-branch-boundary=32 -malign-branch=indirect+call
+#objdump: -dw
+
+.*: +file format .*
+
+Disassembly of section .text:
+
+0+ <foo>:
+   0:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+   8:	55                   	push   %rbp
+   9:	55                   	push   %rbp
+   a:	55                   	push   %rbp
+   b:	55                   	push   %rbp
+   c:	48 89 e5             	mov    %rsp,%rbp
+   f:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  12:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  15:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  18:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1b:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  1e:	e8 00 00 00 00       	callq  23 <foo\+0x23>
+  23:	55                   	push   %rbp
+  24:	55                   	push   %rbp
+  25:	64 89 04 25 01 00 00 00 	mov    %eax,%fs:0x1
+  2d:	48 89 e5             	mov    %rsp,%rbp
+  30:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  33:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  36:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  39:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3c:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+  3f:	ff 15 00 00 00 00    	callq  \*0x0\(%rip\)        # 45 <foo\+0x45>
+  45:	89 75 f4             	mov    %esi,-0xc\(%rbp\)
+#pass
diff --git a/gas/testsuite/gas/i386/x86-64-align-branch-3.s b/gas/testsuite/gas/i386/x86-64-align-branch-3.s
new file mode 100644
index 0000000000..6787cdc36f
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-align-branch-3.s
@@ -0,0 +1,27 @@
+  .text
+  .globl  foo
+  .p2align  4
+foo:
+  movl  %eax, %fs:0x1
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  pushq  %rbp
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  call	__tls_get_addr
+  pushq  %rbp
+  pushq  %rbp
+  movl  %eax, %fs:0x1
+  movq  %rsp, %rbp
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  movl  %esi, -12(%rbp)
+  call	*__tls_get_addr@GOTPCREL(%rip)
+  movl  %esi, -12(%rbp)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]