From patchwork Mon Jan 6 15:45:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Viennot X-Patchwork-Id: 37215 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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 45422 invoked by uid 89); 6 Jan 2020 15:45:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=1998, libdl, 1997 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> 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 += restest1 preloadtest loadfail multiload origtest 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 += loadtest unload unload2 circleload1 \ neededtest neededtest2 neededtest3 neededtest4 \ @@ -305,6 +306,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 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 +LDFLAGS-tst-soname-mod.so = -Wl,-soname=dummyname + +$(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 = \ 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 = xdlopen ("tst-soname-mod.so", RTLD_NOW); + void *h2 = xdlopen ("tst-soname-mod-copy.so", RTLD_NOW); + + TEST_VERIFY (h1 == 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 */