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

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 19:04:09 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld-elf

Author: dong jianqiang (dongjianqiang2)

<details>
<summary>Changes</summary>

Add armeb support when incoming bc is arm big endian:
Fix error: could not infer e_machine from bitcode target triple armebv7-linux-gnueabi.

---
Full diff: https://github.com/llvm/llvm-project/pull/72604.diff


2 Files Affected:

- (modified) lld/ELF/InputFiles.cpp (+2) 
- (added) lld/test/ELF/lto/armeb.ll (+12) 


``````````diff
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..77ac4e1297a63fe
--- /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
+ 
+; Make sure the armeb triple is handled
+ 
+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
+}

``````````

</details>


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


More information about the llvm-commits mailing list