if (ph->p_type == DLFO_EH_SEGMENT_TYPE)
{
atomic_store_relaxed (&result->eh_frame,
- (void *) (ph->p_vaddr + l->l_addr));
+ (void *) dl_rx_ptr (l, ph->p_vaddr));
#if DLFO_STRUCT_HAS_EH_COUNT
atomic_store_relaxed (&result->eh_count, ph->p_memsz / 8);
#endif
void
_dl_process_pt_gnu_property (struct link_map *l, int fd, const ElfW(Phdr) *ph)
{
- const ElfW(Nhdr) *note = (const void *) (ph->p_vaddr + l->l_addr);
+ const ElfW(Nhdr) *note = (const void *) dl_rx_ptr (l, ph->p_vaddr);
const ElfW(Addr) size = ph->p_memsz;
const ElfW(Addr) align = ph->p_align;
}
else
/* Adjust the PT_PHDR value by the runtime load address. */
- l->l_phdr = (ElfW(Phdr) *) ((ElfW(Addr)) l->l_phdr + l->l_addr);
+ l->l_phdr = (ElfW(Phdr) *) dl_rx_ptr (l, (ElfW(Addr)) l->l_phdr);
if (__glibc_unlikely ((stack_flags &~ GL(dl_stack_flags)) & PF_X))
{
/* Adjust the address of the TLS initialization image. */
if (l->l_tls_initimage != NULL)
- l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
+ l->l_tls_initimage
+ = (void *) dl_rw_ptr (l, (ElfW(Addr)) l->l_tls_initimage);
/* Process program headers again after load segments are mapped in
case processing requires accessing those segments. Scan program
/* If this is ET_EXEC, we should have loaded it as lt_executable. */
assert (type != ET_EXEC || l->l_type == lt_executable);
- l->l_entry += l->l_addr;
+ l->l_entry = dl_rx_ptr (l, l->l_entry);
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_FILES))
_dl_debug_printf ("\
+ reloc_offset (pltgot, reloc_arg));
const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
const ElfW(Sym) *refsym = sym;
- void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);
+ void *const rel_addr = (void *) dl_rw_ptr (l, reloc->r_offset);
lookup_t result;
DL_FIXUP_VALUE_TYPE value;
def_offset = map->l_info[VERSYMIDX (DT_VERDEF)]->d_un.d_ptr;
assert (def_offset != 0);
- def = (ElfW(Verdef) *) ((char *) map->l_addr + def_offset);
+ def = (ElfW(Verdef) *) dl_rx_ptr (map, def_offset);
while (1)
{
/* Currently the version number of the definition entry is 1.
if (dyn != NULL)
{
/* This file requires special versions from its dependencies. */
- ElfW(Verneed) *ent = (ElfW(Verneed) *) (map->l_addr + dyn->d_un.d_ptr);
+ ElfW(Verneed) *ent = (ElfW(Verneed) *) dl_rx_ptr (map, dyn->d_un.d_ptr);
/* Currently the version number of the needed entry is 1.
Make sure all we see is this version. */
if (def != NULL)
{
ElfW(Verdef) *ent;
- ent = (ElfW(Verdef) *) (map->l_addr + def->d_un.d_ptr);
+ ent = (ElfW(Verdef) *) dl_rx_ptr (map, def->d_un.d_ptr);
while (1)
{
if ((unsigned int) (ent->vd_ndx & 0x7fff) > ndx_high)
if (dyn != NULL)
{
ElfW(Verneed) *ent;
- ent = (ElfW(Verneed) *) (map->l_addr + dyn->d_un.d_ptr);
+ ent = (ElfW(Verneed) *) dl_rx_ptr (map, dyn->d_un.d_ptr);
while (1)
{
ElfW(Vernaux) *aux;
if (def != NULL)
{
ElfW(Verdef) *ent;
- ent = (ElfW(Verdef) *) (map->l_addr + def->d_un.d_ptr);
+ ent = (ElfW(Verdef) *) dl_rx_ptr (map, def->d_un.d_ptr);
while (1)
{
ElfW(Verdaux) *aux;
{
ElfW (Half) ndx = version[ELFW (R_SYM) (r->r_info)] & 0x7fff;
const ElfW (Sym) *sym = &symtab[ELFW (R_SYM) (r->r_info)];
- void *const r_addr_arg = (void *) (l_addr + r->r_offset);
+ void *const r_addr_arg = (void *) dl_rw_ptr (map, r->r_offset);
const struct r_found_version *rversion = &map->l_versions[ndx];
elf_machine_rel (map, scope, r, sym, rversion, r_addr_arg, skip_ifunc);
{
ElfW(Half) ndx = version[ELFW(R_SYM) (r->r_info)] & 0x7fff;
const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (r->r_info)];
- void *const r_addr_arg = (void *) (l_addr + r->r_offset);
+ void *const r_addr_arg = (void *) dl_rw_ptr (map, r->r_offset);
const struct r_found_version *rversion = &map->l_versions[ndx];
#if defined ELF_MACHINE_IRELATIVE
if (ELFW(R_TYPE) (r->r_info) == ELF_MACHINE_IRELATIVE)
elf_machine_rel (map, scope, r2,
&symtab[ELFW(R_SYM) (r2->r_info)],
&map->l_versions[ndx],
- (void *) (l_addr + r2->r_offset),
+ (void *) dl_rw_ptr (map, r2->r_offset),
skip_ifunc);
}
#endif
for (; r < end; ++r)
{
const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (r->r_info)];
- void *const r_addr_arg = (void *) (l_addr + r->r_offset);
+ void *const r_addr_arg = (void *) dl_rw_ptr (map, r->r_offset);
# ifdef ELF_MACHINE_IRELATIVE
if (ELFW(R_TYPE) (r->r_info) == ELF_MACHINE_IRELATIVE)
{
for (; r2 <= end2; ++r2)
if (ELFW(R_TYPE) (r2->r_info) == ELF_MACHINE_IRELATIVE)
elf_machine_rel (map, scope, r2, &symtab[ELFW(R_SYM) (r2->r_info)],
- NULL, (void *) (l_addr + r2->r_offset),
+ NULL, (void *) dl_rw_ptr (map, r2->r_offset),
skip_ifunc);
# endif
}
/* The file has no symbol versioning. */
return 0;
- def = (ElfW(Verdef) *) ((char *) map->l_addr
- + map->l_info[VERDEFTAG]->d_un.d_ptr);
+ def = (ElfW(Verdef) *) dl_rx_ptr (map, map->l_info[VERDEFTAG]->d_un.d_ptr);
while (1)
{
ElfW(Verdaux) *aux = (ElfW(Verdaux) *) ((char *) def + def->vd_aux);
dlopen call or DT_NEEDED entry, for something that wants to link
against the dynamic linker as a shared library, will know that
the shared object is already loaded. */
- _dl_rtld_libname.name = ((const char *) main_map->l_addr
- + ph->p_vaddr);
+ _dl_rtld_libname.name = (const char *) dl_rx_ptr (main_map,
+ ph->p_vaddr);
/* _dl_rtld_libname.next = NULL; Already zero. */
GL(dl_rtld_map).l_libname = &_dl_rtld_libname;
the executable is actually an ET_DYN object. */
if (main_map->l_tls_initimage != NULL)
main_map->l_tls_initimage
- = (char *) main_map->l_tls_initimage + main_map->l_addr;
+ = (void *) dl_rx_ptr (main_map, (ElfW(Addr)) main_map->l_tls_initimage);
if (! main_map->l_map_end)
main_map->l_map_end = ~0;
if (! main_map->l_text_end)
continue;
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
- ent = (ElfW(Verneed) *) (map->l_addr + dyn->d_un.d_ptr);
+ ent = (ElfW(Verneed) *) dl_rx_ptr (map, dyn->d_un.d_ptr);
if (first)
{
most architectures the entry is already relocated - but for some not
and we need to relocate at access time. */
#define D_PTR(map, i) \
- ((map)->i->d_un.d_ptr + (dl_relocate_ld (map) ? 0 : (map)->l_addr))
+ (dl_relocate_ld (map) ? (map)->i->d_un.d_ptr \
+ : dl_rx_ptr ((map), (map)->i->d_un.d_ptr))
/* Result of the lookup functions and how to retrieve the base address. */
typedef struct link_map *lookup_t;