mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-16 01:50:11 +00:00
(RTLD_START):Rewrite for new init function interface.
This commit is contained in:
parent
245bff9408
commit
f0824b0c78
@ -289,37 +289,64 @@ _dl_start_user:
|
|||||||
/* Store the highest stack address. */
|
/* Store the highest stack address. */
|
||||||
stq $30, __libc_stack_end
|
stq $30, __libc_stack_end
|
||||||
/* See if we were run as a command with the executable file
|
/* See if we were run as a command with the executable file
|
||||||
name as an extra leading argument. If so, adjust the stack
|
name as an extra leading argument. */
|
||||||
pointer to skip _dl_skip_args words. */
|
|
||||||
ldl $1, _dl_skip_args
|
ldl $1, _dl_skip_args
|
||||||
beq $1, 0f
|
beq $1, $fixup_stack
|
||||||
ldq $2, 0($sp)
|
$fixup_stack_ret:
|
||||||
subq $2, $1, $2
|
/* The special initializer gets called with the stack just
|
||||||
s8addq $1, $sp, $sp
|
as the application's entry point will see it; it can
|
||||||
stq $2, 0($sp)
|
switch stacks if it moves these contents over. */
|
||||||
/* Load _dl_main_searchlist into s1 to pass to _dl_init_next. */
|
" RTLD_START_SPECIAL_INIT "
|
||||||
0: ldq $10, _dl_main_searchlist
|
/* Call _dl_init(_dl_loaded, argc, argv, envp) to run initializers. */
|
||||||
/* Call _dl_init_next to return the address of an initializer
|
ldq $16, _dl_loaded
|
||||||
function to run. */
|
ldq $17, 0($sp)
|
||||||
1: mov $10, $16
|
lda $18, 8($sp)
|
||||||
jsr $26, _dl_init_next
|
s8addq $17, 8, $19
|
||||||
ldgp $gp, 0($26)
|
addq $19, $18, $19
|
||||||
beq $0, 2f
|
jsr $26, _dl_init
|
||||||
mov $0, $27
|
|
||||||
jsr $26, ($0)
|
|
||||||
ldgp $gp, 0($26)
|
|
||||||
br 1b
|
|
||||||
2: /* Clear the startup flag. */
|
|
||||||
stl $31, _dl_starting_up
|
|
||||||
/* Pass our finalizer function to the user in $0. */
|
/* Pass our finalizer function to the user in $0. */
|
||||||
lda $0, _dl_fini
|
lda $0, _dl_fini
|
||||||
/* Jump to the user's entry point. */
|
/* Jump to the user's entry point. */
|
||||||
mov $9, $27
|
mov $9, $27
|
||||||
jmp ($9)
|
jmp ($9)
|
||||||
|
$fixup_stack:
|
||||||
|
/* Adjust the stack pointer to skip _dl_skip_args words. This
|
||||||
|
involves copying everything down, since the stack pointer must
|
||||||
|
always be 16-byte aligned. */
|
||||||
|
ldq $2, 0($sp)
|
||||||
|
subq $2, $1, $2
|
||||||
|
mov $sp, $4
|
||||||
|
s8addq $2, $sp, $3
|
||||||
|
stq $2, 0($sp)
|
||||||
|
/* Copy down argv. */
|
||||||
|
0: ldq $5, 8($3)
|
||||||
|
addq $4, 8, $4
|
||||||
|
addq $3, 8, $3
|
||||||
|
stq $5, 0($4)
|
||||||
|
bne $5, 0b
|
||||||
|
/* Copy down envp. */
|
||||||
|
1: ldq $5, 8($3)
|
||||||
|
addq $4, 8, $4
|
||||||
|
addq $3, 8, $3
|
||||||
|
stq $5, 0($4)
|
||||||
|
bne $5, 1b
|
||||||
|
/* Copy down auxiliary table. */
|
||||||
|
2: ldq $5, 8($3)
|
||||||
|
ldq $6, 16($3)
|
||||||
|
addq $4, 16, $4
|
||||||
|
addq $3, 16, $3
|
||||||
|
stq $5, -8($4)
|
||||||
|
stq $6, 0($4)
|
||||||
|
bne $5, 2b
|
||||||
|
br $fixup_stack_ret
|
||||||
.end _dl_start_user
|
.end _dl_start_user
|
||||||
.set noat
|
.set noat
|
||||||
.previous");
|
.previous");
|
||||||
|
|
||||||
|
#ifndef RTLD_START_SPECIAL_INIT
|
||||||
|
#define RTLD_START_SPECIAL_INIT /* nothing */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Nonzero iff TYPE describes relocation of a PLT entry, so
|
/* Nonzero iff TYPE describes relocation of a PLT entry, so
|
||||||
PLT entries should not be allowed to define the value. */
|
PLT entries should not be allowed to define the value. */
|
||||||
#define elf_machine_lookup_noplt_p(type) ((type) == R_ALPHA_JMP_SLOT)
|
#define elf_machine_lookup_noplt_p(type) ((type) == R_ALPHA_JMP_SLOT)
|
||||||
@ -350,7 +377,7 @@ elf_machine_fixup_plt(struct link_map *l, const Elf64_Rela *reloc,
|
|||||||
/* Recover the PLT entry address by calculating reloc's index into the
|
/* Recover the PLT entry address by calculating reloc's index into the
|
||||||
.rela.plt, and finding that entry in the .plt. */
|
.rela.plt, and finding that entry in the .plt. */
|
||||||
rela_plt = (void *) D_PTR (l, l_info[DT_JMPREL]);
|
rela_plt = (void *) D_PTR (l, l_info[DT_JMPREL]);
|
||||||
plte = (void *) (D_PTR (l, [DT_PLTGOT]) + 32);
|
plte = (void *) (D_PTR (l, l_info[DT_PLTGOT]) + 32);
|
||||||
plte += 3 * (reloc - rela_plt);
|
plte += 3 * (reloc - rela_plt);
|
||||||
|
|
||||||
/* Find the displacement from the plt entry to the function. */
|
/* Find the displacement from the plt entry to the function. */
|
||||||
|
Loading…
Reference in New Issue
Block a user