1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-07 06:43:00 +03:00

(fixup): Change return type to DL_FIXUP_VALUE_TYPE. Use DL_FIXUP_VALUE_TYPE, DL_FIXUP_MAKE_VALUE and DL_FIXUP_VALUE_CODE_ADDR for relocation values. Use DL_FIXUP_VALUE_ADDR and DL_FIXUP_ADDR_VALUE to store and retrieve relocation values. (profile_fixup): Likewise.

This commit is contained in:
Ulrich Drepper
2005-02-07 22:47:00 +00:00
parent 58954d492d
commit 028dca779d

View File

@@ -52,7 +52,7 @@
function. */ function. */
#ifndef ELF_MACHINE_NO_PLT #ifndef ELF_MACHINE_NO_PLT
ElfW(Addr) DL_FIXUP_VALUE_TYPE
__attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
_dl_fixup ( _dl_fixup (
# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS # ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
@@ -71,7 +71,7 @@ _dl_fixup (
const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)]; const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
void *const rel_addr = (void *)(l->l_addr + reloc->r_offset); void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);
lookup_t result; lookup_t result;
ElfW(Addr) value; DL_FIXUP_VALUE_TYPE value;
/* Sanity check that we're really looking at a PLT relocation. */ /* Sanity check that we're really looking at a PLT relocation. */
assert (ELFW(R_TYPE)(reloc->r_info) == ELF_MACHINE_JMP_SLOT); assert (ELFW(R_TYPE)(reloc->r_info) == ELF_MACHINE_JMP_SLOT);
@@ -99,13 +99,15 @@ _dl_fixup (
/* Currently result contains the base load address (or link map) /* Currently result contains the base load address (or link map)
of the object that defines sym. Now add in the symbol of the object that defines sym. Now add in the symbol
offset. */ offset. */
value = (sym ? LOOKUP_VALUE_ADDRESS (result) + sym->st_value : 0); value = DL_FIXUP_MAKE_VALUE (result,
sym ? LOOKUP_VALUE_ADDRESS (result)
+ sym->st_value : 0);
} }
else else
{ {
/* We already found the symbol. The module (and therefore its load /* We already found the symbol. The module (and therefore its load
address) is also known. */ address) is also known. */
value = l->l_addr + sym->st_value; value = DL_FIXUP_MAKE_VALUE (l, l->l_addr + sym->st_value);
result = l; result = l;
} }
@@ -122,7 +124,7 @@ _dl_fixup (
#if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__ #if !defined PROF && !defined ELF_MACHINE_NO_PLT && !__BOUNDED_POINTERS__
ElfW(Addr) DL_FIXUP_VALUE_TYPE
__attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE __attribute ((noinline)) ARCH_FIXUP_ATTRIBUTE
_dl_profile_fixup ( _dl_profile_fixup (
#ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS #ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
@@ -137,10 +139,10 @@ _dl_profile_fixup (
relocations. */ relocations. */
struct reloc_result *reloc_result struct reloc_result *reloc_result
= &l->l_reloc_result[reloc_offset / sizeof (PLTREL)]; = &l->l_reloc_result[reloc_offset / sizeof (PLTREL)];
ElfW(Addr) *resultp = &reloc_result->addr; DL_FIXUP_VALUE_TYPE *resultp = &reloc_result->addr;
ElfW(Addr) value = *resultp; DL_FIXUP_VALUE_TYPE value = *resultp;
if (value == 0) if (DL_FIXUP_VALUE_CODE_ADDR (value) == 0)
{ {
/* This is the first time we have to relocate this object. */ /* This is the first time we have to relocate this object. */
const ElfW(Sym) *const symtab const ElfW(Sym) *const symtab
@@ -180,14 +182,16 @@ _dl_profile_fixup (
/* Currently result contains the base load address (or link map) /* Currently result contains the base load address (or link map)
of the object that defines sym. Now add in the symbol of the object that defines sym. Now add in the symbol
offset. */ offset. */
value = (defsym != NULL value = DL_FIXUP_MAKE_VALUE (result,
? LOOKUP_VALUE_ADDRESS (result) + defsym->st_value : 0); defsym != NULL
? LOOKUP_VALUE_ADDRESS (result)
+ defsym->st_value : 0);
} }
else else
{ {
/* We already found the symbol. The module (and therefore its load /* We already found the symbol. The module (and therefore its load
address) is also known. */ address) is also known. */
value = l->l_addr + refsym->st_value; value = DL_FIXUP_MAKE_VALUE (l, l->l_addr + refsym->st_value);
result = l; result = l;
} }
/* And now perhaps the relocation addend. */ /* And now perhaps the relocation addend. */
@@ -215,7 +219,7 @@ _dl_profile_fixup (
/* Synthesize a symbol record where the st_value field is /* Synthesize a symbol record where the st_value field is
the result. */ the result. */
ElfW(Sym) sym = *defsym; ElfW(Sym) sym = *defsym;
sym.st_value = value; sym.st_value = DL_FIXUP_VALUE_ADDR (value);
/* Keep track whether there is any interest in tracing /* Keep track whether there is any interest in tracing
the call in the lower two bits. */ the call in the lower two bits. */
@@ -268,7 +272,7 @@ _dl_profile_fixup (
} }
reloc_result->flags = altvalue; reloc_result->flags = altvalue;
value = sym.st_value; value = DL_FIXUP_ADDR_VALUE (sym.st_value);
} }
else else
/* Set all bits since this symbol binding is not interesting. */ /* Set all bits since this symbol binding is not interesting. */
@@ -287,7 +291,7 @@ _dl_profile_fixup (
#ifdef SHARED #ifdef SHARED
/* Auditing checkpoint: report the PLT entering and allow the /* Auditing checkpoint: report the PLT entering and allow the
auditors to change the value. */ auditors to change the value. */
if (value != 0 && GLRO(dl_naudit) > 0 if (DL_FIXUP_VALUE_CODE_ADDR (value) != 0 && GLRO(dl_naudit) > 0
/* Don't do anything if no auditor wants to intercept this call. */ /* Don't do anything if no auditor wants to intercept this call. */
&& (reloc_result->enterexit & LA_SYMB_NOPLTENTER) == 0) && (reloc_result->enterexit & LA_SYMB_NOPLTENTER) == 0)
{ {
@@ -297,7 +301,7 @@ _dl_profile_fixup (
/* Set up the sym parameter. */ /* Set up the sym parameter. */
ElfW(Sym) sym = *defsym; ElfW(Sym) sym = *defsym;
sym.st_value = value; sym.st_value = DL_FIXUP_VALUE_ADDR (value);
/* Get the symbol name. */ /* Get the symbol name. */
const char *strtab = (const void *) D_PTR (reloc_result->bound, const char *strtab = (const void *) D_PTR (reloc_result->bound,
@@ -352,14 +356,14 @@ _dl_profile_fixup (
afct = afct->next; afct = afct->next;
} }
value = sym.st_value; value = DL_FIXUP_ADDR_VALUE (sym.st_value);
} }
#endif #endif
/* Store the frame size information. */ /* Store the frame size information. */
*framesizep = framesize; *framesizep = framesize;
(*mcount_fct) (retaddr, value); (*mcount_fct) (retaddr, DL_FIXUP_VALUE_CODE_ADDR (value));
return value; return value;
} }