From: N Jain <jain61@gmail.com>
To: musl@lists.openwall.com, Rich Felker <dalias@libc.org>
Subject: Re: dynamic linker command line invocation
Date: Thu, 7 Jan 2016 18:29:48 -0500 [thread overview]
Message-ID: <CAOkOUeczurT6FTPf5-d52LuVcu9f3ZC25+cusgoc4hAZz6aSnw@mail.gmail.com> (raw)
In-Reply-To: <20160105182326.GB238@brightrain.aerifal.cx>
[-- Attachment #1: Type: text/plain, Size: 2828 bytes --]
Hi Rich,
Thanks I am able to get my dynamic linker loaded into memory but facing
issue during application load at __dls3 function.
I am getting following print from MUSL -
"musl libc
Version 1.1.10
Dynamic Program Loader
Usage: hello.elf [options] [--] pathname--2--"
Not sure why my application is not getting loaded in below code __dls3
function ?
char *ldname = argv[0];
size_t l = strlen(ldname);
*ldname is the application elf which I want to load "hello.elf"*
if (l >= 3 && !strcmp(ldname+l-3, "ldd")) ldd_mode = 1;
*I am not sure why "ldd" string is compared here ?*
argv++;
*I don't pass any options ? Do I need to pass some option value ?*
while (argv[0] && argv[0][0]=='-' && argv[0][1]=='-') {
char *opt = argv[0]+2;
*argv++ = (void *)-1;
if (!*opt) {
break;
} else if (!memcmp(opt, "list", 5)) {
ldd_mode = 1;
} else if (!memcmp(opt, "library-path", 12)) {
if (opt[12]=='=') env_path = opt+13;
else if (opt[12]) *argv = 0;
else if (*argv) env_path = *argv++;
} else if (!memcmp(opt, "preload", 7)) {
if (opt[7]=='=') env_preload = opt+8;
else if (opt[7]) *argv = 0;
else if (*argv) env_preload = *argv++;
} else {
argv[0] = 0;
}
}
*I see the argv[0] is set to 0 so I am not able to see my application
loaded ?*
Thanks,
NJ
On Tue, Jan 5, 2016 at 1:23 PM, Rich Felker <dalias@libc.org> wrote:
> 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
>
[-- Attachment #2: Type: text/html, Size: 5700 bytes --]
next prev parent reply other threads:[~2016-01-07 23:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-04 16:59 N Jain
2016-01-04 19:22 ` Markus Wichmann
2016-01-04 20:52 ` Rich Felker
2016-01-04 20:59 ` Rich Felker
2016-01-05 16:45 ` N Jain
2016-01-05 17:32 ` Rich Felker
2016-01-05 18:00 ` N Jain
2016-01-05 18:23 ` Rich Felker
2016-01-07 23:29 ` N Jain [this message]
2016-01-08 11:09 ` Markus Wichmann
2016-01-11 17:03 ` N Jain
2016-01-12 16:24 ` Markus Wichmann
2016-01-14 22:30 ` Rich Felker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOkOUeczurT6FTPf5-d52LuVcu9f3ZC25+cusgoc4hAZz6aSnw@mail.gmail.com \
--to=jain61@gmail.com \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).