Browse Source

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

Mike Frysinger 18 years ago
parent
commit
0e89137680
1 changed files with 9 additions and 9 deletions
  1. 9 9
      utils/readsoname2.c

+ 9 - 9
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);