From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10239 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: request for help with aux Date: Mon, 27 Jun 2016 17:58:12 -0400 Message-ID: <20160627215812.GJ10893@brightrain.aerifal.cx> References: 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 1467064714 21638 80.91.229.3 (27 Jun 2016 21:58:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 27 Jun 2016 21:58:34 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10252-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jun 27 23:58:31 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 1bHeY1-0001NN-H3 for gllmg-musl@m.gmane.org; Mon, 27 Jun 2016 23:58:29 +0200 Original-Received: (qmail 32643 invoked by uid 550); 27 Jun 2016 21:58:26 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 32616 invoked from network); 27 Jun 2016 21:58:25 -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:10239 Archived-At: On Mon, Jun 27, 2016 at 01:07:59PM -0700, Daniel Wilkerson wrote: > The musl crt0 code seems to expect that when the process starts that > the stack pointer points to a data page having the following four data > structures immediately contiguous: argc, argv, env, aux. It's not necessarily a page. It's just an array of sorts that's aligned to the (pointer) wordsize. > I'm writing a loader for musl-riscv and I need to know how to > initialize this data. The only one I wonder about is the aux array. > It seems that aux is a collection of name/value pairs which are used > as follows in musl-riscv/src/env/__libc_start_main.c: There are various places it's used; try something like: grep -r aux.*AT_ src ldso For static linking only, at least AT_PHDR/AT_PHENT/AT_PHNUM need to be correct in order for the executable's TLS image to be located at runtime. AT_RANDOM should be valid (and point to a buffer of at least 16 random bytes IIRC) in order for stack protector to work correctly. Other fields that are used if present but probably don't matter for bare-metal setups you're looking at are AT_HWCAP, AT_SYSINFO_EHDR, and AT_SECURE and the related uid/gid fields. Rich