[PATCH] [mips][microMIPS] Relocate with symbol for micromips function symbols

Zoran Jovanovic zoran.jovanovic at imgtec.com
Tue Dec 30 02:12:11 PST 2014


Labels also relocated with the symbol.


http://reviews.llvm.org/D6796

Files:
  lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
  test/MC/Mips/micromips-func-addr.s

Index: lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
===================================================================
--- lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -12,6 +12,7 @@
 #include "MCTargetDesc/MipsMCTargetDesc.h"
 #include "llvm/MC/MCAssembler.h"
 #include "llvm/MC/MCELFObjectWriter.h"
+#include "llvm/MC/MCELF.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCValue.h"
@@ -244,8 +245,11 @@
   case ELF::R_MICROMIPS_LO16:
     return true;
 
-  case ELF::R_MIPS_26:
   case ELF::R_MIPS_32:
+    if (MCELF::getOther(SD) & (ELF::STO_MIPS_MICROMIPS >> 2))
+      return true;
+    // falltrough
+  case ELF::R_MIPS_26:
   case ELF::R_MIPS_64:
   case ELF::R_MIPS_GPREL16:
     return false;
Index: test/MC/Mips/micromips-func-addr.s
===================================================================
--- /dev/null
+++ test/MC/Mips/micromips-func-addr.s
@@ -0,0 +1,15 @@
+# RUN: llvm-mc %s -filetype=obj -triple=mipsel-unknown-linux \
+# RUN: -mattr=micromips | llvm-readobj -r \
+# RUN: | FileCheck %s -check-prefix=CHECK
+# CHECK: Relocations [
+# CHECK:     0x0 R_MIPS_32 bar 0x0
+# CHECK:     0x8 R_MIPS_32 foo 0x0
+
+  .set    micromips
+  .type   bar, at function
+bar:
+  .4byte bar
+foo:
+  nop
+  .4byte foo 
+

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6796.17714.patch
Type: text/x-patch
Size: 1341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141230/bbbcfc0a/attachment.bin>


More information about the llvm-commits mailing list