110c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown/* 210c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * Copyright (C) 2008 The Android Open Source Project 310c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * All rights reserved. 410c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * 510c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * Redistribution and use in source and binary forms, with or without 610c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * modification, are permitted provided that the following conditions 710c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * are met: 810c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * * Redistributions of source code must retain the above copyright 910c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * notice, this list of conditions and the following disclaimer. 1010c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * * Redistributions in binary form must reproduce the above copyright 1110c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * notice, this list of conditions and the following disclaimer in 1210c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * the documentation and/or other materials provided with the 1310c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * distribution. 1410c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * 1510c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1610c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1710c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 1810c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 1910c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 2010c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 2110c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 2210c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 2310c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 2410c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 2510c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2610c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown * SUCH DAMAGE. 2710c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown */ 285c2772f59d3b6f564897187324d8606f54423207Elliott Hughes 295c2772f59d3b6f564897187324d8606f54423207Elliott Hughes#include <linux/err.h> 305c2772f59d3b6f564897187324d8606f54423207Elliott Hughes#include <asm/unistd.h> 315c2772f59d3b6f564897187324d8606f54423207Elliott Hughes#include <machine/asm.h> 325c2772f59d3b6f564897187324d8606f54423207Elliott Hughes 3310c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown/* unlike our auto-generated syscall stubs, this code saves lr 3410c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown on the stack, as well as a few other registers. this makes 3510c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown our stack unwinder happy, when we generate debug stack 3610c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown traces after the C library or other parts of the system 3710c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown abort due to a fatal runtime error (e.g. detection 3810c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown of a corrupted malloc heap). 3910c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown*/ 4010c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown 4110c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff BrownENTRY(tgkill) 427e6ce1a3c52d8533fed92c143419fedb0c93988aBen Cheng .save {r4-r7, ip, lr} 4310c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown stmfd sp!, {r4-r7, ip, lr} 4410c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown ldr r7, =__NR_tgkill 4510c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown swi #0 4610c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff Brown ldmfd sp!, {r4-r7, ip, lr} 479aceab50155b17741faded1fb22e2daa51a07fb1Elliott Hughes cmn r0, #(MAX_ERRNO + 1) 489aceab50155b17741faded1fb22e2daa51a07fb1Elliott Hughes bxls lr 499aceab50155b17741faded1fb22e2daa51a07fb1Elliott Hughes neg r0, r0 509aceab50155b17741faded1fb22e2daa51a07fb1Elliott Hughes b __set_errno 5110c8ce59a40a1d8ae8f49145eca365b364aabe58Jeff BrownEND(tgkill) 52