From patchwork Fri Nov 13 16:58:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41062 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 7F48839450FF; Fri, 13 Nov 2020 16:59:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F48839450FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286751; bh=B19qjK+PiZv3eDAw3pLAMkr/P4gKfIIvG3KtkqAYF8Y=; 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=aFFiHUppbN6GN6WTvwnQKDQyrJV8yynhYOTYylmM+e40ey4tduG5vMxZIzfwKbZmE rUlHo85AWoiIpKvR//c6uXE7AzkNfJOaA9yh6dDdqhoOWb8WBnxYcler0LHnCJhUF9 NemXf2dk0vS36bIJEhIBo8n9QMTTQRekqAoqRiMo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by sourceware.org (Postfix) with ESMTPS id 5147439450F3 for ; Fri, 13 Nov 2020 16:59:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5147439450F3 Received: by mail-qv1-xf2b.google.com with SMTP id v20so1624175qvx.4 for ; Fri, 13 Nov 2020 08:59:08 -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=B19qjK+PiZv3eDAw3pLAMkr/P4gKfIIvG3KtkqAYF8Y=; b=iejxAQ7xBibzyom4SgZBkFrKcuS6jQqYsJm9/fNc2Pik8sBphITaDfTy6nnei6zHMN fziPEppylvD4BROHXh0BpuuQJg5s51ClffChqI9Fo0cGZuX3f2G2BuTfVAf6QaWm23Nt pz1L2qqUJ+S0YKGZVvLdTg4KubVPI+Ui/ZuaLL49Cnp0qJm+l8CqPJspERmptZ12r+Gu i+cULMzzVdeoKM5ibYWCb8kvX6oKddHDrDzt+in1ZgP1PDSl2RedXBSFtgNevok3JcV9 /W6jF4p8dNkSTcS7mA64wwtSfnNJW4dStq4vHeVz4a8I34dy+kR+k9yOWHie+gWenxrC RtUg== X-Gm-Message-State: AOAM5321bbJ9OgOIr2ircnMLszds6GI73vllXxRt+N8RBDzrF/VJdt4A 8UR988U0h88hnCTD4JswyoF4JkK6bQDMDg== X-Google-Smtp-Source: ABdhPJxhkzizchKBiG3Yk2liXElZg5ZH0Xwvy4fO6jYQtpB3s+cBPczkVdn5EDRwnB34N0i9N3i7Bw== X-Received: by 2002:a0c:8c8a:: with SMTP id p10mr3456314qvb.54.1605286742656; Fri, 13 Nov 2020 08:59:02 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:02 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 14/23] linux: Use generic __syscall_error for sh Date: Fri, 13 Nov 2020 13:58:28 -0300 Message-Id: <20201113165837.121629-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 Netto 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 - .../linux/sh/{sysdep.S => syscall_error.h} | 21 ++-- 3 files changed, 7 insertions(+), 130 deletions(-) delete mode 100644 sysdeps/unix/sh/sysdep.S rename sysdeps/unix/sysv/linux/sh/{sysdep.S => syscall_error.h} (60%) 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/syscall_error.h similarity index 60% rename from sysdeps/unix/sysv/linux/sh/sysdep.S rename to sysdeps/unix/sysv/linux/sh/syscall_error.h index 85ff3f900e..5b75619168 100644 --- a/sysdeps/unix/sysv/linux/sh/sysdep.S +++ b/sysdeps/unix/sysv/linux/sh/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1995-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. SH version. + Copyright (C) 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 @@ -15,18 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -/* 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. */ +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR -#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 +#endif