[lld] f3da6b7 - Add duplex to R_HEX_GOT_16_X

Brian Cain via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 17:32:52 PDT 2020


Author: Brian Cain
Date: 2020-04-13T19:32:44-05:00
New Revision: f3da6b7ab5698bb0b9bd208972115dbcbbc59f27

URL: https://github.com/llvm/llvm-project/commit/f3da6b7ab5698bb0b9bd208972115dbcbbc59f27
DIFF: https://github.com/llvm/llvm-project/commit/f3da6b7ab5698bb0b9bd208972115dbcbbc59f27.diff

LOG: Add duplex to R_HEX_GOT_16_X

Building 'espresso' from llvm-test-suite revealed missing support
for duplex instructions with R_HEX_GOT_16_X.

Added: 
    

Modified: 
    lld/ELF/Arch/Hexagon.cpp
    lld/test/ELF/hexagon-shared.s

Removed: 
    


################################################################################
diff  --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp
index 730c47a88dfd..27b20baceeed 100644
--- a/lld/ELF/Arch/Hexagon.cpp
+++ b/lld/ELF/Arch/Hexagon.cpp
@@ -161,6 +161,13 @@ RelExpr Hexagon::getRelExpr(RelType type, const Symbol &s,
   }
 }
 
+static bool isDuplex(uint32_t insn) {
+  // Duplex forms have a fixed mask and parse bits 15:14 are always
+  // zero.  Non-duplex insns will always have at least one bit set in the
+  // parse field.
+  return (0xC000 & insn) == 0;
+}
+
 static uint32_t findMaskR6(uint32_t insn) {
   // There are (arguably too) many relocation masks for the DSP's
   // R_HEX_6_X type.  The table below is used to select the correct mask
@@ -185,10 +192,7 @@ static uint32_t findMaskR6(uint32_t insn) {
       {0xd7000000, 0x006020e0}, {0xd8000000, 0x006020e0},
       {0xdb000000, 0x006020e0}, {0xdf000000, 0x006020e0}};
 
-  // Duplex forms have a fixed mask and parse bits 15:14 are always
-  // zero.  Non-duplex insns will always have at least one bit set in the
-  // parse field.
-  if ((0xC000 & insn) == 0x0)
+  if (isDuplex(insn))
     return 0x03f00000;
 
   for (InstructionMask i : r6)
@@ -224,6 +228,9 @@ static uint32_t findMaskR16(uint32_t insn) {
   if ((0xff000000 & insn) == 0xb0000000)
     return 0x0fe03fe0;
 
+  if (isDuplex(insn))
+    return 0x03f00000;
+
   error("unrecognized instruction for R_HEX_16_X relocation: 0x" +
         utohexstr(insn));
   return 0;

diff  --git a/lld/test/ELF/hexagon-shared.s b/lld/test/ELF/hexagon-shared.s
index 6bc1bd567ed5..d1d925414978 100644
--- a/lld/test/ELF/hexagon-shared.s
+++ b/lld/test/ELF/hexagon-shared.s
@@ -38,6 +38,11 @@ jumpr r0
 # R_HEX_GOT_16_X
 r0 = add(r1,##bar at GOT)
 
+# R_HEX_GOT_16_X, duplex
+{ r0 = add(r0,##bar at GOT)
+  memw(r0) = r2 }
+
+
 # foo is local so no plt will be generated
 foo:
   jumpr lr
@@ -78,6 +83,7 @@ pvar:
 # TEXT: if (p0) jump:nt 0x102d0
 # TEXT: r0 = #0 ; jump 0x102d0
 # TEXT: r0 = add(r1,##-65548)
+# TEXT: r0 = add(r0,##-65548); memw(r0+#0) = r2 }
 
 # GOT: .got:
 # GOT:  00 00 00 00 00000000 <unknown>


        


More information about the llvm-commits mailing list