Merge "Fix signal trampolines."
This commit is contained in:
commit
5cba3c6f8e
@ -55,6 +55,8 @@ libc_bionic_src_files_arm += \
|
||||
arch-arm/bionic/_exit_with_stack_teardown.S \
|
||||
arch-arm/bionic/libgcc_compat.c \
|
||||
arch-arm/bionic/memcmp.S \
|
||||
arch-arm/bionic/__restore_rt.S \
|
||||
arch-arm/bionic/__restore.S \
|
||||
arch-arm/bionic/_setjmp.S \
|
||||
arch-arm/bionic/setjmp.S \
|
||||
arch-arm/bionic/sigsetjmp.S \
|
||||
|
35
libc/arch-arm/bionic/__restore.S
Normal file
35
libc/arch-arm/bionic/__restore.S
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
// This function must have exactly this instruction sequence for gdb and libunwind.
|
||||
ENTRY_PRIVATE(__restore)
|
||||
mov r7, #__NR_sigreturn
|
||||
swi #0
|
||||
END(__restore)
|
35
libc/arch-arm/bionic/__restore_rt.S
Normal file
35
libc/arch-arm/bionic/__restore_rt.S
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
// This function must have exactly this instruction sequence for gdb and libunwind.
|
||||
ENTRY_PRIVATE(__restore_rt)
|
||||
mov r7, #__NR_rt_sigreturn
|
||||
swi #0
|
||||
END(__restore_rt)
|
@ -29,7 +29,7 @@ libc_common_src_files_arm64 += \
|
||||
libc_bionic_src_files_arm64 := \
|
||||
arch-arm64/bionic/__bionic_clone.S \
|
||||
arch-arm64/bionic/_exit_with_stack_teardown.S \
|
||||
arch-arm64/bionic/__rt_sigreturn.S \
|
||||
arch-arm64/bionic/__restore_rt.S \
|
||||
arch-arm64/bionic/_setjmp.S \
|
||||
arch-arm64/bionic/setjmp.S \
|
||||
arch-arm64/bionic/__set_tls.c \
|
||||
|
@ -28,7 +28,8 @@
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY_PRIVATE(__rt_sigreturn)
|
||||
mov x8, __NR_rt_sigreturn
|
||||
svc #0
|
||||
END(__rt_sigreturn)
|
||||
// This function must have exactly this instruction sequence for gdb and libunwind.
|
||||
ENTRY_PRIVATE(__restore_rt)
|
||||
mov x8, __NR_rt_sigreturn
|
||||
svc #0
|
||||
END(__restore_rt)
|
37
libc/arch-x86/bionic/__restore.S
Normal file
37
libc/arch-x86/bionic/__restore.S
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
// This function must have exactly this instruction sequence for gdb and libunwind.
|
||||
// This function must have exactly this name for gdb.
|
||||
ENTRY(__restore)
|
||||
popl %eax
|
||||
movl $__NR_sigreturn, %eax
|
||||
int $0x80
|
||||
END(__restore)
|
36
libc/arch-x86/bionic/__restore_rt.S
Normal file
36
libc/arch-x86/bionic/__restore_rt.S
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
// This function must have exactly this instruction sequence for gdb and libunwind.
|
||||
// This function must have exactly this name for gdb.
|
||||
ENTRY(__restore_rt)
|
||||
movl $__NR_rt_sigreturn, %eax
|
||||
int $0x80
|
||||
END(__restore_rt)
|
@ -25,6 +25,8 @@ libc_bionic_src_files_x86 := \
|
||||
libc_bionic_src_files_x86 += \
|
||||
arch-x86/bionic/__bionic_clone.S \
|
||||
arch-x86/bionic/_exit_with_stack_teardown.S \
|
||||
arch-x86/bionic/__restore_rt.S \
|
||||
arch-x86/bionic/__restore.S \
|
||||
arch-x86/bionic/_setjmp.S \
|
||||
arch-x86/bionic/setjmp.S \
|
||||
arch-x86/bionic/__set_tls.c \
|
||||
|
@ -28,7 +28,9 @@
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY_PRIVATE(__rt_sigreturn)
|
||||
movl $__NR_rt_sigreturn, %eax
|
||||
// This function must have exactly this instruction sequence for gdb and libunwind.
|
||||
// This function must have exactly this name for gdb.
|
||||
ENTRY(__restore_rt)
|
||||
mov $__NR_rt_sigreturn, %rax
|
||||
syscall
|
||||
END(__rt_sigreturn)
|
||||
END(__restore_rt)
|
@ -30,7 +30,7 @@ libc_common_src_files_x86_64 += \
|
||||
libc_bionic_src_files_x86_64 := \
|
||||
arch-x86_64/bionic/__bionic_clone.S \
|
||||
arch-x86_64/bionic/_exit_with_stack_teardown.S \
|
||||
arch-x86_64/bionic/__rt_sigreturn.S \
|
||||
arch-x86_64/bionic/__restore_rt.S \
|
||||
arch-x86_64/bionic/_setjmp.S \
|
||||
arch-x86_64/bionic/setjmp.S \
|
||||
arch-x86_64/bionic/__set_tls.c \
|
||||
|
@ -62,6 +62,11 @@ int dl_iterate_phdr(int (*cb)(struct dl_phdr_info* info, size_t size, void* data
|
||||
|
||||
// Try the VDSO if that didn't work.
|
||||
ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(getauxval(AT_SYSINFO_EHDR));
|
||||
if (ehdr_vdso == nullptr) {
|
||||
// There is no VDSO, so there's nowhere left to look.
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct dl_phdr_info vdso_info;
|
||||
vdso_info.dlpi_addr = 0;
|
||||
vdso_info.dlpi_name = NULL;
|
||||
|
@ -28,8 +28,10 @@
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
extern "C" void __restore_rt(void);
|
||||
extern "C" void __restore(void);
|
||||
|
||||
#if __LP64__
|
||||
extern "C" void __rt_sigreturn(void);
|
||||
extern "C" int __rt_sigaction(int, const struct __kernel_sigaction*, struct __kernel_sigaction*, size_t);
|
||||
#else
|
||||
extern "C" int __sigaction(int, const struct sigaction*, struct sigaction*);
|
||||
@ -47,7 +49,7 @@ int sigaction(int signal, const struct sigaction* bionic_new_action, struct siga
|
||||
|
||||
if (!(kernel_new_action.sa_flags & SA_RESTORER)) {
|
||||
kernel_new_action.sa_flags |= SA_RESTORER;
|
||||
kernel_new_action.sa_restorer = &__rt_sigreturn;
|
||||
kernel_new_action.sa_restorer = &__restore_rt;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -71,6 +73,20 @@ int sigaction(int signal, const struct sigaction* bionic_new_action, struct siga
|
||||
#else
|
||||
// The 32-bit ABI is broken. struct sigaction includes a too-small sigset_t.
|
||||
// TODO: if we also had correct struct sigaction definitions available, we could copy in and out.
|
||||
return __sigaction(signal, bionic_new_action, bionic_old_action);
|
||||
struct sigaction kernel_new_action;
|
||||
if (bionic_new_action != NULL) {
|
||||
kernel_new_action.sa_flags = bionic_new_action->sa_flags;
|
||||
kernel_new_action.sa_handler = bionic_new_action->sa_handler;
|
||||
kernel_new_action.sa_mask = bionic_new_action->sa_mask;
|
||||
#ifdef SA_RESTORER
|
||||
kernel_new_action.sa_restorer = bionic_new_action->sa_restorer;
|
||||
|
||||
if (!(kernel_new_action.sa_flags & SA_RESTORER)) {
|
||||
kernel_new_action.sa_flags |= SA_RESTORER;
|
||||
kernel_new_action.sa_restorer = (kernel_new_action.sa_flags & SA_SIGINFO) ? &__restore_rt : &__restore;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return __sigaction(signal, (bionic_new_action != NULL) ? &kernel_new_action : NULL, bionic_old_action);
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user