[llvm-branch-commits] [llvm] release/19.x: [BinaryFormat] Disable MachOTest.UnalignedLC on SPARC (#100086) (PR #102103)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 6 00:15:47 PDT 2024
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/102103
Backport 3a226dbe27ac7c7d935bc0968e84e31798a01207
Requested by: @rorth
>From 7d36f22d285d3142213ec4c8312b2a8f0f7ea83f Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Tue, 6 Aug 2024 09:08:41 +0200
Subject: [PATCH] [BinaryFormat] Disable MachOTest.UnalignedLC on SPARC
(#100086)
As discussed in Issue #86793, the `MachOTest.UnalignedLC` test dies with
`SIGBUS` on SPARC, a strict-alignment target. It simply cannot work
there. Besides, the test invokes undefined behaviour on big-endian
targets, so this patch disables it on all of those.
Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.
(cherry picked from commit 3a226dbe27ac7c7d935bc0968e84e31798a01207)
---
llvm/unittests/BinaryFormat/MachOTest.cpp | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/llvm/unittests/BinaryFormat/MachOTest.cpp b/llvm/unittests/BinaryFormat/MachOTest.cpp
index 391298ff38d76..78b20c28a9549 100644
--- a/llvm/unittests/BinaryFormat/MachOTest.cpp
+++ b/llvm/unittests/BinaryFormat/MachOTest.cpp
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/bit.h"
#include "llvm/BinaryFormat/MachO.h"
#include "llvm/TargetParser/Triple.h"
#include "gtest/gtest.h"
@@ -13,7 +14,15 @@
using namespace llvm;
using namespace llvm::MachO;
-TEST(MachOTest, UnalignedLC) {
+#if BYTE_ORDER == BIG_ENDIAN
+// As discussed in Issue #86793, this test cannot work on a strict-alignment
+// targets like SPARC. Besides, it's undefined behaviour on big-endian hosts.
+#define MAYBE_UnalignedLC DISABLED_UnalignedLC
+#else
+#define MAYBE_UnalignedLC UnalignedLC
+#endif
+
+TEST(MachOTest, MAYBE_UnalignedLC) {
unsigned char Valid32BitMachO[] = {
0xCE, 0xFA, 0xED, 0xFE, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00,
More information about the llvm-branch-commits
mailing list