From patchwork Mon Nov 9 20:18:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 40995 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DC5339730A4; Mon, 9 Nov 2020 20:19:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DC5339730A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953141; bh=coemqb/z0cZupdX9MjHeXnTYM8yyRJM/ZScl0OPZqnU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=sJqI/iJeidwPeFV17nOBuPepg6Af0DwKwr2YgRzfGHldBZbX+hAQNgs1NhNU4LX9X 0h1HHLyVXbzhvexauv+9mu8XlysKChDFMLcfDThVKhmqZnQ5IT/+5hXHY9vRpZl5SL ssIoQoGDHTv3rAj48otVWeOFDHWenhA7nP0YVKD8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id A9B733972800 for ; Mon, 9 Nov 2020 20:18:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A9B733972800 Received: by mail-qt1-x831.google.com with SMTP id p12so6967782qtp.7 for ; Mon, 09 Nov 2020 12:18:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=coemqb/z0cZupdX9MjHeXnTYM8yyRJM/ZScl0OPZqnU=; b=BLHAcNAvPGyvsfoWNz5ct1GuBf2tcPPqA53Jul+Wd2rJlrpZebofK+UVD2TeJVaNvn LzkRdMeCOS6GXG6wFh2ps5PECh5qlHfSLjJgTs/sH3Y5Hhyyd6uzkHZkGAUTV32vj+nr dILvEiu3dWHCCp/07PMEMX+R4K+r3Tp19YY9mgGmt3DsAitQOMCCBAEn1uh7pGbyBGIC UA7WwUe4ZT6yWELxbXIHv3qz+PU02kvTFMH/hXOSoiRLkrwFlsEVLDU17wJ2Cue1Ylk6 T6jqp99loLexvVzu+dUWfKQQLvygt+eiMWhiji51sSOPeHQW4OgsoXWr1HWplp8B6L0y 9ACQ== X-Gm-Message-State: AOAM531v4Y9m/XVpz4as7GtW7irAOD+eim3NhAH34I0jEAdPrBWUVGWO YF0Vh0mm/Y71/JGOTC1x4Aeiut8QrX30aw== X-Google-Smtp-Source: ABdhPJzNKM2ZAOAzW5Kgm37vGybjzmVVkNE2cNDx3RAHQal0rV1Suh1oXO8rUoXJPRSAWv7UfzRJbA== X-Received: by 2002:ac8:b87:: with SMTP id h7mr14767427qti.87.1604953136862; Mon, 09 Nov 2020 12:18:56 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:56 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 15/23] linux: Use generic __syscall_error for sh Date: Mon, 9 Nov 2020 17:18:18 -0300 Message-Id: <20201109201826.120534-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Although the auto-generated syscall sets errno directly for dynamic case, using a function call generates more compact code: --- sizes-sh4-linux-gnu.outline +++ sizes-sh4-linux-gnu.inline text data bss dec hex filename -1242446 9948 9240 1261634 134042 libc.so - 122480 3764 176 126420 1edd4 elf/ld.so - 91548 804 8348 100700 1895c nptl/libpthread.so - 23613 608 160 24381 5f3d rt/librt.so +1244638 9948 9240 1263826 1348d2 libc.so + 122416 3764 176 126356 1ed94 elf/ld.so + 91460 804 8348 100612 18904 nptl/libpthread.so + 23805 608 160 24573 5ffd rt/librt.so It also removes the PLT call done by the generic unix syscall.S which calls __errno_location instead of the accessing it directly (as done by C implementation through syscall_error.c). Checked with some basic tests to see if errno is set correctly on both static and dynamic binaries with auto-generated syscals and C implementation (which uses INTERNAL_SYSCALL_CALL). --- sysdeps/unix/sh/sysdep.S | 115 ----------------------- sysdeps/unix/sysv/linux/sh/localplt.data | 1 - sysdeps/unix/sysv/linux/sh/sysdep.S | 32 ------- sysdeps/unix/sysv/linux/sh/sysdep.h | 2 + 4 files changed, 2 insertions(+), 148 deletions(-) delete mode 100644 sysdeps/unix/sh/sysdep.S delete mode 100644 sysdeps/unix/sysv/linux/sh/sysdep.S diff --git a/sysdeps/unix/sh/sysdep.S b/sysdeps/unix/sh/sysdep.S deleted file mode 100644 index dc9a230ee0..0000000000 --- a/sysdeps/unix/sh/sysdep.S +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 1999-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include -#include - -ENTRY(__syscall_error) -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN - /* We translate the system's EWOULDBLOCK error into EAGAIN. - The GNU C library always defines EWOULDBLOCK==EAGAIN. - EWOULDBLOCK_sys is the original number. */ - mov.l .L1, r1 - cmp/eq r1, r0 - bf skip - nop - mov.l .L2, r0 -skip: -#endif - /* Store it in errno... */ -#ifndef SHARED -#ifndef _LIBC_REENTRANT - mov.l .L3, r1 - mov.l r0, @r1 -#else - mov.l .L3, r1 - sts.l pr, @-r15 - cfi_adjust_cfa_offset (4) - cfi_rel_offset (pr, 0) - mov.l r0, @-r15 - cfi_adjust_cfa_offset (4) - jsr @r1 - nop - mov.l @r15+, r1 - cfi_adjust_cfa_offset (-4) - lds.l @r15+, pr - cfi_adjust_cfa_offset (-4) - cfi_restore (pr) - mov.l r1, @r0 -#endif -#else - mov.l r12, @-r15 - cfi_adjust_cfa_offset (4) - cfi_rel_offset (r12, 0) -#ifndef _LIBC_REENTRANT - mov r0, r2 - mov.l 0f, r12 - mova 0f, r0 - add r0, r12 - mov.l .L3, r0 - mov.l @(r0,r12), r1 - mov.l r2, @r1 -#else - mov.l r0, @-r15 - cfi_adjust_cfa_offset (4) - sts.l pr, @-r15 - cfi_adjust_cfa_offset (4) - cfi_rel_offset (pr, 0) - mov.l 0f, r12 - mova 0f, r0 - add r0, r12 - mov.l .L3, r1 - mova .L3, r0 - add r0, r1 - jsr @r1 - nop - lds.l @r15+, pr - cfi_adjust_cfa_offset (-4) - cfi_restore (pr) - mov.l @r15+, r1 - cfi_adjust_cfa_offset (-4) - mov.l r1, @r0 -#endif - mov.l @r15+, r12 - cfi_adjust_cfa_offset (-4) - cfi_restore (r12) -#endif - /* And just kick back a -1. */ - rts - mov #-1, r0 - - .align 2 -#if defined (EWOULDBLOCK_sys) && EWOULDBLOCK_sys != EAGAIN -.L1: .long EWOULDBLOCK_sys -.L2: .long EAGAIN -#endif -#ifndef SHARED -#ifndef _LIBC_REENTRANT -.L3: .long C_SYMBOL_NAME(errno) -#else -.L3: .long C_SYMBOL_NAME(__errno_location) -#endif -#else -0: - .long _GLOBAL_OFFSET_TABLE_ -#ifndef _LIBC_REENTRANT -.L3: .long C_SYMBOL_NAME(errno@GOT) -#else -.L3: .long C_SYMBOL_NAME(__errno_location@PLT) -#endif -#endif -END(__syscall_error) diff --git a/sysdeps/unix/sysv/linux/sh/localplt.data b/sysdeps/unix/sysv/linux/sh/localplt.data index 3225177c50..9d8154648b 100644 --- a/sysdeps/unix/sysv/linux/sh/localplt.data +++ b/sysdeps/unix/sysv/linux/sh/localplt.data @@ -8,7 +8,6 @@ libc.so: memalign libc.so: realloc libc.so: _Unwind_Find_FDE libc.so: _exit -libc.so: __errno_location libm.so: matherr # Generated by the compiler because there is no trap insn pattern. libc.so: abort ? diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.S b/sysdeps/unix/sysv/linux/sh/sysdep.S deleted file mode 100644 index 85ff3f900e..0000000000 --- a/sysdeps/unix/sysv/linux/sh/sysdep.S +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 1995-2020 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - . */ - -#include - -/* The syscall stubs jump here when they detect an error. - The code for Linux is almost identical to the canonical Unix - code, except that the error number in R0 is negated. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers R0. */ - -ENTRY (__syscall_error) - neg r4, r0 - cfi_endproc - -#define __syscall_error __syscall_error_1 -#include diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h index 60a5032ce4..511406b5dc 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.h +++ b/sysdeps/unix/sysv/linux/sh/sysdep.h @@ -20,6 +20,8 @@ #ifndef _LINUX_SH_SYSDEP_H #define _LINUX_SH_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + /* There is some commonality. */ #include #include