[PATCH] D52876: [mips] Fix FDE/CFI encoding in case of N32 ABI

Simon Atanasyan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 4 03:43:42 PDT 2018


atanasyan created this revision.
atanasyan added reviewers: abeserminji, petarj, smaksimovic.
Herald added subscribers: jrtc27, arichardson, sdardis.

For O32 and N32 ABI FDE/CFI encoding should be DW_EH_PE_sdata4 and only N64 ABI uses DW_EH_PE_sdata8. To cover all cases this patch check code pointer size and setup a correct FDE/CFI encoding type.


Repository:
  rL LLVM

https://reviews.llvm.org/D52876

Files:
  lib/MC/MCObjectFileInfo.cpp
  test/MC/Mips/cfi-encoding.s


Index: test/MC/Mips/cfi-encoding.s
===================================================================
--- /dev/null
+++ test/MC/Mips/cfi-encoding.s
@@ -0,0 +1,23 @@
+# RUN: llvm-mc -filetype=obj -triple mips--gnu -g %s \
+# RUN:   | llvm-objdump -s -section=.eh_frame - | FileCheck --check-prefix=O32 %s
+# RUN: llvm-mc -filetype=obj -triple mips64--gnuabin32 -g %s \
+# RUN:   | llvm-objdump -s -section=.eh_frame - | FileCheck --check-prefix=N32 %s
+# RUN: llvm-mc -filetype=obj -triple mips64--gnuabi64 -g %s \
+# RUN:   | llvm-objdump -s -section=.eh_frame - | FileCheck --check-prefix=N64 %s
+
+# O32: 0000 00000010 00000000 017a5200 017c1f01
+# O32: 0010 0b0c1d00 00000010 00000018 00000000
+# O32: 0020 00000004 00000000
+
+# N32: 0000 00000010 00000000 017a5200 017c1f01
+# N32: 0010 0b0c1d00 00000010 00000018 00000000
+# N32: 0020 00000004 00000000
+
+# N64: 0000 00000010 00000000 017a5200 01781f01
+# N64: 0010 0c0c1d00 00000018 00000018 00000000
+# N64: 0020 00000000 00000000 00000004 00000000
+
+foo:
+  .cfi_startproc
+  nop
+  .cfi_endproc
Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -291,11 +291,11 @@
   switch (T.getArch()) {
   case Triple::mips:
   case Triple::mipsel:
-    FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
-    break;
   case Triple::mips64:
   case Triple::mips64el:
-    FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
+    FDECFIEncoding = Ctx->getAsmInfo()->getCodePointerSize() == 4
+                         ? dwarf::DW_EH_PE_sdata4
+                         : dwarf::DW_EH_PE_sdata8;
     break;
   case Triple::ppc64:
   case Triple::ppc64le:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52876.168259.patch
Type: text/x-patch
Size: 1703 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181004/6fc5cad8/attachment.bin>


More information about the llvm-commits mailing list