summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan Chien <tzuhsiang.chien@gmail.com>2016-11-13 14:44:41 +0000
committerLogan Chien <tzuhsiang.chien@gmail.com>2016-11-13 14:44:41 +0000
commitcc4f512be04098946b4f875d18bd4d69cbcd7463 (patch)
tree19e66d5d68051e6bb725df6e394b21a0cdb35913
parent6962eb354b46062b997a740efa1c63724a8d3caf (diff)
arm: Fix ttype encoding assertion failure.
GCC 4.7 or newer emits 0x90 (indirect | pcrel) as the ttype encoding. This would hit an assertion in cxa_personality.cpp. This commit fixes the problem by relaxing the assertion. git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@286760 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--src/cxa_personality.cpp10
-rw-r--r--test/lit.cfg2
-rw-r--r--test/lit.site.cfg.in2
-rw-r--r--test/native/arm-linux-eabi/lit.local.cfg6
-rw-r--r--test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s97
-rw-r--r--test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s96
6 files changed, 210 insertions, 3 deletions
diff --git a/src/cxa_personality.cpp b/src/cxa_personality.cpp
index 0b75a1c..75f6b4a 100644
--- a/src/cxa_personality.cpp
+++ b/src/cxa_personality.cpp
@@ -348,7 +348,10 @@ get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,
call_terminate(native_exception, unwind_exception);
}
- assert(ttypeEncoding == DW_EH_PE_absptr && "Unexpected TTypeEncoding");
+ assert(((ttypeEncoding == DW_EH_PE_absptr) || // LLVM or GCC 4.6
+ (ttypeEncoding == DW_EH_PE_pcrel) || // GCC 4.7 baremetal
+ (ttypeEncoding == (DW_EH_PE_pcrel | DW_EH_PE_indirect))) && // GCC 4.7 linux
+ "Unexpected TTypeEncoding");
(void)ttypeEncoding;
const uint8_t* ttypePtr = classInfo - ttypeIndex * sizeof(uintptr_t);
@@ -415,7 +418,10 @@ exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,
call_terminate(false, unwind_exception);
}
- assert(ttypeEncoding == DW_EH_PE_absptr && "Unexpected TTypeEncoding");
+ assert(((ttypeEncoding == DW_EH_PE_absptr) || // LLVM or GCC 4.6
+ (ttypeEncoding == DW_EH_PE_pcrel) || // GCC 4.7 baremetal
+ (ttypeEncoding == (DW_EH_PE_pcrel | DW_EH_PE_indirect))) && // GCC 4.7 linux
+ "Unexpected TTypeEncoding");
(void)ttypeEncoding;
// specIndex is negative of 1-based byte offset into classInfo;
diff --git a/test/lit.cfg b/test/lit.cfg
index a97dada..29d1a3b 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -18,7 +18,7 @@ if 'PYLINT_IMPORT' in os.environ:
config.name = 'libc++abi'
# suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.cpp']
+config.suffixes = ['.cpp', '.s']
# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index e1ab50d..57e448a 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -16,6 +16,8 @@ config.executor = "@LIBCXXABI_EXECUTOR@"
config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
config.enable_shared = "@LIBCXX_ENABLE_SHARED@"
config.enable_exceptions = "@LIBCXXABI_ENABLE_EXCEPTIONS@"
+config.host_triple = "@LLVM_HOST_TRIPLE@"
+config.target_triple = "@TARGET_TRIPLE@"
# Let the main config do the real work.
lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")
diff --git a/test/native/arm-linux-eabi/lit.local.cfg b/test/native/arm-linux-eabi/lit.local.cfg
new file mode 100644
index 0000000..1b2c20c
--- /dev/null
+++ b/test/native/arm-linux-eabi/lit.local.cfg
@@ -0,0 +1,6 @@
+def is_arm_linux_eabi(triple):
+ return ('arm' in triple) and ('linux' in triple) and ('eabi' in triple)
+
+is_native = config.root.host_triple == config.root.target_triple
+if not is_native or not is_arm_linux_eabi(config.root.host_triple):
+ config.unsupported = True
diff --git a/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s b/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
new file mode 100644
index 0000000..2c9f720
--- /dev/null
+++ b/test/native/arm-linux-eabi/ttype-encoding-00.pass.sh.s
@@ -0,0 +1,97 @@
+@ RUN: %cxx %flags %link_flags %s -o %t.exe
+@ RUN: %exec %t.exe
+
+@ PURPOSE: Check that 0x00 is a valid value for ttype encoding. LLVM and
+@ GCC 4.6 are generating 0x00 as ttype encoding. libc++abi should provide
+@ legacy support.
+
+@ NOTE:
+@
+@ This file is generated from the following C++ source code:
+@
+@ ```
+@ int main() {
+@ try {
+@ throw 5;
+@ } catch (int i) {
+@ if (i != 5)
+@ abort();
+@ return 0;
+@ }
+@ }
+@ ```
+
+ .syntax unified
+
+ .text
+ .globl main
+ .p2align 2
+ .type main,%function
+main: @ @main
+.Lfunc_begin0:
+ .fnstart
+@ BB#0: @ %entry
+ .save {r11, lr}
+ push {r11, lr}
+ .setfp r11, sp
+ mov r11, sp
+ mov r0, #4
+ bl __cxa_allocate_exception
+ mov r1, #5
+ str r1, [r0]
+.Ltmp0:
+ ldr r1, .LCPI0_0
+ mov r2, #0
+ bl __cxa_throw
+.Ltmp1:
+
+@ BB#2: @ %lpad
+.Ltmp2:
+ bl __cxa_begin_catch
+ ldr r0, [r0]
+ cmp r0, #5
+ bne .LBB0_4
+@ BB#3: @ %if.end
+ bl __cxa_end_catch
+ mov r0, #0
+ pop {r11, lr}
+ bx lr
+.LBB0_4: @ %if.then
+ bl abort
+ .p2align 2
+@ BB#5:
+.LCPI0_0:
+ .long _ZTIi
+.Lfunc_end0:
+
+ .size main, .Lfunc_end0-main
+ .globl __gxx_personality_v0
+ .personality __gxx_personality_v0
+ .handlerdata
+ .p2align 2
+GCC_except_table0:
+.Lexception0:
+ .byte 255 @ @LPStart Encoding = omit
+ .byte 0 @ @TType Encoding = absptr
+ .asciz "\257\200" @ @TType base offset
+ .byte 3 @ Call site Encoding = udata4
+ .byte 39 @ Call site table length
+ .long .Lfunc_begin0-.Lfunc_begin0 @ >> Call Site 1 <<
+ .long .Ltmp0-.Lfunc_begin0 @ Call between .Lfunc_begin0 and .Ltmp0
+ .long 0 @ has no landing pad
+ .byte 0 @ On action: cleanup
+ .long .Ltmp0-.Lfunc_begin0 @ >> Call Site 2 <<
+ .long .Ltmp1-.Ltmp0 @ Call between .Ltmp0 and .Ltmp1
+ .long .Ltmp2-.Lfunc_begin0 @ jumps to .Ltmp2
+ .byte 1 @ On action: 1
+ .long .Ltmp1-.Lfunc_begin0 @ >> Call Site 3 <<
+ .long .Lfunc_end0-.Ltmp1 @ Call between .Ltmp1 and .Lfunc_end0
+ .long 0 @ has no landing pad
+ .byte 0 @ On action: cleanup
+ .byte 1 @ >> Action Record 1 <<
+ @ Catch TypeInfo 1
+ .byte 0 @ No further actions
+ @ >> Catch TypeInfos <<
+ .long _ZTIi(target2) @ TypeInfo 1
+ .p2align 2
+ .fnend
diff --git a/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s b/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s
new file mode 100644
index 0000000..bb362c4
--- /dev/null
+++ b/test/native/arm-linux-eabi/ttype-encoding-90.pass.sh.s
@@ -0,0 +1,96 @@
+@ RUN: %cxx %flags %link_flags %s -o %t.exe
+@ RUN: %exec %t.exe
+
+@ PURPOSE: Check that 0x90 is a valid value for ttype encoding.
+
+@ NOTE:
+@
+@ This file is generated from the following C++ source code and then change the
+@ `TType Encoding` to 0x90.
+@
+@ ```
+@ int main() {
+@ try {
+@ throw 5;
+@ } catch (int i) {
+@ if (i != 5)
+@ abort();
+@ return 0;
+@ }
+@ }
+@ ```
+
+ .syntax unified
+
+ .text
+ .globl main
+ .p2align 2
+ .type main,%function
+main: @ @main
+.Lfunc_begin0:
+ .fnstart
+@ BB#0: @ %entry
+ .save {r11, lr}
+ push {r11, lr}
+ .setfp r11, sp
+ mov r11, sp
+ mov r0, #4
+ bl __cxa_allocate_exception
+ mov r1, #5
+ str r1, [r0]
+.Ltmp0:
+ ldr r1, .LCPI0_0
+ mov r2, #0
+ bl __cxa_throw
+.Ltmp1:
+
+@ BB#2: @ %lpad
+.Ltmp2:
+ bl __cxa_begin_catch
+ ldr r0, [r0]
+ cmp r0, #5
+ bne .LBB0_4
+@ BB#3: @ %if.end
+ bl __cxa_end_catch
+ mov r0, #0
+ pop {r11, lr}
+ bx lr
+.LBB0_4: @ %if.then
+ bl abort
+ .p2align 2
+@ BB#5:
+.LCPI0_0:
+ .long _ZTIi
+.Lfunc_end0:
+
+ .size main, .Lfunc_end0-main
+ .globl __gxx_personality_v0
+ .personality __gxx_personality_v0
+ .handlerdata
+ .p2align 2
+GCC_except_table0:
+.Lexception0:
+ .byte 255 @ @LPStart Encoding = omit
+ .byte 0x90 @ @TType Encoding = indirect | pcrel
+ .asciz "\257\200" @ @TType base offset
+ .byte 3 @ Call site Encoding = udata4
+ .byte 39 @ Call site table length
+ .long .Lfunc_begin0-.Lfunc_begin0 @ >> Call Site 1 <<
+ .long .Ltmp0-.Lfunc_begin0 @ Call between .Lfunc_begin0 and .Ltmp0
+ .long 0 @ has no landing pad
+ .byte 0 @ On action: cleanup
+ .long .Ltmp0-.Lfunc_begin0 @ >> Call Site 2 <<
+ .long .Ltmp1-.Ltmp0 @ Call between .Ltmp0 and .Ltmp1
+ .long .Ltmp2-.Lfunc_begin0 @ jumps to .Ltmp2
+ .byte 1 @ On action: 1
+ .long .Ltmp1-.Lfunc_begin0 @ >> Call Site 3 <<
+ .long .Lfunc_end0-.Ltmp1 @ Call between .Ltmp1 and .Lfunc_end0
+ .long 0 @ has no landing pad
+ .byte 0 @ On action: cleanup
+ .byte 1 @ >> Action Record 1 <<
+ @ Catch TypeInfo 1
+ .byte 0 @ No further actions
+ @ >> Catch TypeInfos <<
+ .long _ZTIi(target2) @ TypeInfo 1
+ .p2align 2
+ .fnend