[PATCH] D14700: [mips][freebsd] Explicitly select PC-relative Personality and LSDA encodings.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 04:11:15 PST 2015


dsanders created this revision.
dsanders added subscribers: emaste, seanbruno, llvm-commits.
Herald added subscribers: dsanders, srhines, danalbert, tberghammer.

The Mips port of FreeBSD is currently using an old linker (GNU ld 2.17.50
[FreeBSD] 2007-07-03) which seems to be unable to fully support read-only
.eh_frame sections. However, there exists a patch to fix this (see PR25176)
which adds the missing R_MIPS_PC32 relocation and also seems to fix some
.eh_frame-related crashes.

This patch makes clang use appropriate encodings to support read-only .eh_frame
sections with this patched linker.

http://reviews.llvm.org/D14700

Files:
  lib/MC/MCObjectFileInfo.cpp
  test/CodeGen/Mips/ehframe-indirect.ll

Index: test/CodeGen/Mips/ehframe-indirect.ll
===================================================================
--- test/CodeGen/Mips/ehframe-indirect.ll
+++ test/CodeGen/Mips/ehframe-indirect.ll
@@ -1,15 +1,32 @@
-; RUN: llc -mtriple=mipsel-linux-gnu < %s -asm-verbose | FileCheck -check-prefix=ALL -check-prefix=O32 %s
-; RUN: llc -mtriple=mipsel-linux-android < %s -asm-verbose | FileCheck -check-prefix=ALL -check-prefix=O32 %s
-; RUN: llc -mtriple=mips64el-linux-gnu -target-abi=n32 < %s -asm-verbose | FileCheck -check-prefix=ALL -check-prefix=N32 %s
-; RUN: llc -mtriple=mips64el-linux-android -target-abi=n32 < %s -asm-verbose | FileCheck -check-prefix=ALL -check-prefix=N32 %s
-; RUN: llc -mtriple=mips64el-linux-gnu < %s -asm-verbose | FileCheck -check-prefix=ALL -check-prefix=N64 %s
-; RUN: llc -mtriple=mips64el-linux-android < %s -asm-verbose | FileCheck -check-prefix=ALL -check-prefix=N64 %s
+; RUN: llc -mtriple=mipsel-linux-gnu < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=LINUX -check-prefix=O32 %s
+; RUN: llc -mtriple=mipsel-linux-android < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=LINUX -check-prefix=O32 %s
+; RUN: llc -mtriple=mips64el-linux-gnu -target-abi=n32 < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=LINUX -check-prefix=N32 %s
+; RUN: llc -mtriple=mips64el-linux-android -target-abi=n32 < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=LINUX -check-prefix=N32 %s
+; RUN: llc -mtriple=mips64el-linux-gnu < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=LINUX -check-prefix=N64 %s
+; RUN: llc -mtriple=mips64el-linux-android < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=LINUX -check-prefix=N64 %s
+; RUN: llc -mtriple=mips64el-linux-gnu < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=LINUX -check-prefix=N64 %s
+; RUN: llc -mtriple=mips64-unknown-freebsd11.0 < %s -asm-verbose | \
+; RUN:     FileCheck -check-prefix=ALL -check-prefix=FREEBSD -check-prefix=N64 %s
 
 @_ZTISt9exception = external constant i8*
 
 define i32 @main() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
 ; ALL: .cfi_startproc
-; ALL: .cfi_personality 128, DW.ref.__gxx_personality_v0
+
+; Linux must rely on the assembler/linker converting the encodings.
+; LINUX: .cfi_personality 128, DW.ref.__gxx_personality_v0
+; LINUX: .cfi_lsda 0, $exception0
+
+; FreeBSD can (and must) be more direct about the encodings it wants.
+; FREEBSD: .cfi_personality 155, DW.ref.__gxx_personality_v0
+; FREEBSD: .cfi_lsda 27, $exception0
 
 entry:
   invoke void @foo() to label %cont unwind label %lpad
Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -368,6 +368,14 @@
                     dwarf::DW_EH_PE_sdata4;
     // We don't support PC-relative LSDA references in GAS so we use the default
     // DW_EH_PE_absptr for those.
+
+    // FreeBSD must be explicit about the data size and using pcrel since it's
+    // assembler/linker won't do the automatic conversion that the Linux tools
+    // do.
+    if (T.isOSFreeBSD()) {
+      PersonalityEncoding |= dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
+      LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
+    }
     break;
   case Triple::ppc64:
   case Triple::ppc64le:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14700.40274.patch
Type: text/x-patch
Size: 3491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/ef3ecc43/attachment.bin>


More information about the llvm-commits mailing list