summaryrefslogtreecommitdiff
path: root/ldso
diff options
context:
space:
mode:
authorRon <ron@debian.org>2009-06-27 04:44:28 +0930
committerMike Frysinger <vapier@gentoo.org>2009-07-05 20:27:18 -0400
commite1aba9d040d07a3cc30667a17b9e8d91567f2389 (patch)
tree7e1bce867dd067b4be5e7252c057c07c2772f384 /ldso
parent8ee834680d39677a60e26a0de4ece2f0c1ebbde2 (diff)
Avoid type-punned pointers that break strict-aliasing
Signed-off-by: Ron Lee <ron@debian.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'ldso')
-rw-r--r--ldso/ldso/dl-elf.c4
-rw-r--r--ldso/ldso/dl-startup.c3
2 files changed, 5 insertions, 2 deletions
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 5f59162a7..89708497d 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -338,6 +338,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
ElfW(Addr) relro_addr = 0;
size_t relro_size = 0;
struct stat st;
+ uint32_t *p32;
DL_LOADADDR_TYPE lib_loadaddr;
DL_INIT_LOADADDR_EXTRA_DECLS
@@ -382,7 +383,8 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
_dl_read(infile, header, _dl_pagesize);
epnt = (ElfW(Ehdr) *) (intptr_t) header;
- if (*((uint32_t*) &epnt->e_ident) != ELFMAG_U32) {
+ p32 = (uint32_t*)&epnt->e_ident;
+ if (*p32 != ELFMAG_U32) {
_dl_dprintf(2, "%s: '%s' is not an ELF file\n", _dl_progname,
libname);
_dl_internal_error_number = LD_ERROR_NOTELF;
diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
index 70942bc7a..de9c8bc4e 100644
--- a/ldso/ldso/dl-startup.c
+++ b/ldso/ldso/dl-startup.c
@@ -121,6 +121,7 @@ DL_START(unsigned long args)
struct elf_resolve *tpnt = &tpnt_tmp;
ElfW(auxv_t) auxvt[AT_EGID + 1];
ElfW(Dyn) *dpnt;
+ uint32_t *p32;
/* WARNING! -- we cannot make _any_ function calls until we have
* taken care of fixing up our own relocations. Making static
@@ -176,7 +177,7 @@ DL_START(unsigned long args)
/* Do not use an inline _dl_strncmp here or some arches
* will blow chunks, i.e. those that need to relocate all
* string constants... */
- || *((uint32_t*) &header->e_ident) != ELFMAG_U32
+ || *(p32 = (uint32_t*)&header->e_ident) != ELFMAG_U32
) {
SEND_EARLY_STDERR("Invalid ELF header\n");
_dl_exit(0);