From 0e89137680c5b381b022ef5a027a2de169798160 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 30 Dec 2005 06:26:55 +0000 Subject: use ElfW(Addr) instead of ElfW(Word) since elf word types are always 32bits in size, even on 64bit hosts, while Addr is the proper native size ... also get creative with our signed/unsigned usage to get rid of warnings --- utils/readsoname2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'utils') diff --git a/utils/readsoname2.c b/utils/readsoname2.c index 9452c0c4d..029a2bbc1 100644 --- a/utils/readsoname2.c +++ b/utils/readsoname2.c @@ -2,14 +2,14 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type) { ElfW(Ehdr) *epnt; ElfW(Phdr) *ppnt; - int i, j; + unsigned int i, j; char *header; - ElfW(Word) dynamic_addr = 0; - ElfW(Word) dynamic_size = 0; + ElfW(Addr) dynamic_addr = 0; + ElfW(Addr) dynamic_size = 0; unsigned long page_size = getpagesize(); - ElfW(Word) strtab_val = 0; - ElfW(Word) needed_val; - ElfW(Sword) loadaddr = -1; + ElfW(Addr) strtab_val = 0; + ElfW(Addr) needed_val; + ElfW(Addr) loadaddr = -1; ElfW(Dyn) *dpnt; struct stat st; char *needed; @@ -62,7 +62,7 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type) ppnt->p_filesz=bswap_32(ppnt->p_filesz); } - if (loadaddr == -1 && ppnt->p_type == PT_LOAD) + if (loadaddr == (ElfW(Addr))-1 && ppnt->p_type == PT_LOAD) loadaddr = (ppnt->p_vaddr & ~(page_size-1)) - (ppnt->p_offset & ~(page_size-1)); if(ppnt->p_type == 2) @@ -104,8 +104,8 @@ char *readsonameXX(char *name, FILE *infile, int expected_type, int *type) if (dpnt->d_tag == DT_SONAME || dpnt->d_tag == DT_NEEDED) { needed_val = dpnt->d_un.d_val; - if (needed_val + strtab_val - loadaddr >= 0 || - needed_val + strtab_val - loadaddr < st.st_size) + if (needed_val + strtab_val >= loadaddr || + needed_val + strtab_val < st.st_size - loadaddr) { needed = (char *) (header - loadaddr + strtab_val + needed_val); -- cgit v1.2.3