From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 794471F463 for ; Mon, 6 Jan 2020 15:45:26 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=Zii YUkiSHT8xRLrhSAr7e/yNx1/ubDUkarmIFumNxca1W9MpUWhhisU1TGrK81oP3Nj QByRaOgPPX+yQ8Uknla8e9aLLLaw+Tq9j4RqGHf6ZBOcjSmxN8hpKVMM9/IrhF5l GzET8uwpZEjCkJU3urBEICEVv3aasNGoeJfARRz0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=wCkqvVCHi dPmrd+Odx5NUr+7xdE=; b=NuypvXIXhGc6p9T5VXE/S2UM4sgKUXptjcXPLzp2y /o0li/ZEyqoEUvabPfViUA5RuXWNbwUFKMRLPa84pgSubSOVtiinV784kQnkphy0 cMivdvew8fQMk+PYTT4JvdILSg334qS23YBeRVGa5UNlCma5EA57DqkTAKCg6NDx Q8= Received: (qmail 45577 invoked by alias); 6 Jan 2020 15:45:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 45422 invoked by uid 89); 6 Jan 2020 15:45:17 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mxo2.dft.dmz.twosigma.com From: Nicolas Viennot To: "libc-alpha@sourceware.org" Subject: [PATCH 3/3] dl-load: test that loaded libraries cannot have duplicated sonames Date: Mon, 6 Jan 2020 15:45:06 +0000 Message-ID: <8fd944a7c6d74ef3868a3fec7aae625e@EXMBDFT10.ad.twosigma.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 --- elf/Makefile | 14 +++++++++++++- elf/tst-dlopen-soname-dup.c | 34 ++++++++++++++++++++++++++++++++++ elf/tst-soname-mod.c | 19 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 elf/tst-dlopen-soname-dup.c create mode 100644 elf/tst-soname-mod.c diff --git a/elf/Makefile b/elf/Makefile index f861126b2f..88a7361073 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -199,7 +199,8 @@ tests +=3D restest1 preloadtest loadfail multiload orig= test resolvfail \ tst-debug1 tst-main1 tst-absolute-sym tst-absolute-zero tst-big-note \ tst-unwind-ctor tst-unwind-main tst-audit13 \ tst-sonamemove-link tst-sonamemove-dlopen tst-dlopen-tlsmodid \ - tst-dlopen-self tst-auditmany tst-initfinilazyfail tst-dlopenfail + tst-dlopen-self tst-auditmany tst-initfinilazyfail tst-dlopenfail \ + tst-dlopen-soname-dup # reldep9 tests-internal +=3D loadtest unload unload2 circleload1 \ neededtest neededtest2 neededtest3 neededtest4 \ @@ -305,6 +306,7 @@ modules-names =3D testobj1 testobj2 testobj3 testobj4 t= estobj5 testobj6 \ tst-absolute-zero-lib tst-big-note-lib tst-unwind-ctor-lib \ tst-audit13mod1 tst-sonamemove-linkmod1 \ tst-sonamemove-runmod1 tst-sonamemove-runmod2 \ + tst-soname-mod \ tst-auditmanymod1 tst-auditmanymod2 tst-auditmanymod3 \ tst-auditmanymod4 tst-auditmanymod5 tst-auditmanymod6 \ tst-auditmanymod7 tst-auditmanymod8 tst-auditmanymod9 \ @@ -1499,6 +1501,16 @@ $(objpfx)tst-sonamemove-dlopen.out: \ $(objpfx)tst-sonamemove-runmod1.so \ $(objpfx)tst-sonamemove-runmod2.so =20 +LDFLAGS-tst-soname-mod.so =3D -Wl,-soname=3Ddummyname + +$(objpfx)tst-soname-mod-copy.so: $(objpfx)tst-soname-mod.so + cp $< $@ + +$(objpfx)tst-dlopen-soname-dup: $(libdl) +$(objpfx)tst-dlopen-soname-dup.out: \ + $(objpfx)tst-soname-mod.so \ + $(objpfx)tst-soname-mod-copy.so + # Override -z defs, so that we can reference an undefined symbol. # Force lazy binding for the same reason. LDFLAGS-tst-latepthreadmod.so =3D \ diff --git a/elf/tst-dlopen-soname-dup.c b/elf/tst-dlopen-soname-dup.c new file mode 100644 index 0000000000..804b259f3f --- /dev/null +++ b/elf/tst-dlopen-soname-dup.c @@ -0,0 +1,34 @@ +/* Check that two DSOs with the same soname can only be loaded once + Copyright (C) 2019 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 + +static int +do_test (void) +{ + void *h1 =3D xdlopen ("tst-soname-mod.so", RTLD_NOW); + void *h2 =3D xdlopen ("tst-soname-mod-copy.so", RTLD_NOW); + + TEST_VERIFY (h1 =3D=3D h2); + + return 0; +} + +#include diff --git a/elf/tst-soname-mod.c b/elf/tst-soname-mod.c new file mode 100644 index 0000000000..844438a146 --- /dev/null +++ b/elf/tst-soname-mod.c @@ -0,0 +1,19 @@ +/* Run-time module with a soname defined + Copyright (C) 2019 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 + . */ + +/* left intentionally blank */ --=20 2.19.1