[PATCH] D16349: [AArch64] Fix two bugs in the .inst directive
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 20 04:12:13 PST 2016
olista01 created this revision.
olista01 added a reviewer: t.p.northover.
olista01 added a subscriber: llvm-commits.
olista01 set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.
The AArch64 .inst directive was implemented using EmitIntValue, which resulted in both $x and $d (code and data) mapping symbols being emitted at the same address. This fixes it to only emit the $x mapping symbol.
EmitIntValue also emits the value in big-endian order when targeting big-endian systems, but instructions are always emitted in little-endian order for AArch64.
Repository:
rL LLVM
http://reviews.llvm.org/D16349
Files:
lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
test/MC/AArch64/inst-directive.s
Index: test/MC/AArch64/inst-directive.s
===================================================================
--- test/MC/AArch64/inst-directive.s
+++ test/MC/AArch64/inst-directive.s
@@ -1,7 +1,14 @@
// RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=asm -o - \
// RUN: | FileCheck %s --check-prefix=CHECK-ASM
-// RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=obj -o - \
-// RUN: | llvm-readobj -s -sd | FileCheck %s --check-prefix=CHECK-OBJ
+// RUN: llvm-mc %s -triple=aarch64-none-linux-gnu -filetype=obj -o %t
+// RUN: llvm-readobj -s -sd %t | FileCheck %s --check-prefix=CHECK-OBJ
+// RUN: llvm-objdump -t %t | FileCheck %s --check-prefix=CHECK-SYMS
+
+// RUN: llvm-mc %s -triple=aarch64_be-none-linux-gnu -filetype=asm -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-ASM
+// RUN: llvm-mc %s -triple=aarch64_be-none-linux-gnu -filetype=obj -o %t
+// RUN: llvm-readobj -s -sd %t | FileCheck %s --check-prefix=CHECK-OBJ
+// RUN: llvm-objdump -t %t | FileCheck %s --check-prefix=CHECK-SYMS
.section .inst.aarch64_inst
@@ -22,3 +29,7 @@
// CHECK-OBJ: SectionData (
// CHECK-OBJ-NEXT: 0000: 2040105E
// CHECK-OBJ-NEXT: )
+
+// CHECK-SYMS-NOT: 0000000000000000 .inst.aarch64_inst 00000000 $d
+// CHECK-SYMS: 0000000000000000 .inst.aarch64_inst 00000000 $x
+// CHECK-SYMS-NOT: 0000000000000000 .inst.aarch64_inst 00000000 $d
Index: lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
===================================================================
--- lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
+++ lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
@@ -113,8 +113,18 @@
}
void emitInst(uint32_t Inst) {
+ char Buffer[4];
+
+ // We can't just use EmitIntValue here, as that will emit a data mapping
+ // symbol, and swap the endianness on big-endian systems (instructions are
+ // always little-endian).
+ for (unsigned I = 0; I < 4; ++I) {
+ Buffer[I] = uint8_t(Inst);
+ Inst >>= 8;
+ }
+
EmitA64MappingSymbol();
- MCELFStreamer::EmitIntValue(Inst, 4);
+ MCELFStreamer::EmitBytes(StringRef(Buffer, 4));
}
/// This is one of the functions used to emit data into an ELF section, so the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16349.45370.patch
Type: text/x-patch
Size: 2280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160120/0fd730ec/attachment.bin>
More information about the llvm-commits
mailing list