From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 6 05:20:13 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F297CB32 for ; Wed, 6 Nov 2013 05:20:13 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-ie0-x231.google.com (mail-ie0-x231.google.com [IPv6:2607:f8b0:4001:c03::231]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A770D225F for ; Wed, 6 Nov 2013 05:20:13 +0000 (UTC) Received: by mail-ie0-f177.google.com with SMTP id e14so16734650iej.36 for ; Tue, 05 Nov 2013 21:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=mD8ZNPshuJnIUrxNdDl/PqZZoIRd84QXz0V/sU9IqT0=; b=n8Xbplc5QA8NPZcusxqJk4Q07e2mvcaPDWP1Czeb2wAby2gKIGmeKdOVIQjVAm8umv NwET/t01qPi5qbEr5cfR8Vc8ibtdDJ26uDV/bJOGFc6Pyb/TMc1zKUQ42pwm3ff6E9Z0 Rs86umS88ZgDYFKwu7WjTOJoV/gBlT3JhtdCoqFZ8sdPi5qS5Lp8baWl5FWauuY8V/nU +C0zBVydU/eCJvo+3g378lI6O5bCAST+J997Hz53wauOggbm2jCOqHH0TImMmENKYgCY eqvic2ugpNvL+iBEcpC8ZzKD1tF02GDeOqv+cEyku4taEpNbCNllDtgUf20l6y/igsSb kWSg== X-Received: by 10.50.40.37 with SMTP id u5mr18897650igk.29.1383715213006; Tue, 05 Nov 2013 21:20:13 -0800 (PST) Received: from raichu (24-212-218-13.cable.teksavvy.com. [24.212.218.13]) by mx.google.com with ESMTPSA id qi3sm12366645igc.8.2013.11.05.21.20.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Nov 2013 21:20:12 -0800 (PST) Sender: Mark Johnston Date: Wed, 6 Nov 2013 00:20:10 -0500 From: Mark Johnston To: freebsd-hackers@freebsd.org Subject: dl_iterate_phdr() omits ld-elf.so Message-ID: <20131106052010.GB2826@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Nov 2013 05:20:14 -0000 Hello, While experimenting with dl_iterate_phdr(3), I noticed that it doesn't include the runtime linker itself in the list of objects. This is inconsistent with related interfaces such as /map in procfs, and kinfo_getvmmap(3), so it seems incorrect to me that rtld is excluded from the list of callback arguments. Is there a reason for this behaviour? If not, does anyone have thoughts on the diff below which fixes this? Thanks, -Mark diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index fa6dc2a..b55effa 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -3269,6 +3269,11 @@ dl_iterate_phdr(__dl_iterate_hdr_callback callback, void *param) break; } + if (error == 0) { + rtld_fill_dl_phdr_info(&obj_rtld, &phdr_info); + error = callback(&phdr_info, sizeof(phdr_info), param); + } + lock_release(rtld_bind_lock, &bind_lockstate); lock_release(rtld_phdr_lock, &phdr_lockstate);