From patchwork Mon Nov 9 20:18:16 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: 40993 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 1E3A8397307F; Mon, 9 Nov 2020 20:18:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E3A8397307F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953138; bh=TQIOiSQ5DeVsfYviHj/TofC1BzAIfAwt4dD4VUva3c0=; 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=RYYWa5a6kC/l89VF3iis1n3XAu+5+Yp5Yz0KhPp+i8GfL73Y/chTaQwvgA3Vj0NiQ 4fJaPA2WTf8F+njd7gZ3a7DDPuS1z7KTEvTdLrntvR1QIh229uGLdW3thZkJVwlpop /eZ9CuVvCKJO8j6s8xrqeqMMOSw4VwAOkLM/+lU8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id E49753973070 for ; Mon, 9 Nov 2020 20:18:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E49753973070 Received: by mail-qk1-x72d.google.com with SMTP id u4so6502666qkk.10 for ; Mon, 09 Nov 2020 12:18:54 -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=TQIOiSQ5DeVsfYviHj/TofC1BzAIfAwt4dD4VUva3c0=; b=pQqGBh7XudhyQeOK2b4z7weU/ZvjYL6fzXQ/obu6zHJZqTCXyn+AzfJyJmr89dN/gl nLhmGAlFnXXZ6eFmzA76O7eMGugjwRi+qndph/WZmjeGzJ+QO7YhzszYb0T5zWmy6BEO QEDG6o2YxzAW9fpUSABXdZ9iOdNQKSYkxYZs0SC/QbypI2qPLtZK3cpWFQxzACv28Abp qFiZojezkoooDlCJuhGjXdiEp2xz2jJHDxo2xGsc5M6dvNaJHhcelk1O58S9zVmM31+p 9a4j8q2J8StcyKKb/KpJc9D2V9SmAHwCofx5s1Y/BFpXTCFiccIDxHDXrIf3EZbZTWrr xRrA== X-Gm-Message-State: AOAM533JGGcG77PgictDh3S24AllPfdpkwRax+mYQew36rU7C2PLXLmT vzoyZrJo7y03F/GmcChwHI6CwpyJ5cAAEA== X-Google-Smtp-Source: ABdhPJyqfJByX6AS8TbmLaUWqjhzMdtUOA7ndsgmKMtpEpCqX+ANMzwEAFHmz7cI5s450303XvEl5g== X-Received: by 2002:a37:6107:: with SMTP id v7mr15246712qkb.145.1604953134084; Mon, 09 Nov 2020 12:18:54 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:53 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 13/23] linux: Use generic __syscall_error for x86_64 Date: Mon, 9 Nov 2020 17:18:16 -0300 Message-Id: <20201109201826.120534-14-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.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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" The auto-generated syscalls issue the __syscall_error only for static objects, so a arch specific syscall_error is added. The size of using extern __syscall_error is just slight better for static case: --- size-fstatat64.o.inline +++ size-fstatat64.o.outline @@ -1,2 +1,2 @@ text data bss dec hex filename - 100 0 0 100 64 io/fstatat64.o + 94 0 0 94 5e io/fstatat64.o For shared objects the inline __syscall_error does generate more compact code: --- sizes-x86_64-linux-gnu.inline +++ sizes-x86_64-linux-gnu.outline @@ -1,5 +1,5 @@ text data bss dec hex filename -1774028 20520 15896 1810444 1ba00c libc.so - 167499 7280 392 175171 2ac43 elf/ld.so - 99261 1640 16728 117629 1cb7d nptl/libpthread.so - 24751 1188 2400 28339 6eb3 rt/librt.so +1776260 20520 15896 1812676 1ba8c4 libc.so + 167758 7280 392 175430 2ad46 elf/ld.so + 100221 1640 16728 118589 1cf3d nptl/libpthread.so + 24927 1188 2400 28515 6f63 rt/librt.so A possible option might be to use the same strategy for both static and PIC code, which allow to remove the arch-specific syscall_error.c with a slight increase of code size in static library. Checked on x86_64-linux-gnu. --- sysdeps/unix/sysv/linux/sysdep.h | 8 +++ .../unix/sysv/linux/x86_64/syscall_error.c | 5 ++ sysdeps/unix/sysv/linux/x86_64/sysdep.S | 40 --------------- sysdeps/unix/x86_64/sysdep.S | 49 ------------------- 4 files changed, 13 insertions(+), 89 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/x86_64/syscall_error.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/sysdep.S delete mode 100644 sysdeps/unix/x86_64/sysdep.S diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 6c0d1f9f6f..4f5b978838 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -24,6 +24,14 @@ #include #ifndef __ASSEMBLER__ +/* The errno setting might be set either inline or with a help function. For + some ABIs (x86_64), setting inline might generate less code; while for + others (i686) function call is preferable. + + To use the helper function an ABI might define SYSCALL_ERROR_FUNC, it will + build a hidden function on each shared object that issues direct syscall + with {INLINE,INTERNAL}_SYSCALL_CALL. */ + static inline _Bool syscall_error (unsigned long int val) { diff --git a/sysdeps/unix/sysv/linux/x86_64/syscall_error.c b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c new file mode 100644 index 0000000000..40528f8ae9 --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c @@ -0,0 +1,5 @@ +/* The auto-generated syscalls calls __syscall_error for static objects. */ +#ifndef SHARED +# define SYSCALL_ERROR_FUNC +#endif +#include diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.S b/sysdeps/unix/sysv/linux/x86_64/sysdep.S deleted file mode 100644 index 2d3592296d..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.S +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2001-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 following code is only used in the shared library when we - compile the reentrant version. Otherwise each system call defines - each own version. */ - -#ifndef PIC - -/* 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 %rax is negated. */ - -#undef CALL_MCOUNT -#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %rax. */ - - .text -ENTRY (__syscall_error) - neg %RAX_LP - -#define __syscall_error __syscall_error_1 -#include - -#endif /* !PIC */ diff --git a/sysdeps/unix/x86_64/sysdep.S b/sysdeps/unix/x86_64/sysdep.S deleted file mode 100644 index 2278fce9e4..0000000000 --- a/sysdeps/unix/x86_64/sysdep.S +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2001-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 -#include - -#if IS_IN (rtld) -# include /* Defines RTLD_PRIVATE_ERRNO. */ -#endif - -.globl C_SYMBOL_NAME(errno) -.globl syscall_error - -__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. */ - cmp $EWOULDBLOCK_sys, %RAX_LP /* Is it the old EWOULDBLOCK? */ - jne notb /* Branch if not. */ - movl $EAGAIN, %eax /* Yes; translate it to EAGAIN. */ -notb: -#endif -#ifdef PIC - movq C_SYMBOL_NAME(errno@GOTTPOFF)(%rip), %rcx - movl %eax, %fs:0(%rcx) -#else - movl %eax, %fs:C_SYMBOL_NAME(errno@TPOFF) -#endif - or $-1, %RAX_LP - ret - -#undef __syscall_error -END (__syscall_error)