2000-11-15  Jakub Jelinek  <jakub@redhat.com>

	* dlfcn/default.c (main): Add test for dladdr of main returning
	argv[0] in dli_fname field.

2000-11-15  Jakub Jelinek  <jakub@redhat.com>

	* Makeconfig (run-program-prefix): Move test-static test into the
	variable.

	* sysdeps/alpha/dl-machine.h (RTLD_START): Update _dl_argv.
	* sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Likewise,
	schedule instructions.
	* sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise,
	schedule instructions, fix a bug in copying auxiliary data.

	* manual/startup.texi (Program Arguments): Fix type of main's envp
	parameter.
	Reported by Ral Nez de Arenas Coronado <dervishd@linuxfreak.com>.
This commit is contained in:
Ulrich Drepper 2000-11-16 02:17:26 +00:00
parent 821dcbccd1
commit 85857f932b
7 changed files with 78 additions and 29 deletions

View File

@ -1,5 +1,25 @@
2000-11-15 Jakub Jelinek <jakub@redhat.com>
* dlfcn/default.c (main): Add test for dladdr of main returning
argv[0] in dli_fname field.
2000-11-15 Jakub Jelinek <jakub@redhat.com>
* Makeconfig (run-program-prefix): Move test-static test into the
variable.
* sysdeps/alpha/dl-machine.h (RTLD_START): Update _dl_argv.
* sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Likewise,
schedule instructions.
* sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise,
schedule instructions, fix a bug in copying auxiliary data.
2000-11-15 Ulrich Drepper <drepper@redhat.com>
* manual/startup.texi (Program Arguments): Fix type of main's envp
parameter.
Reported by Raúl Núñez de Arenas Coronado <dervishd@linuxfreak.com>.
* iconvdata/gconv-modules: Add CP950 alias.
2000-11-13 Jakub Jelinek <jakub@redhat.com>

View File

@ -495,12 +495,9 @@ sysdep-library-path = \
$(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
$(filter -Wl$(comma)-rpath-link=%,\
$(sysdep-LDFLAGS)))))
ifeq (,$(findstring $(notdir $(built-program-file)), $(tests-static)))
run-program-prefix = $(elf-objpfx)$(rtld-installed-name) \
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
else
run-program-prefix =
endif
run-program-prefix = $(if $(findstring $(notdir $(built-program-file)), $(tests-static)),, \
$(elf-objpfx)$(rtld-installed-name) \
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
else
run-program-prefix =
endif

View File

@ -1,5 +1,6 @@
#include <dlfcn.h>
#include <stdio.h>
#include <string.h>
extern int test_in_mod1 (void *);
@ -12,6 +13,21 @@ main (int argc, char *argv[])
int (*ifp) (void);
void *p;
int result = 0;
Dl_info info;
dladdr(main, &info);
if (info.dli_fname == NULL)
{
printf ("%s: dladdr returns NULL dli_fname\n", __FILE__);
result = 1;
}
else if (strcmp (info.dli_fname, argv[0]))
{
printf ("%s: dladdr returned '%s' as dli_fname\n", __FILE__, info.dli_fname);
result = 1;
}
else
printf ("%s: dladdr returned correct dli_fname\n", __FILE__);
/* Find function `main'. */
p = dlsym (RTLD_DEFAULT, "main");

View File

@ -86,7 +86,7 @@ three elements, @code{"cat"}, @code{"foo"} and @code{"bar"}.
In Unix systems you can define @code{main} a third way, using three arguments:
@smallexample
int main (int @var{argc}, char *@var{argv}[], char *@var{envp})
int main (int @var{argc}, char *@var{argv}[], char *@var{envp}[])
@end smallexample
The first two arguments are just the same. The third argument

View File

@ -314,10 +314,14 @@ $fixup_stack:
involves copying everything down, since the stack pointer must
always be 16-byte aligned. */
ldq $2, 0($sp)
ldq $5, _dl_argv
subq $31, $1, $6
subq $2, $1, $2
s8addq $6, $5, $5
mov $sp, $4
s8addq $1, $sp, $3
stq $2, 0($sp)
stq $5, _dl_argv
/* Copy down argv. */
0: ldq $5, 8($3)
addq $4, 8, $4

View File

@ -224,23 +224,29 @@ _dl_start_user:
sethi %hi(__libc_stack_end), %g2
or %g2, %lo(__libc_stack_end), %g2
ld [%l7 + %g2], %l1
sethi %hi(_dl_skip_args), %g2
add %sp, 6*4, %l2
or %g2, %lo(_dl_skip_args), %g2
st %l2, [%l1]
/* See if we were run as a command with the executable file name as an
extra leading argument. If so, adjust the contents of the stack. */
sethi %hi(_dl_skip_args), %g2
or %g2, %lo(_dl_skip_args), %g2
ld [%l7+%g2], %i0
ld [%i0], %i0
tst %i0
beq 3f
ld [%sp+22*4], %i5 /* load argc */
/* Find out how far to shift. */
sethi %hi(_dl_argv), %l3
or %l3, %lo(_dl_argv), %l3
ld [%l7+%l3], %l3
sub %i5, %i0, %i5
ld [%l3], %l4
sll %i0, 2, %i2
st %i5, [%sp+22*4]
sub %l4, %i2, %l4
add %sp, 23*4, %i1
add %i1, %i2, %i2
st %l4, [%l3]
/* Copy down argv */
21: ld [%i2], %i3
add %i2, 4, %i2

View File

@ -546,36 +546,41 @@ _dl_start_user:
1: call 11f
sethi %hi(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
11: or %l7, %lo(_GLOBAL_OFFSET_TABLE_-(1b-.)), %l7
add %l7,%o7,%l7
/* Save the user entry point address in %l0. */
mov %o0,%l0
/* Store the highest stack address. */
sethi %hi(__libc_stack_end), %g5
add %l7, %o7, %l7
or %g5, %lo(__libc_stack_end), %g5
/* Save the user entry point address in %l0. */
mov %o0, %l0
ldx [%l7 + %g5], %l1
sethi %hi(_dl_skip_args), %g5
add %sp, 6*8, %l2
stx %l2, [%l1]
/* See if we were run as a command with the executable file name as an
extra leading argument. If so, we must shift things around since we
must keep the stack doubleword aligned. */
sethi %hi(_dl_skip_args), %g5
or %g5, %lo(_dl_skip_args), %g5
stx %l2, [%l1]
ldx [%l7 + %g5], %i0
ld [%i0], %i0
brz,pt %i0, 2f
ldx [%sp + " __S(STACK_BIAS) " + 22*8], %i5
/* Find out how far to shift. */
sethi %hi(_dl_argv), %l4
sub %i5, %i0, %i5
sllx %i0, 3, %i2
or %l4, %lo(_dl_argv), %l4
sllx %i0, 3, %l6
ldx [%l7 + %l4], %l4
stx %i5, [%sp + " __S(STACK_BIAS) " + 22*8]
add %sp, " __S(STACK_BIAS) " + 23*8, %i1
add %i1, %i2, %i2
add %i1, %l6, %i2
ldx [%l4], %l5
/* Copy down argv. */
12: ldx [%i2], %i3
add %i2, 8, %i2
stx %i3, [%i1]
brnz,pt %i3, 12b
add %i1, 8, %i1
sub %l5, %l6, %l5
/* Copy down envp. */
13: ldx [%i2], %i3
add %i2, 8, %i2
@ -588,8 +593,9 @@ _dl_start_user:
add %i2, 16, %i2
stx %i3, [%i1]
stx %i4, [%i1 + 8]
brnz,pt %i3, 13b
brnz,pt %i3, 14b
add %i1, 16, %i1
stx %l5, [%l4]
/* %o0 = _dl_loaded, %o1 = argc, %o2 = argv, %o3 = envp. */
2: sethi %hi(_dl_loaded), %o0
add %sp, " __S(STACK_BIAS) " + 23*8, %o2