From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by sourceware.org (Postfix) with ESMTPS id 10D233858D1E for ; Tue, 30 Apr 2024 16:57:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10D233858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 10D233858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714496237; cv=none; b=tnEBJaZGBWK7CW0BQ9nGaTqtSACD8ixTesPheauiOJHtmpfhZFMI2ISMnTx06cVEw1TzwWc2k3MAzS+fg2LtvG5oigVESI/uqa0Knvg6M7jDvNzhQUJnmi2MrRKDYhBKBpA6Uxsh/BbeGuMMdpzpYZA2jhlGjIMtcUIi0Y/5R4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714496237; c=relaxed/simple; bh=MrPf8UTJVc/MZL6GasoFqJFTjOO+CNJWmrEI0UPn0Tw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t81vWZjXXxYkjy+lz4OrdZalMIwArIX+GOr+ia2W64bi+xos9o3J61epgD/U5nYwHT72rhcyy7fmvimks3jG6vxr2N3+Zecy8Z/aC7cKvRVOVuFM+baPTNDhuHZXuugRFYdqDbwpvAv+z2757G8YFi7rqgf9g5dw4yZaCHQHjlg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-5ad2da2196aso3858545eaf.2 for ; Tue, 30 Apr 2024 09:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714496234; x=1715101034; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=g/XDoBsuoUP5ZM6dQTpyZk/Td/lOXwbg7BWLf84RNOQ=; b=m6TikxiNVR/121WdL5WDk1vKfsvHbyoOcTxyylNKhiHOU/Gp75M2lVCvMNc10aoydz LmKqoWDSAZh6PhkAYKe719TtzyCMNPYuzADbvF4MiphgjRjqzK47kJsKben27ebQg+lH B543Dk5DtUYt7f1XfEP29B9ZQPuA49OLAnFJzg313OJ0Ymbn9q2gFWGpgC+Zia1l2Ttu zw6IvesatxjX7BbR44uuy/M2b+AcsXVmy0/ZdLy5PskqZnKmmeXxtg9wbssxPrSbmvk7 wuH/PdD7NGmC2PwoseoamYxj1b3E656QGXqNvKj5sM5Ar+Gu7kmaiulzBgPUumtxzSFI S2OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714496234; x=1715101034; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g/XDoBsuoUP5ZM6dQTpyZk/Td/lOXwbg7BWLf84RNOQ=; b=Eq73e/t7zXQKIsoxYzf3qtO/nnHcbTq64g5C9A8G+D2hIGo9JbLoumNv67agoKCUw2 lYuhRJp+5SvIGHEs5DjW+lUhgq7QfByEaBy+HGeZ1jlNy3VyY/e8DeklCHZGKhNTH9b1 X8mkOGcOdiDxFt44cz6XTQv/PSqabV+3fQIvJPifsnU42DzPDAVQVY77xayp8882yVlk C7VZmcWZ5Lhl0WgqnBCeyjZcG8aj9JSpOKqAXgmjF8O46EPPyCFdeXPD3OFuUUpb5mPz Xy4v7UOZJ/pCw/OP8v+WXUGn8tm1z0lLmyfCmXAocifItu7uQiy+c8RH9u8D9EMmwPtU ED1w== X-Gm-Message-State: AOJu0YzHcv0Wc0JYE2zwxqGH3MJ+4XGzXL7nvTY+QUyDMuFTtzs4LYH1 nLkCc50O8NHFN1HFBBrtWLWS6bRJSYYXR5OJzCZKsbjNRrCgg8HDNBuMoQ== X-Google-Smtp-Source: AGHT+IF3rSn/V5GErrVSt5euYjBMqYoh0OJ1nGzoIR9TZgRoPJ2HfvhrhC3VV2+ORqPvikVPkWbPvQ== X-Received: by 2002:a05:6358:7e0d:b0:186:3c3:b40f with SMTP id o13-20020a0563587e0d00b0018603c3b40fmr523774rwm.20.1714496233974; Tue, 30 Apr 2024 09:57:13 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.56.168.158]) by smtp.gmail.com with ESMTPSA id y5-20020a63fa05000000b005cf450e91d2sm21143776pgh.52.2024.04.30.09.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 09:57:13 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id 8A7E4C00DC for ; Tue, 30 Apr 2024 09:57:12 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH] Add crt1-2.0.o for glibc 2.0 compatibility tests Date: Tue, 30 Apr 2024 09:57:12 -0700 Message-ID: <20240430165712.295758-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3022.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Starting from glibc 2.1, crt1.o contains _IO_stdin_used which is checked by _IO_check_libio to provide binary compatibility for glibc 2.0. Add crt1-2.0.o for tests against glibc 2.0. Define tests-2.0 for glibc 2.0 compatibility tests. Add and update glibc 2.0 compatibility tests for stderr, matherr and pthread_kill. --- Makeconfig | 21 ++++++++++++++++ Rules | 13 +++++++++- csu/Makefile | 4 +++ libio/Makefile | 6 +++++ libio/tst-stderr-compat.c | 52 +++++++++++++++++++++++++++++++++++++++ math/Makefile | 3 +++ sysdeps/pthread/Makefile | 4 +++ 7 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 libio/tst-stderr-compat.c diff --git a/Makeconfig b/Makeconfig index e583765712..61ff1d0d9b 100644 --- a/Makeconfig +++ b/Makeconfig @@ -360,6 +360,8 @@ whole-archive = -Wl,--whole-archive # Installed name of the startup code. # The ELF convention is that the startfile is called crt1.o start-installed-name = crt1.o +# Similar to crt1.o, but without _IO_stdin_used. +start-name-2.0 = crt1-2.0.o # On systems that do not need a special startfile for statically linked # binaries, simply set it to the normal name. ifndef static-start-installed-name @@ -537,6 +539,25 @@ else # build-static endif # build-shared endif # +link +# Command for linking test programs with crt1.o from glibc 2.0. ++link-2.0-before-inputs = -nostdlib -nostartfiles $(no-pie-ldflag) \ + $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ + $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ + $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-name-2.0)) \ + $(+preinit) $(+prector) ++link-2.0-before-libc = -o $@ $(+link-2.0-before-inputs) \ + $(filter-out $(addprefix $(csu-objpfx),start.o \ + $(start-name-2.0))\ + $(+preinit) $(link-extra-libs) \ + $(common-objpfx)libc% $(+postinit),$^) \ + $(link-extra-libs) ++link-after-libc = $(+postctor) $(+postinit) +define +link-2.0-tests +$(CC) $(+link-2.0-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \ + $(+link-after-libc) +$(call after-link,$@) +endef + # The pretty printer test programs need to be compiled without optimizations # so they won't confuse gdb. We could use either the 'GCC optimize' pragma # or the 'optimize' function attribute to achieve this; however, at least on diff --git a/Rules b/Rules index c7db0a4869..9010c5d5b2 100644 --- a/Rules +++ b/Rules @@ -188,6 +188,7 @@ binaries-all = $(binaries-all-notests) $(binaries-all-tests) binaries-static-notests = $(others-static) binaries-static-tests = $(tests-static) $(xtests-static) binaries-static = $(binaries-static-notests) $(binaries-static-tests) +binaries-shared-2.0-tests = $(tests-2.0) ifeq (yesyes,$(have-fpie)$(build-shared)) binaries-pie-tests = $(tests-pie) $(xtests-pie) binaries-pie-notests = $(others-pie) @@ -215,7 +216,8 @@ binaries-malloc-hugetlb2-tests = endif binaries-pie = $(binaries-pie-tests) $(binaries-pie-notests) -binaries-shared-tests = $(filter-out $(binaries-pie) $(binaries-static), \ +binaries-shared-tests = $(filter-out $(binaries-pie) $(binaries-static) \ + $(binaries-shared-2.0-tests), \ $(binaries-all-tests)) binaries-shared-notests = $(filter-out $(binaries-pie) $(binaries-static), \ $(binaries-all-notests)) @@ -235,6 +237,15 @@ $(addprefix $(objpfx),$(binaries-shared-tests)): %: %.o \ $(+link-tests) endif +# Linking test programs with crt1.o from glibc 2.0. +ifneq "$(strip $(binaries-shared-2.0-tests))" "" +$(addprefix $(objpfx),$(binaries-shared-2.0-tests)): %: %.o \ + $(link-extra-libs-tests) \ + $(sort $(filter $(common-objpfx)lib%,$(link-libc))) \ + $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) + $(+link-2.0-tests) +endif + ifneq "$(strip $(binaries-mcheck-tests))" "" $(addprefix $(objpfx),$(binaries-mcheck-tests)): %-mcheck: %.o \ $(link-extra-libs-tests) \ diff --git a/csu/Makefile b/csu/Makefile index 946fd91031..777d6720a7 100644 --- a/csu/Makefile +++ b/csu/Makefile @@ -42,6 +42,7 @@ csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o) extra-objs = \ $(csu-dummies) \ $(start-installed-name) \ + $(start-name-2.0) \ S$(start-installed-name) \ g$(start-installed-name) \ start.o \ @@ -182,6 +183,9 @@ ifndef start-installed-name-rule $(objpfx)$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \ $(objpfx)init.o $(objpfx)static-reloc.o $(link-relocatable) +$(objpfx)$(start-name-2.0): $(objpfx)start.o $(objpfx)abi-note.o \ + $(objpfx)static-reloc.o + $(link-relocatable) $(objpfx)r$(start-installed-name): $(objpfx)start.o $(objpfx)abi-note.o \ $(objpfx)init.o $(link-relocatable) diff --git a/libio/Makefile b/libio/Makefile index a4f4409b56..0c1f16ee3b 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -266,6 +266,12 @@ aux := fileops genops stdfiles stdio strops ifeq ($(build-shared),yes) generated += tst-bz24228.mtrace tst-bz24228.check aux += oldfileops oldstdfiles +tests += \ + tst-stderr-compat \ +# tests +tests-2.0 += \ + tst-stderr-compat \ +# tests-2.0 endif shared-only-routines = oldiofopen oldiofdopen oldiofclose oldfileops \ diff --git a/libio/tst-stderr-compat.c b/libio/tst-stderr-compat.c new file mode 100644 index 0000000000..8221415cd4 --- /dev/null +++ b/libio/tst-stderr-compat.c @@ -0,0 +1,52 @@ +/* Test that fclose works on stderr from glibc 2.0. + Copyright (C) 2024 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 + +#if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +# define _LIBC +# define _IO_USE_OLD_IO_FILE +# include +# include + +extern FILE _IO_stderr_; +compat_symbol_reference (libc, _IO_stderr_, _IO_stderr_, GLIBC_2_0); +compat_symbol_reference (libc, fclose, fclose, GLIBC_2_0); + +__attribute__ ((weak, noclone, noinline)) +void +do_fclose (FILE *fp) +{ + TEST_VERIFY_EXIT (fclose (fp) == 0); +} + +static int +do_test (void) +{ + do_fclose (&_IO_stderr_); + return 0; +} +#else +static int +do_test (void) +{ + return 0; +} +#endif + +#include diff --git a/math/Makefile b/math/Makefile index a9fef9e2db..435939aedb 100644 --- a/math/Makefile +++ b/math/Makefile @@ -566,6 +566,9 @@ tests += \ test-matherr \ test-matherr-2 \ # tests +tests-2.0 += \ + test-matherr-2 \ + # tests-2.0 endif # These tests use internal (unexported) GMP functions and are linked diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile index f9efb50764..04ea56559e 100644 --- a/sysdeps/pthread/Makefile +++ b/sysdeps/pthread/Makefile @@ -282,6 +282,10 @@ tests += \ tst-vfork2x \ # tests +tests-2.0 += \ + tst-pthread_kill-exited + # tests-2.0 + tests-time64 += \ tst-abstime-time64 \ tst-cnd-timedwait-time64 \ -- 2.44.0