From patchwork Mon Feb 4 10:04:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1035781 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99730-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="CPxE1ylz"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 43tNbY6ybBz9s3x for ; Mon, 4 Feb 2019 21:04:25 +1100 (AEDT) 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:mime-version :content-type; q=dns; s=default; b=rigOrOqq0sbzoeTVFOv1RPv270Dg9 nVXqQJlF/MXOGaSpKWB9r8+wixUP92wlSFCXif2L8GMiUviPG8eaATiQhgdXObZ5 REe/D+EbJJYP6KS2VfjRrWaagFkrRGUZ3M+JsEJyMsORyZoSkPmyzcS8Fh1MiEON /DRla4YRiQjOQk= 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:mime-version :content-type; s=default; bh=6Xut70oMSK8rSfbpSqBYkQALacI=; b=CPx E1ylzotdCfraO0EvsSvgVRjeGMkNZkBEt/cmDd9f9LcbrVzmQi0oDsTLR0OEttyP jbXw8ydIAzAjj3/QIYaTA7lAUxa+5Su8NUV7/2wQIYAKm7LL4/yZY7Zbe1dna8CR BWbWdd2bjMf3X3crFOOm2LGaBCa1dEpEBAI6awf4= Received: (qmail 41091 invoked by alias); 4 Feb 2019 10:04:20 -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 41081 invoked by uid 89); 4 Feb 2019 10:04:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] support: Implement xdlmopen Date: Mon, 04 Feb 2019 11:04:15 +0100 Message-ID: <87y36vx42o.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Put xdlmopen into its own file, to avoid disturbing static linking tests (where dlmopen pulls in additional code). 2019-02-03 Florian Weimer * support/xdlfcn.h (xdlmopen): Declare. * support/xdlmopen.c: New file. diff --git a/support/Makefile b/support/Makefile index c15b93647c..180366e5a2 100644 --- a/support/Makefile +++ b/support/Makefile @@ -81,6 +81,7 @@ libsupport-routines = \ xconnect \ xcopy_file_range \ xdlfcn \ + xdlmopen \ xdup2 \ xfclose \ xfopen \ diff --git a/support/xdlfcn.h b/support/xdlfcn.h index 559281fc74..c9cd810a8a 100644 --- a/support/xdlfcn.h +++ b/support/xdlfcn.h @@ -25,10 +25,10 @@ __BEGIN_DECLS /* Each of these terminates process on failure with relevant error message. */ void *xdlopen (const char *filename, int flags); +void *xdlmopen (Lmid_t lmid, const char *filename, int flags); void *xdlsym (void *handle, const char *symbol); void xdlclose (void *handle); - __END_DECLS #endif /* SUPPORT_DLOPEN_H */ diff --git a/support/xdlmopen.c b/support/xdlmopen.c new file mode 100644 index 0000000000..d4efe110f6 --- /dev/null +++ b/support/xdlmopen.c @@ -0,0 +1,35 @@ +/* dlmopen with error checking. + Copyright (C) 2017-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 + +void * +xdlmopen (Lmid_t lmid, const char *filename, int flags) +{ + void *dso = dlmopen (lmid, filename, flags); + + if (dso == NULL) + FAIL_EXIT1 ("error: dlmopen: %s\n", dlerror ()); + + /* Clear any errors. */ + dlerror (); + + return dso; +} +