Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* argv[] to /sbin/loader
@ 1997-10-03  3:14 Robert L. Millner
  0 siblings, 0 replies; 2+ messages in thread
From: Robert L. Millner @ 1997-10-03  3:14 UTC (permalink / raw)


This may be better suited to the kernel list but I thought to ask it
here.  I have a system running:

Kern 2.1.57, libc 2.0.5 and the /sbin/loader from 4.0B (system patch 3,
about to patch up to 4).  When the kernel launches loader, it does so by
(I think) shifting off argv[0], and then unshifting the name of the
loader on to it (see fs/exec.c:search_binary_handler).  When loader gets
its argv, it probably looks something like:

(loader, -n, 1000)

and the exec call is something like (I haven't gone digging enough to
get it directly yet so this is speculation)

loader, a.out, (loader, -n, 1000), (ENV1, ENV2, ...)

loader never bothers to replace argv[0] when it runs the program.  This
is a problem for some code that checks argv[0].  Under D.U., it looks
like exec_with_loader gets called without modifications to argv so that
the call is something like:

loader, a.out, (a.out, -n, 1000), (ENV1, ENV2, ...)

and a.out never knows the difference.  Why do we do it the former and
not the latter way?  I can figure how to change the code myself given
enough time but someone out there who already knows it well can send a
quick change faster.  Thanks.

	Rob

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: argv[] to /sbin/loader
@ 1997-10-03 16:10 Robert L. Millner
  0 siblings, 0 replies; 2+ messages in thread
From: Robert L. Millner @ 1997-10-03 16:10 UTC (permalink / raw)


This time, with a clue (what I get for not exercising the C wheels in
my head for a year).

In case none of what I am saying makes sense:

$ ./a.out -n 1000 &
$ sleep(10)
$ ps
PID TTY STAT TIME COMMAND
666   1 R    0:10 loader -n 1000

"RLM" == Robert L Millner <rmillner@NRAO.EDU> writes:
RLM> loader, a.out, (loader, -n, 1000), (ENV1, ENV2, ...)

I was trying to abstract the guts of the code in exec.c into a pseudo
call which doesn't really make sense with how exec.c works.  Either way,
the original argv[0] is getting zorched and loader is treating it like
it is still there.

RLM> loader, a.out, (a.out, -n, 1000), (ENV1, ENV2, ...)

More correctly, under DU, the call to exec_with_loader looks like (once
again using abstractions):

(/sbin/loader, ./a.out, [a.out, -n, 1000], [ENV1, ENV2])

which probably exec's loader with:

(/sbin/loader, [a.out, ./a.out , -n, 1000], [ENV1, ENV2])

loader then moves the program's name off argv and exec's a.out with:

(./a.out, [a.out, -n, 1000], [ENV1, ENV2]).

	-Rob

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-10-03 16:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-10-03  3:14 argv[] to /sbin/loader Robert L. Millner
  -- strict thread matches above, loose matches on Subject: below --
1997-10-03 16:10 Robert L. Millner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox