[lld] [lld][ELF] Add armeb support when incoming bc is arm big endian (PR #72604)

dong jianqiang via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 17 01:26:20 PST 2023


https://github.com/dongjianqiang2 updated https://github.com/llvm/llvm-project/pull/72604

>From 0939deb984084535302843dc36dc10a84e8adf9c Mon Sep 17 00:00:00 2001
From: Dong JianQiang <dongjianqiang2 at huawei.com>
Date: Thu, 16 Nov 2023 20:55:05 +0800
Subject: [PATCH] [lld][ELF] Add armeb support when incoming bc is arm big
 endian

---
 lld/ELF/InputFiles.cpp      |  2 ++
 lld/test/ELF/lto/armeb.ll   | 12 ++++++++++++
 lld/test/ELF/lto/thumbeb.ll | 12 ++++++++++++
 3 files changed, 26 insertions(+)
 create mode 100644 lld/test/ELF/lto/armeb.ll
 create mode 100644 lld/test/ELF/lto/thumbeb.ll

diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 4b4d7d6db93cd57..17ecd047e015287 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1582,7 +1582,9 @@ static uint16_t getBitcodeMachineKind(StringRef path, const Triple &t) {
   case Triple::r600:
     return EM_AMDGPU;
   case Triple::arm:
+  case Triple::armeb:
   case Triple::thumb:
+  case Triple::thumbeb:
     return EM_ARM;
   case Triple::avr:
     return EM_AVR;
diff --git a/lld/test/ELF/lto/armeb.ll b/lld/test/ELF/lto/armeb.ll
new file mode 100644
index 000000000000000..724b39ed2f930ba
--- /dev/null
+++ b/lld/test/ELF/lto/armeb.ll
@@ -0,0 +1,12 @@
+; REQUIRES: arm
+; RUN: llvm-as %s -o %t.bc
+; RUN: ld.lld %t.bc -o %t.o
+ 
+;; Test we can infer the e_machine value EM_ARM from a bitcode file.
+ 
+target triple = "armebv7-linux-musleabi"
+target datalayout = "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+ 
+define dso_local void @_start() #0 {
+  ret void
+}
diff --git a/lld/test/ELF/lto/thumbeb.ll b/lld/test/ELF/lto/thumbeb.ll
new file mode 100644
index 000000000000000..a0af3fb1b7dfb27
--- /dev/null
+++ b/lld/test/ELF/lto/thumbeb.ll
@@ -0,0 +1,12 @@
+; REQUIRES: thumb
+; RUN: llvm-as %s -o %t.bc
+; RUN: ld.lld %t.bc -o %t.o
+ 
+;; Test we can infer the e_machine value EM_ARM from bitcode file.
+ 
+target triple = "thumbebv7-linux-musleabi"
+target datalayout = "E-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+ 
+define dso_local void @_start() #0 {
+  ret void
+}



More information about the llvm-commits mailing list