From patchwork Wed Aug 3 13:52:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 14278 Received: (qmail 81010 invoked by alias); 3 Aug 2016 13:53:10 -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 80847 invoked by uid 89); 3 Aug 2016 13:53:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=dlvsym, T, Lesser, D*T X-HELO: mail-wm0-f45.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=r4ZXw3k8MCZvOyzdrSUIulHZ5gNzkJZjDYdYjPBfXqo=; b=XUaSJ70Lv9KlencOr5ZsioeyjsreMPqbLKZGHKFv+gB1kNX6geuQ+xUdZnDA+1k84K rf8qtDZH3nZeWlTprAZieLezwRzqn6fJM6B+ki5qozrHjMBgnjEkx4cUmOS1xzE3vR1P aW0dTq6VAj8WvLBolf5lMPQQ9l4QB5V8vgbJBEjaP/b/p57wak7/YFmkHYiyaR3uc93Y XnMyHsGrtSFZ7RYRn9Wm/7ETY8mLqNYFaGlUFWCFVje6/UQqkzEyUreHAG3dySnhBdVv 0BfTit9gJxEjWgk6saFTljS8n4Si6zlGU3x/rQ5Pp4ULnTj3as6CIn4DOIDUA9lyFuL5 E3xQ== X-Gm-Message-State: AEkooutt5vW2fKA5UuTT2mRLcOwxEKPHDBSNZLT558lwQmVlPnXa+IlPS2x+UyVAHpxF7w== X-Received: by 10.194.118.70 with SMTP id kk6mr2103223wjb.180.1470232374802; Wed, 03 Aug 2016 06:52:54 -0700 (PDT) From: Gleb Natapov To: libc-alpha@sourceware.org Subject: [PATCH v2 2/2] add test for correct calculation of dl_phdr_info.dlpi_subs Date: Wed, 3 Aug 2016 16:52:39 +0300 Message-Id: <1470232359-18696-3-git-send-email-gleb@scylladb.com> In-Reply-To: <1470232359-18696-1-git-send-email-gleb@scylladb.com> References: <1470232359-18696-1-git-send-email-gleb@scylladb.com> --- elf/Makefile | 5 ++++- elf/tst-dlpi_subs.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 elf/tst-dlpi_subs.c diff --git a/elf/Makefile b/elf/Makefile index 593403c..d64b281 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -149,7 +149,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ tst-nodelete) \ tst-initorder tst-initorder2 tst-relsort1 tst-null-argv \ tst-ptrguard1 tst-tlsalign tst-tlsalign-extern tst-nodelete-opened \ - tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error + tst-nodelete2 tst-audit11 tst-audit12 tst-dlsym-error tst-dlpi_subs # reldep9 ifeq ($(build-hardcoded-path-in-tests),yes) tests += tst-dlopen-aout @@ -1005,6 +1005,9 @@ generated += check-execstack.out $(objpfx)tst-dlmodcount: $(libdl) $(objpfx)tst-dlmodcount.out: $(test-modules) +$(objpfx)tst-dlpi_subs: $(libdl) +$(objpfx)tst-dlpi_subs.out: $(test-modules) + $(all-built-dso:=.jmprel): %.jmprel: % Makefile @rm -f $@T LC_ALL=C $(READELF) -W -S -d -r $< > $@T diff --git a/elf/tst-dlpi_subs.c b/elf/tst-dlpi_subs.c new file mode 100644 index 0000000..79ee761 --- /dev/null +++ b/elf/tst-dlpi_subs.c @@ -0,0 +1,54 @@ + +/* Test error reporting for dlsym, dlvsym failures. + Copyright (C) 2016 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 + . */ + +/* Test checks that dlpi_subs is calculated correctly when dlmopen is used */ + +#include +#include + +static int fail = 0; + +static int +callback (struct dl_phdr_info *info, size_t size, void *data) +{ + if (info->dlpi_subs != 0) { + printf ("dlpi_subs == %llu instead of 0\n", info->dlpi_subs); + fail = 1; + } + return 0; +} + + +static int +do_test (void) +{ + void *h = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-deep1mod2.so", RTLD_LAZY); + if (h == NULL) + { + printf ("cannot get handle for %s: %s\n", + "tst-deep1mod2.so", dlerror ()); + return 1; + } + dl_iterate_phdr (callback, NULL); + + return fail; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c"