From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9063 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: dynamic linker command line invocation Date: Tue, 5 Jan 2016 13:23:26 -0500 Message-ID: <20160105182326.GB238@brightrain.aerifal.cx> References: <20160104205920.GW238@brightrain.aerifal.cx> <20160105173200.GZ238@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1452018232 27674 80.91.229.3 (5 Jan 2016 18:23:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 5 Jan 2016 18:23:52 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-9076-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jan 05 19:23:45 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aGWGm-0003QD-Nk for gllmg-musl@m.gmane.org; Tue, 05 Jan 2016 19:23:45 +0100 Original-Received: (qmail 23608 invoked by uid 550); 5 Jan 2016 18:23:41 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 23590 invoked from network); 5 Jan 2016 18:23:40 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:9063 Archived-At: On Tue, Jan 05, 2016 at 01:00:37PM -0500, N Jain wrote: > > You never answered whether > > you were setting up the aux vector right, but if not, that's > > definitely going to cause problems. > > I am not setting any aux vectors. I only pass argv = "app.elf" and argc = 1 > to dynamic linker. > What and where I need to set "aux" vectors ? Any pointers will help.. The ELF entry point ABI is that the initial stack pointer points to an array of word-sized cells containing: argc argv[0] argv[1] ... argv[argc-1] argv[argc](=0) anviron[0] environ[1] ... 0 auxv[0].key auxv[0].val auxv[1].key auxv[1].val ... 0 The auxv items are key,val pairs where the key is one of the AT_* constants from elf.h and the value is either an integer or pointer (depending on which key it's for). At the very least you should be passing: AT_PHDR - points to the start of elf program headers AT_PHENT - size of each program header AT_PHNUM - number of program headers If you load both the main program and "interpreter" (dynamic linker) from the kernel, then these values should be for the main program's headers, and in addition you need to pass: AT_BASE - load address of the "interpreter" (dynamic linker) AT_ENTRY - entry point address of the main program, from its header On the other hand, if you only load the dynamic linker (treating it as the main program), then the program header auxv entries should hold the right values for the dynamic linker. Rich