aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2022-09-07 16:45:18 +0100
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2022-10-12 14:22:03 +0100
commit4d7cf069eea6761b9ffceaac6a8be2ad970f4413 (patch)
tree54a9e0a3aab3f6f3373e117f792407c93f8a2d05
parent9c11d64d6d6fcd5ef2fc1acb623744ab6f7099b5 (diff)
downloadglibc-4d7cf069eea6761b9ffceaac6a8be2ad970f4413.tar
glibc-4d7cf069eea6761b9ffceaac6a8be2ad970f4413.tar.gz
glibc-4d7cf069eea6761b9ffceaac6a8be2ad970f4413.tar.bz2
glibc-4d7cf069eea6761b9ffceaac6a8be2ad970f4413.zip
cheri: elf: Turn l_addr back to ElfW(Addr)
Pointers are no longer derived from l_addr, but l_map_start (RX) and l_rw_start (RW) so it does not have to be a capability. This also allows removing hacks where l_addr was derived from DDC.
-rw-r--r--elf/dl-map-segments.h14
-rw-r--r--elf/dl-support.c8
-rw-r--r--elf/do-rel.h2
-rw-r--r--elf/dynamic-link.h6
-rw-r--r--elf/rtld.c5
-rw-r--r--include/link.h2
-rw-r--r--sysdeps/aarch64/morello/dl-machine.h2
7 files changed, 9 insertions, 30 deletions
diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h
index 4ba1c71c73..ce51585ce4 100644
--- a/elf/dl-map-segments.h
+++ b/elf/dl-map-segments.h
@@ -123,7 +123,7 @@ _dl_map_segments (struct link_map *l, int fd,
c->mapend))
return N_("ELF load command address/offset not page-aligned");
if (__glibc_unlikely
- (__mprotect ((caddr_t) (l->l_addr + c->mapend),
+ (__mprotect ((caddr_t) dl_rx_ptr (l, c->mapend),
loadcmds[nloadcmds - 1].mapstart - c->mapend,
PROT_NONE) < 0))
return DL_MAP_SEGMENTS_ERROR_MPROTECT;
@@ -146,14 +146,6 @@ _dl_map_segments (struct link_map *l, int fd,
l->l_map_end = l->l_map_start + maplength;
l->l_contiguous = !has_holes;
- /* TODO: l_addr is 0 in an exe, but it should cover the load segments. */
- uintptr_t l_addr = 0;
- unsigned long allocend = ALIGN_UP (loadcmds[nloadcmds - 1].allocend,
- GLRO(dl_pagesize));
- asm volatile ("cvtd %0, %x0" : "+r"(l_addr));
- asm volatile ("scbnds %0, %0, %x1" : "+r"(l_addr) : "r"(allocend));
- l->l_addr = l_addr;
-
goto postmap;
}
#endif
@@ -167,7 +159,7 @@ _dl_map_segments (struct link_map *l, int fd,
{
if (c->dataend > c->mapstart
/* Map the segment contents from the file. */
- && (__mmap ((void *) (l->l_addr + c->mapstart),
+ && (__mmap ((void *) dl_rx_ptr (l, c->mapstart),
c->dataend - c->mapstart, c->prot,
MAP_FIXED|MAP_COPY|MAP_FILE,
fd, c->mapoff)
@@ -198,7 +190,7 @@ _dl_map_segments (struct link_map *l, int fd,
after the data mapped from the file. */
elfptr_t zero, zeroend, zeropage;
- zero = l->l_addr + c->dataend;
+ zero = dl_rx_ptr (l, c->dataend);
zeroend = l->l_addr + c->allocend;
zeropage = ((zero + GLRO(dl_pagesize) - 1)
& ~(GLRO(dl_pagesize) - 1));
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 8551e18eb2..ffc1d8d01b 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -248,14 +248,6 @@ _dl_aux_init (ElfW(auxv_t) *av)
GL(dl_sysinfo) = DL_SYSINFO_DEFAULT;
#endif
-#ifdef __CHERI_PURE_CAPABILITY__
- /* Base is 0 in non-pie static executable, but it needs to be a valid
- capability. Use the zero capability instead of AT_BASE. */
- elfptr_t zerocap;
- asm volatile ("cvtd %0,xzr" : "=r"(zerocap));
- _dl_main_map.l_addr = zerocap;
-#endif
-
_dl_auxv = av;
dl_parse_auxv_t auxv_values;
/* Use an explicit initialization loop here because memset may not
diff --git a/elf/do-rel.h b/elf/do-rel.h
index 0a2eddf737..219fad2318 100644
--- a/elf/do-rel.h
+++ b/elf/do-rel.h
@@ -48,7 +48,7 @@ elf_dynamic_do_Rel (struct link_map *map, struct r_scope_elem *scope[],
const ElfW(Rel) *relative = (const void *) reladdr;
const ElfW(Rel) *r = relative + nrelative;
const ElfW(Rel) *end = (const void *) (reladdr + relsize);
- elfptr_t l_addr = map->l_addr;
+ ElfW(Addr) l_addr = map->l_addr;
const ElfW(Sym) *const symtab
= (const void *) D_PTR (map, l_info[DT_SYMTAB]);
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
index 86105714bb..e189de49eb 100644
--- a/elf/dynamic-link.h
+++ b/elf/dynamic-link.h
@@ -37,7 +37,7 @@ elf_machine_rel (struct link_map *map, struct r_scope_elem *scope[],
const struct r_found_version *version,
void *const reloc_addr, int skip_ifunc);
static inline void __attribute__((always_inline))
-elf_machine_rel_relative (elfptr_t l_addr, const ElfW(Rel) *reloc,
+elf_machine_rel_relative (ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
void *const reloc_addr);
# endif
# if ! ELF_MACHINE_NO_RELA
@@ -58,12 +58,12 @@ elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
# if ELF_MACHINE_NO_RELA || defined ELF_MACHINE_PLT_REL
static inline void __attribute__((always_inline))
elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
- elfptr_t l_addr, const ElfW(Rel) *reloc,
+ ElfW(Addr) l_addr, const ElfW(Rel) *reloc,
int skip_ifunc);
# else
static inline void __attribute__((always_inline))
elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
- elfptr_t l_addr, const ElfW(Rela) *reloc,
+ ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
int skip_ifunc);
# endif
#endif
diff --git a/elf/rtld.c b/elf/rtld.c
index 82e40e8201..753211772c 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -553,7 +553,6 @@ _dl_start (void *arg)
#ifdef __CHERI_PURE_CAPABILITY__
elf_machine_rtld_base_setup (&bootstrap_map, arg);
- bootstrap_map.l_addr = elf_machine_load_address_from_args (arg);
bootstrap_map.l_ld = elf_machine_runtime_dynamic ();
#else
/* Figure out the run-time load address of the dynamic linker itself. */
@@ -1172,10 +1171,6 @@ rtld_setup_main_map (struct link_map *main_map)
case PT_PHDR:
/* Find out the load address. */
main_map->l_addr = (elfptr_t) phdr - ph->p_vaddr;
-#ifdef __CHERI_PURE_CAPABILITY__
- // TODO: we still need laddr
- asm volatile ("cvtd %0, %x0" : "+r"(main_map->l_addr));
-#endif
break;
case PT_DYNAMIC:
/* This tells us where to find the dynamic section,
diff --git a/include/link.h b/include/link.h
index e1dca89762..67045a79ee 100644
--- a/include/link.h
+++ b/include/link.h
@@ -97,7 +97,7 @@ struct link_map
{
/* These first few members are part of the protocol with the debugger.
This is the same format used in SVR4. */
- elfptr_t l_addr; /* Difference between the address in the ELF
+ ElfW(Addr) l_addr; /* Difference between the address in the ELF
file and the addresses in memory. */
char *l_name; /* Absolute file name object was found in. */
diff --git a/sysdeps/aarch64/morello/dl-machine.h b/sysdeps/aarch64/morello/dl-machine.h
index 1ca4cd0277..5169a48fce 100644
--- a/sysdeps/aarch64/morello/dl-machine.h
+++ b/sysdeps/aarch64/morello/dl-machine.h
@@ -440,7 +440,7 @@ elf_machine_rela_relative (struct link_map *map, const ElfW(Rela) *reloc)
static inline void
__attribute__ ((always_inline))
elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[],
- uintptr_t l_addr,
+ ElfW(Addr) l_addr,
const ElfW(Rela) *reloc,
int skip_ifunc)
{