[lld] [lld] Add thunks for hexagon (PR #111217)

Brian Cain via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 08:26:16 PST 2024


================
@@ -253,6 +260,35 @@ static uint32_t findMaskR16(uint32_t insn) {
 
 static void or32le(uint8_t *p, int32_t v) { write32le(p, read32le(p) | v); }
 
+bool Hexagon::inBranchRange(RelType type, uint64_t src, uint64_t dst) const {
+  int64_t offset = dst - src;
+  switch (type) {
+  case llvm::ELF::R_HEX_B22_PCREL:
+  case llvm::ELF::R_HEX_PLT_B22_PCREL:
+  case llvm::ELF::R_HEX_GD_PLT_B22_PCREL:
+  case llvm::ELF::R_HEX_LD_PLT_B22_PCREL:
+    return llvm::isInt<22>(offset >> 2);
+  case llvm::ELF::R_HEX_B15_PCREL:
+    return llvm::isInt<15>(offset >> 2);
+    break;
+  case llvm::ELF::R_HEX_B13_PCREL:
+    return llvm::isInt<13>(offset >> 2);
+    break;
+  case llvm::ELF::R_HEX_B9_PCREL:
+    return llvm::isInt<9>(offset >> 2);
+  default:
+    return true;
+  }
+  llvm::report_fatal_error(StringRef(
----------------
androm3da wrote:

This is inconsistent, yes.  Maybe this should be `unreachable` instead?  The default case above should handle the unknown relocations and there should be no way to execute this code.

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


More information about the llvm-commits mailing list