write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/* FIXME: Profiling of shared libraries is not implemented yet. */
#ifndef dl_machine_h
#define dl_machine_h
#error ENTRY_POINT needs to be defined for MIPS.
#endif
+/* The offset of gp from GOT might be system-dependent. It's set by
+ ld. The same value is also */
+#define OFFSET_GP_GOT 0x7ff0
+
#ifndef _RTLD_PROLOGUE
# define _RTLD_PROLOGUE(entry) "\n\t.globl " #entry \
"\n\t.ent " #entry \
elf_mips_got_from_gpreg (ElfW(Addr) gpreg)
{
/* FIXME: the offset of gp from GOT may be system-dependent. */
- return (ElfW(Addr) *) (gpreg - 0x7ff0);
+ return (ElfW(Addr) *) (gpreg - OFFSET_GP_GOT);
}
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
_dl_runtime_resolve. MIPS instead calls __dl_runtime_resolve. We
have to use our own version because of the way the got section is
treaded on MIPS (we've also got ELF_MACHINE_PLT defined). */
-
+
#define ELF_MACHINE_RUNTIME_TRAMPOLINE \
/* The flag _dl_mips_gnu_objects is set if all dynamic objects are \
generated by the gnu linker. */ \
= (const ElfW(Word)) l->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val; \
const ElfW(Word) gotsym \
= (const ElfW(Word)) l->l_info[DT_MIPS (GOTSYM)]->d_un.d_val; \
- const ElfW(Sym) *sym; \
- ElfW(Addr) funcaddr; \
+ const ElfW(Sym) *sym = &symtab[sym_index]; \
ElfW(Addr) value; \
\
- /* Look up the symbol's run-time value. */ \
- sym = &symtab[sym_index]; \
/* FIXME: The symbol versioning stuff is not tested yet. */ \
if (__builtin_expect (ELFW(ST_VISIBILITY) (sym->st_other), 0) == 0) \
{ \
/* Apply the relocation with that value. */ \
*(got + local_gotno + sym_index - gotsym) = value; \
\
- return value; \
+ return value; \
} \
\
asm ("\n \
_dl_runtime_resolve:\n \
.set noreorder\n \
# Save slot call pc.\n \
+ # XXX: Is this ok? \
move $3, $31\n \
# Modify t9 ($25) so as to point .cpload instruction.\n \
addu $25,8\n \
# the address of the dynamic structure. Though MIPS ABI\n\
# doesn't say nothing about this, I emulate this here.\n\
la $4, _DYNAMIC\n\
+ # Subtract OFFSET_GP_GOT\n\
sw $4, -0x7ff0($28)\n\
move $4, $29\n\
subu $29, 16\n\
ElfW(Addr) *got;
ElfW(Sym) *sym;
int i, n, symidx;
+#ifndef RTLD_BOOTSTRAP
const char *strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
+#endif
/* This function is loaded in dl-reloc as a nested function and can
therefore access the variable scope from _dl_relocate_object. */
#ifdef RTLD_BOOTSTRAP
i = (got[1] & ELF_MIPS_GNU_GOT1_MASK)? 2: 1;
n = map->l_info[DT_MIPS (LOCAL_GOTNO)]->d_un.d_val;
/* Add the run-time display to all local got entries if needed. */
- if (map->l_addr != 0)
+ if (__builtin_expect (map->l_addr != 0, 0))
{
while (i < n)
got[i++] += map->l_addr;
}
-
+
/* Handle global got entries. */
got += n;
/* Keep track of the symbol index. */
sym = (ElfW(Sym) *) D_PTR (map, l_info[DT_SYMTAB]) + symidx;
i = (map->l_info[DT_MIPS (SYMTABNO)]->d_un.d_val
- map->l_info[DT_MIPS (GOTSYM)]->d_un.d_val);
-
+
+ /* This loop doesn't handle Quickstart. */
while (i--)
{
if (sym->st_shndx == SHN_UNDEF)
{
- if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC)
- {
- if (sym->st_value && lazy)
- *got = sym->st_value + map->l_addr;
- else
- *got = RESOLVE_GOTSYM (sym, symidx);
- }
- else /* if (*got == 0 || *got == QS) */
+ if (ELFW(ST_TYPE) (sym->st_info) == STT_FUNC
+ && sym->st_value && lazy)
+ *got = sym->st_value + map->l_addr;
+ else
*got = RESOLVE_GOTSYM (sym, symidx);
}
else if (sym->st_shndx == SHN_COMMON)