From patchwork Mon Apr 7 08:04:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: vincent X-Patchwork-Id: 337414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 87C211400C6 for ; Mon, 7 Apr 2014 18:07:54 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id F0E7D8B0D4; Mon, 7 Apr 2014 08:07:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XUtFH1NCnB3r; Mon, 7 Apr 2014 08:07:51 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id C9A7C8B00A; Mon, 7 Apr 2014 08:07:51 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 1CD941BF98D for ; Mon, 7 Apr 2014 08:07:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1959887C4A for ; Mon, 7 Apr 2014 08:07:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cwj1otHtXCgm for ; Mon, 7 Apr 2014 08:07:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx08-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by hemlock.osuosl.org (Postfix) with ESMTPS id 0BD5C87C73 for ; Mon, 7 Apr 2014 08:07:49 +0000 (UTC) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id s3784B3C010240; Mon, 7 Apr 2014 10:07:47 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 1k2ek3ke4h-1 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Mon, 07 Apr 2014 10:07:47 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 39D694E; Mon, 7 Apr 2014 08:07:32 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 56C8F4B52; Mon, 7 Apr 2014 08:07:27 +0000 (GMT) Received: from reddwarf.lablan (164.129.122.152) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.298.1; Mon, 7 Apr 2014 10:07:26 +0200 Date: Mon, 7 Apr 2014 10:04:40 +0200 From: =?us-ascii?B?PT9VVEYtOD9xP0M9QzM9QTlkcmljPTIwVklOQ0VOVD89?= To: "uclibc@uclibc.org" , Bernhard Reutner-Fischer Subject: Re: [PATCH] ldso: fix standalone execution on x86_64 architecture Message-ID: <20140407080440.GB16008@reddwarf.lablan> References: <20140326133056.GA32517@reddwarf.lablan> <20140401095055.GB630@nbbrfq.cc.univie.ac.at> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140401095055.GB630@nbbrfq.cc.univie.ac.at> User-Agent: Mutt/1.5.23 (2014-03-12) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.87, 1.0.14, 0.0.0000 definitions=2014-04-06_03:2014-04-04, 2014-04-06, 1970-01-01 signatures=0 X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: uclibc-bounces@uclibc.org Sender: uclibc-bounces@uclibc.org If the dynamic linker is built with LDSO_STANDALONE_SUPPORT=y, it can load then run a dynamically linked program when explicitly invoked from the command line. This is used for test and prelink purposes, and also by other tools like PRoot to force the kernel to load the right ELF interpreter. This feature is currently broken on x86_64 since the number of command line arguments (ie. argc) passed from the kernel is an "elf_addr_t" (64 bit on x86_64), whereas it is read as an "unsigned int" (32 bit on x86_64). Ref: https://github.com/cedric-vincent/PRoot/issues/45 Signed-off-by: Cédric VINCENT v2: use "ElfW(Addr)", as suggested by Bernhard Reutner-Fischer --- ldso/ldso/ldso.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c index becabd3..a3745c3 100644 --- a/ldso/ldso/ldso.c +++ b/ldso/ldso/ldso.c @@ -526,8 +526,8 @@ void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr, #ifdef __LDSO_STANDALONE_SUPPORT__ if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) { - unsigned int *aux_dat = (unsigned int *) argv; - int argc = aux_dat[-1]; + ElfW(Addr) *aux_dat = (ElfW(Addr) *) argv; + int argc = (int) aux_dat[-1]; tpnt->libname = argv[0]; while (argc > 1)