summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldso/ldso/arm/dl-sysdep.h5
-rw-r--r--ldso/ldso/arm/ld_sysdep.h5
-rw-r--r--ldso/ldso/dl-elf.c20
-rw-r--r--ldso/ldso/i386/dl-sysdep.h5
-rw-r--r--ldso/ldso/i386/ld_sysdep.h5
-rw-r--r--ldso/ldso/ldso.c14
-rw-r--r--ldso/ldso/m68k/dl-sysdep.h5
-rw-r--r--ldso/ldso/m68k/ld_sysdep.h5
-rw-r--r--ldso/ldso/mips/dl-sysdep.h5
-rw-r--r--ldso/ldso/mips/ld_sysdep.h5
-rw-r--r--ldso/ldso/powerpc/dl-sysdep.h5
-rw-r--r--ldso/ldso/powerpc/ld_sysdep.h5
-rw-r--r--ldso/ldso/readelflib1.c20
-rw-r--r--ldso/ldso/sparc/dl-sysdep.h4
-rw-r--r--ldso/ldso/sparc/ld_sysdep.h4
15 files changed, 85 insertions, 27 deletions
diff --git a/ldso/ldso/arm/dl-sysdep.h b/ldso/ldso/arm/dl-sysdep.h
index e9905d83e..ef994caad 100644
--- a/ldso/ldso/arm/dl-sysdep.h
+++ b/ldso/ldso/arm/dl-sysdep.h
@@ -117,3 +117,8 @@ static inline unsigned long arm_modulus(unsigned long m, unsigned long p) {
}
#define do_rem(result, n, base) result=arm_modulus(n,base);
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/arm/ld_sysdep.h b/ldso/ldso/arm/ld_sysdep.h
index e9905d83e..ef994caad 100644
--- a/ldso/ldso/arm/ld_sysdep.h
+++ b/ldso/ldso/arm/ld_sysdep.h
@@ -117,3 +117,8 @@ static inline unsigned long arm_modulus(unsigned long m, unsigned long p) {
}
#define do_rem(result, n, base) result=arm_modulus(n,base);
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 1bbb79364..4422a46a0 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -448,9 +448,9 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
char *cpnt;
status = (char *) _dl_mmap((char *) ((piclib ? libaddr : 0) +
- (ppnt->p_vaddr & 0xfffff000)), (ppnt->p_vaddr & 0xfff)
+ (ppnt->p_vaddr & PAGE_ALIGN)), (ppnt->p_vaddr & ADDR_ALIGN)
+ ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags, infile,
- ppnt->p_offset & 0x7ffff000);
+ ppnt->p_offset & OFFS_ALIGN);
if (_dl_mmap_check_error(status)) {
_dl_dprintf(2, "%s: can't map '%s'\n",
@@ -462,9 +462,9 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
};
/* Pad the last page with zeroes. */
- cpnt = (char *) (status + (ppnt->p_vaddr & 0xfff) +
+ cpnt = (char *) (status + (ppnt->p_vaddr & ADDR_ALIGN) +
ppnt->p_filesz);
- while (((unsigned long) cpnt) & 0xfff)
+ while (((unsigned long) cpnt) & ADDR_ALIGN)
*cpnt++ = 0;
/* I am not quite sure if this is completely
@@ -473,17 +473,17 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
* /dev/zero if there are any pages left over
* that are not mapped as part of the file */
- map_size = (ppnt->p_vaddr + ppnt->p_filesz + 0xfff) & 0xfffff000;
+ map_size = (ppnt->p_vaddr + ppnt->p_filesz + ADDR_ALIGN) & PAGE_ALIGN;
if (map_size < ppnt->p_vaddr + ppnt->p_memsz)
status = (char *) _dl_mmap((char *) map_size +
(piclib ? libaddr : 0),
ppnt->p_vaddr + ppnt->p_memsz - map_size,
LXFLAGS(ppnt->p_flags), flags | MAP_ANONYMOUS, -1, 0);
} else
- status = (char *) _dl_mmap((char *) (ppnt->p_vaddr & 0xfffff000)
- + (piclib ? libaddr : 0), (ppnt->p_vaddr & 0xfff) +
+ status = (char *) _dl_mmap((char *) (ppnt->p_vaddr & PAGE_ALIGN)
+ + (piclib ? libaddr : 0), (ppnt->p_vaddr & ADDR_ALIGN) +
ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags,
- infile, ppnt->p_offset & 0x7ffff000);
+ infile, ppnt->p_offset & OFFS_ALIGN);
if (_dl_mmap_check_error(status)) {
_dl_dprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
@@ -559,8 +559,8 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
for (i = 0; i < epnt->e_phnum; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) ((piclib ? libaddr : 0) +
- (ppnt->p_vaddr & 0xfffff000)),
- (ppnt->p_vaddr & 0xfff) + (unsigned long) ppnt->p_filesz,
+ (ppnt->p_vaddr & PAGE_ALIGN)),
+ (ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
diff --git a/ldso/ldso/i386/dl-sysdep.h b/ldso/ldso/i386/dl-sysdep.h
index d44b020ee..7c0f884df 100644
--- a/ldso/ldso/i386/dl-sysdep.h
+++ b/ldso/ldso/i386/dl-sysdep.h
@@ -74,3 +74,8 @@ struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
#define do_rem(result, n, base) result = (n % base)
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/i386/ld_sysdep.h b/ldso/ldso/i386/ld_sysdep.h
index d44b020ee..7c0f884df 100644
--- a/ldso/ldso/i386/ld_sysdep.h
+++ b/ldso/ldso/i386/ld_sysdep.h
@@ -74,3 +74,8 @@ struct elf_resolve;
extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
#define do_rem(result, n, base) result = (n % base)
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 5c3f38d30..c4f0e0bc7 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -448,8 +448,8 @@ DL_BOOT(unsigned long args)
header->e_phoff);
for (i = 0; i < header->e_phnum; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W)) {
- _dl_mprotect((void *) (load_addr + (ppnt->p_vaddr & 0xfffff000)),
- (ppnt->p_vaddr & 0xfff) + (unsigned long) ppnt->p_filesz,
+ _dl_mprotect((void *) (load_addr + (ppnt->p_vaddr & PAGE_ALIGN)),
+ (ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
@@ -460,8 +460,8 @@ DL_BOOT(unsigned long args)
ppnt = (elf_phdr *) auxvt[AT_PHDR].a_un.a_ptr;
for (i = 0; i < auxvt[AT_PHNUM].a_un.a_val; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
- _dl_mprotect((void *) (ppnt->p_vaddr & 0xfffff000),
- (ppnt->p_vaddr & 0xfff) +
+ _dl_mprotect((void *) (ppnt->p_vaddr & PAGE_ALIGN),
+ (ppnt->p_vaddr & ADDR_ALIGN) +
(unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
@@ -720,7 +720,7 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
int readsize = 0;
char *pnt, *pnt1, buf[1024];
tpnt->libname = _dl_strdup((char *) ppnt->p_offset +
- (auxvt[AT_PHDR].a_un.a_val & 0xfffff000));
+ (auxvt[AT_PHDR].a_un.a_val & PAGE_ALIGN));
/* Determine if the shared lib loader is a symlink */
_dl_memset(buf, 0, sizeof(buf));
@@ -1107,8 +1107,8 @@ static void _dl_get_ready_to_run(struct elf_resolve *tpnt, struct elf_resolve *a
for (tpnt = _dl_loaded_modules; tpnt; tpnt = tpnt->next) {
for (ppnt = tpnt->ppnt, i = 0; i < tpnt->n_phent; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W) && tpnt->dynamic_info[DT_TEXTREL]) {
- _dl_mprotect((void *) (tpnt->loadaddr + (ppnt->p_vaddr & 0xfffff000)),
- (ppnt->p_vaddr & 0xfff) + (unsigned long) ppnt->p_filesz, LXFLAGS(ppnt->p_flags));
+ _dl_mprotect((void *) (tpnt->loadaddr + (ppnt->p_vaddr & PAGE_ALIGN)),
+ (ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz, LXFLAGS(ppnt->p_flags));
}
}
}
diff --git a/ldso/ldso/m68k/dl-sysdep.h b/ldso/ldso/m68k/dl-sysdep.h
index a9089286b..2a8dcca5f 100644
--- a/ldso/ldso/m68k/dl-sysdep.h
+++ b/ldso/ldso/m68k/dl-sysdep.h
@@ -81,3 +81,8 @@ extern unsigned int _dl_linux_resolver (int, int, struct elf_resolve *, int);
/* Define this because we do not want to call .udiv in the library.
Not needed for m68k. */
#define do_rem(result, n, base) ((result) = (n) % (base))
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/m68k/ld_sysdep.h b/ldso/ldso/m68k/ld_sysdep.h
index a9089286b..2a8dcca5f 100644
--- a/ldso/ldso/m68k/ld_sysdep.h
+++ b/ldso/ldso/m68k/ld_sysdep.h
@@ -81,3 +81,8 @@ extern unsigned int _dl_linux_resolver (int, int, struct elf_resolve *, int);
/* Define this because we do not want to call .udiv in the library.
Not needed for m68k. */
#define do_rem(result, n, base) ((result) = (n) % (base))
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/mips/dl-sysdep.h b/ldso/ldso/mips/dl-sysdep.h
index a669bba67..6b87e6578 100644
--- a/ldso/ldso/mips/dl-sysdep.h
+++ b/ldso/ldso/mips/dl-sysdep.h
@@ -129,3 +129,8 @@ unsigned long _dl_linux_resolver(unsigned long sym_index,
#define do_rem(result, n, base) result = (n % base)
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/mips/ld_sysdep.h b/ldso/ldso/mips/ld_sysdep.h
index a669bba67..6b87e6578 100644
--- a/ldso/ldso/mips/ld_sysdep.h
+++ b/ldso/ldso/mips/ld_sysdep.h
@@ -129,3 +129,8 @@ unsigned long _dl_linux_resolver(unsigned long sym_index,
#define do_rem(result, n, base) result = (n % base)
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/powerpc/dl-sysdep.h b/ldso/ldso/powerpc/dl-sysdep.h
index 3f4db4682..52aace57f 100644
--- a/ldso/ldso/powerpc/dl-sysdep.h
+++ b/ldso/ldso/powerpc/dl-sysdep.h
@@ -120,3 +120,8 @@ void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
#define do_rem(result, n, base) result = (n % base)
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/powerpc/ld_sysdep.h b/ldso/ldso/powerpc/ld_sysdep.h
index 3f4db4682..52aace57f 100644
--- a/ldso/ldso/powerpc/ld_sysdep.h
+++ b/ldso/ldso/powerpc/ld_sysdep.h
@@ -120,3 +120,8 @@ void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
#define do_rem(result, n, base) result = (n % base)
+
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/readelflib1.c b/ldso/ldso/readelflib1.c
index 1bbb79364..4422a46a0 100644
--- a/ldso/ldso/readelflib1.c
+++ b/ldso/ldso/readelflib1.c
@@ -448,9 +448,9 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
char *cpnt;
status = (char *) _dl_mmap((char *) ((piclib ? libaddr : 0) +
- (ppnt->p_vaddr & 0xfffff000)), (ppnt->p_vaddr & 0xfff)
+ (ppnt->p_vaddr & PAGE_ALIGN)), (ppnt->p_vaddr & ADDR_ALIGN)
+ ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags, infile,
- ppnt->p_offset & 0x7ffff000);
+ ppnt->p_offset & OFFS_ALIGN);
if (_dl_mmap_check_error(status)) {
_dl_dprintf(2, "%s: can't map '%s'\n",
@@ -462,9 +462,9 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
};
/* Pad the last page with zeroes. */
- cpnt = (char *) (status + (ppnt->p_vaddr & 0xfff) +
+ cpnt = (char *) (status + (ppnt->p_vaddr & ADDR_ALIGN) +
ppnt->p_filesz);
- while (((unsigned long) cpnt) & 0xfff)
+ while (((unsigned long) cpnt) & ADDR_ALIGN)
*cpnt++ = 0;
/* I am not quite sure if this is completely
@@ -473,17 +473,17 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
* /dev/zero if there are any pages left over
* that are not mapped as part of the file */
- map_size = (ppnt->p_vaddr + ppnt->p_filesz + 0xfff) & 0xfffff000;
+ map_size = (ppnt->p_vaddr + ppnt->p_filesz + ADDR_ALIGN) & PAGE_ALIGN;
if (map_size < ppnt->p_vaddr + ppnt->p_memsz)
status = (char *) _dl_mmap((char *) map_size +
(piclib ? libaddr : 0),
ppnt->p_vaddr + ppnt->p_memsz - map_size,
LXFLAGS(ppnt->p_flags), flags | MAP_ANONYMOUS, -1, 0);
} else
- status = (char *) _dl_mmap((char *) (ppnt->p_vaddr & 0xfffff000)
- + (piclib ? libaddr : 0), (ppnt->p_vaddr & 0xfff) +
+ status = (char *) _dl_mmap((char *) (ppnt->p_vaddr & PAGE_ALIGN)
+ + (piclib ? libaddr : 0), (ppnt->p_vaddr & ADDR_ALIGN) +
ppnt->p_filesz, LXFLAGS(ppnt->p_flags), flags,
- infile, ppnt->p_offset & 0x7ffff000);
+ infile, ppnt->p_offset & OFFS_ALIGN);
if (_dl_mmap_check_error(status)) {
_dl_dprintf(2, "%s: can't map '%s'\n", _dl_progname, libname);
_dl_internal_error_number = DL_ERROR_MMAP_FAILED;
@@ -559,8 +559,8 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
for (i = 0; i < epnt->e_phnum; i++, ppnt++) {
if (ppnt->p_type == PT_LOAD && !(ppnt->p_flags & PF_W))
_dl_mprotect((void *) ((piclib ? libaddr : 0) +
- (ppnt->p_vaddr & 0xfffff000)),
- (ppnt->p_vaddr & 0xfff) + (unsigned long) ppnt->p_filesz,
+ (ppnt->p_vaddr & PAGE_ALIGN)),
+ (ppnt->p_vaddr & ADDR_ALIGN) + (unsigned long) ppnt->p_filesz,
PROT_READ | PROT_WRITE | PROT_EXEC);
}
}
diff --git a/ldso/ldso/sparc/dl-sysdep.h b/ldso/ldso/sparc/dl-sysdep.h
index 3c8d9b8d1..98660e03b 100644
--- a/ldso/ldso/sparc/dl-sysdep.h
+++ b/ldso/ldso/sparc/dl-sysdep.h
@@ -123,3 +123,7 @@ __asm__("mov %%g0,%%Y\n\t" \
#define _dl_linux_resolve _elf_rtbndr
#endif
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000
diff --git a/ldso/ldso/sparc/ld_sysdep.h b/ldso/ldso/sparc/ld_sysdep.h
index 3c8d9b8d1..98660e03b 100644
--- a/ldso/ldso/sparc/ld_sysdep.h
+++ b/ldso/ldso/sparc/ld_sysdep.h
@@ -123,3 +123,7 @@ __asm__("mov %%g0,%%Y\n\t" \
#define _dl_linux_resolve _elf_rtbndr
#endif
+/* 4096 bytes alignment */
+#define PAGE_ALIGN 0xfffff000
+#define ADDR_ALIGN 0xfff
+#define OFFS_ALIGN 0x7ffff000