aboutsummaryrefslogtreecommitdiffstats
path: root/test/MC/MachO
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-12 22:07:14 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-12 22:07:14 +0000
commitf08fde41f34d739c157b1d75dadbb864e7957cab (patch)
treec71e2e775d26fa83538ad6c34d1a297234e82e8c /test/MC/MachO
parent5027064c69c89ff605479d9e7eab2395a54b31e9 (diff)
downloadexternal_llvm-f08fde41f34d739c157b1d75dadbb864e7957cab.zip
external_llvm-f08fde41f34d739c157b1d75dadbb864e7957cab.tar.gz
external_llvm-f08fde41f34d739c157b1d75dadbb864e7957cab.tar.bz2
MC/Mach-O: Implement initial support for relaxation.
- The implementation is currently very brain dead and inefficient, but I have a clear plan on how to fix it. - The good news is, it works and correctly assembles 403.gcc (when built with Clang, at '-Os', '-Os -g', and '-O3'). Even better, at '-Os' and '-Os -g', the resulting binary is exactly equivalent to that when built with the system assembler. So it probably works! :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/MC/MachO')
-rw-r--r--test/MC/MachO/relax-jumps.s31
-rw-r--r--test/MC/MachO/relax-recompute-align.s37
2 files changed, 68 insertions, 0 deletions
diff --git a/test/MC/MachO/relax-jumps.s b/test/MC/MachO/relax-jumps.s
new file mode 100644
index 0000000..9c58aa76
--- /dev/null
+++ b/test/MC/MachO/relax-jumps.s
@@ -0,0 +1,31 @@
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+
+// FIXME: This is a horrible way of checking the output, we need an llvm-mc
+// based 'otool'. Use:
+// (f=relax-jumps;
+// llvm-mc -filetype=obj -o $f.mc.o $f.s &&
+// as -arch i386 -o $f.as.o $f.s &&
+// otool -tvr $f.mc.o | tail +2 > $f.mc.dump &&
+// otool -tvr $f.as.o | tail +2 > $f.as.dump &&
+// diff $f.{as,mc}.dump)
+// to examine the results in a more sensible fashion.
+
+// CHECK: ('_section_data', '\x90
+// CHECK: \x0f\x842\xff\xff\xff\x0f\x82\xe6\x00\x00\x00\x0f\x87&\xff\xff\xff\x0f\x8f\xda\x00\x00\x00\x0f\x88\x1a\xff\xff\xff\x0f\x83\xce\x00\x00\x00\x0f\x89\x0e\xff\xff\xff\x90
+// CHECK: \x901\xc0')
+
+L1:
+ .space 200, 0x90
+
+ je L1
+ jb L2
+ ja L1
+ jg L2
+ js L1
+ jae L2
+ jns L1
+
+ .space 200, 0x90
+L2:
+
+ xorl %eax, %eax
diff --git a/test/MC/MachO/relax-recompute-align.s b/test/MC/MachO/relax-recompute-align.s
new file mode 100644
index 0000000..2494025
--- /dev/null
+++ b/test/MC/MachO/relax-recompute-align.s
@@ -0,0 +1,37 @@
+// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump --dump-section-data | FileCheck %s
+
+// FIXME: This is a horrible way of checking the output, we need an llvm-mc
+// based 'otool'.
+
+// This is a case where llvm-mc computes a better layout than Darwin 'as'. This
+// issue is that after the first jmp slides, the .align size must be
+// recomputed -- otherwise the second jump will appear to be out-of-range for a
+// 1-byte jump.
+
+// CHECK: # Section 0
+// CHECK: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
+// CHECK: ('address', 0)
+// CHECK: ('size', 306)
+// CHECK: ('offset', 324)
+// CHECK: ('alignment', 4)
+// CHECK: ('reloc_offset', 0)
+// CHECK: ('num_reloc', 0)
+// CHECK: ('flags', 0x80000400)
+// CHECK: ('reserved1', 0)
+// CHECK: ('reserved2', 0)
+// CHECK: ),
+
+L0:
+ .space 0x8a, 0x90
+ jmp L0
+ .space (0xb3 - 0x8f), 0x90
+ jle L2
+ .space (0xcd - 0xb5), 0x90
+ .align 4, 0x90
+L1:
+ .space (0x130 - 0xd0),0x90
+ jl L1
+L2:
+
+.zerofill __DATA,__bss,_sym,4,2