From patchwork Mon Aug 1 12:20:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 14182 Received: (qmail 121700 invoked by alias); 1 Aug 2016 12:20:24 -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 121676 invoked by uid 89); 1 Aug 2016 12:20:23 -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=*data, Hx-languages-length:1730, T, D*T X-HELO: mail-wm0-f48.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=gfNxdr5O8l/yTAMLeaVLF6NQbbnNzDKWZiA/Uwl60Ew=; b=RaIQb82ZQsgTGJhDr9/9d4DfrZLJfDQ/3Q8vVYbuAZb0u01jflL3KAg4IdRPg4aN/W D4gVLTMfPodWkvdTJnarzWwMp3/J9TWYyS1TMJoG8L0/C9LTn3dtnP7dy5F7cmVV/0Ev BYt7JR0fKWtubdHZkkMtI097d6P1Q+7sjDHpx/xL2hl5eD1V0p/XHK5nc/GsronI7j9p OE0PX+FYQkOOmJMXDUDVg70er/Q0a7dwkGnwziwZzA35NRWB8+ebV/qf2+hec9wgfbuw 7QLfHlS8751g301VOMDwhzcFQ5kHqD9wEdCrHQKL/237U5p9OwEZXn+908V2AwSahno7 NTnA== X-Gm-Message-State: AEkoous+Qq4nsSP3yylMUTk14f+XkX4wBjJivhQTARdwoG85i8s9GsbHA/WHRPMhGsrxkQ== X-Received: by 10.194.77.142 with SMTP id s14mr49434529wjw.77.1470054010511; Mon, 01 Aug 2016 05:20:10 -0700 (PDT) Date: Mon, 1 Aug 2016 15:20:08 +0300 From: Gleb Natapov To: libc-alpha@sourceware.org Subject: [PATCH] add test for correct calculation of dl_phdr_info.dlpi_subs Message-ID: <20160801122008.GO2502@scylladb.com> MIME-Version: 1.0 Content-Disposition: inline -- Gleb. 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..bea0110 --- /dev/null +++ b/elf/tst-dlpi_subs.c @@ -0,0 +1,33 @@ +#include +#include + +static int fail = false; + +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 = true; + } + 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"