From patchwork Fri Nov 13 16:58:26 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: 41060 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 00CCD39450F9; Fri, 13 Nov 2020 16:59:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00CCD39450F9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286749; bh=u7kk517acl7gVyY3650KV/D59GWExHfMgRPQYUuoE1k=; 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=dCNffX/Wf0kczs+bIwn1NPHmRZjqNMBfgpqtRzScmiwjnC3VKvcUi5ZDHVrrc7l1T YjH2OIDjW4v3T+JNUhk3slLyQdUzs9kxY3u4bb2dgABjo6enugs3buR9Cf6TXttqe6 PcLM1KhFnEYTnCIHeELa61uI/PJiY5ZwkicqN+68= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by sourceware.org (Postfix) with ESMTPS id 00B463945C2E for ; Fri, 13 Nov 2020 16:59:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 00B463945C2E Received: by mail-qt1-x82e.google.com with SMTP id f93so7101123qtb.10 for ; Fri, 13 Nov 2020 08:59:05 -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=u7kk517acl7gVyY3650KV/D59GWExHfMgRPQYUuoE1k=; b=JsaJ0yC8s5iSqcnRePKKpZU6JkeczGaRrtnnNnBJdRqukqt5GGjJdh9GXiBfDnoZBV YQGE7QWUn0pVzyN2+TqnjjzyaxYbv2g1r6DIag8vMbdlMHwncrYhGd5SALEpzX/DYOH0 ZGX50DlbjgyG30SIffIPeBHZevawlS/XQZwqR/6MIueywInrf/icxJma5Id4sWtQDMni A1YJwPPv0oHU1DEr/z3TMyzL5YKy3Idx4eGsK37JuZGoFqTtTLUNeWw4FDgMZfy4/61R 0oW2ht8KQPYpFdyfS3H/0fY56G+JNZqETYzaEfB1gBR7xYvmmxkPcTkG/KITIMzVR0RJ nnSg== X-Gm-Message-State: AOAM533VHe0XLAz0qK2oLyvoKJ23YHMsAZjwzDOsJDgD0fp7MhyFh2pk mzzSB0nZp+II5vNTjEg/F5pa0qt43IP8Gg== X-Google-Smtp-Source: ABdhPJxLcdj50XNa9PLhhqLQvW/B6rljKwvnPzNp7pbAiw8NKqmLiL143BxrTaQpATJQjp19XPV0IQ== X-Received: by 2002:ac8:5253:: with SMTP id y19mr2755847qtn.260.1605286739771; Fri, 13 Nov 2020 08:58:59 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:59 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 12/23] linux: Use generic __syscall_error for x86_64 Date: Fri, 13 Nov 2020 13:58:26 -0300 Message-Id: <20201113165837.121629-13-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.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. --- .../unix/sysv/linux/x86_64/syscall_error.c | 7 +++ sysdeps/unix/sysv/linux/x86_64/sysdep.S | 40 --------------- sysdeps/unix/x86_64/sysdep.S | 49 ------------------- 3 files changed, 7 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/x86_64/syscall_error.c b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c new file mode 100644 index 0000000000..de5491dc50 --- /dev/null +++ b/sysdeps/unix/sysv/linux/x86_64/syscall_error.c @@ -0,0 +1,7 @@ +/* The auto-generated syscalls calls __syscall_error for static objects. */ +#include +#ifndef SHARED +# undef SYSCALL_ERROR_FUNC +# define SYSCALL_ERROR_FUNC 1 +#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)