diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/ldconfig.c | 4 | ||||
-rw-r--r-- | utils/ldd.c | 7 | ||||
-rw-r--r-- | utils/readelf.c | 64 | ||||
-rw-r--r-- | utils/readsoname2.c | 18 |
4 files changed, 62 insertions, 31 deletions
diff --git a/utils/ldconfig.c b/utils/ldconfig.c index 85ce015d5..f54eadd27 100644 --- a/utils/ldconfig.c +++ b/utils/ldconfig.c @@ -779,10 +779,10 @@ void cache_write(void) for (cur_lib = lib_head; cur_lib != NULL; cur_lib = cur_lib->next) { - if (write(cachefd, cur_lib->soname, strlen(cur_lib->soname) + 1) + if ((size_t)write(cachefd, cur_lib->soname, strlen(cur_lib->soname) + 1) != strlen(cur_lib->soname) + 1) err(EXIT_FATAL,"can't write %s~ (%s)", cachefile, strerror(errno)); - if (write(cachefd, cur_lib->libname, strlen(cur_lib->libname) + 1) + if ((size_t)write(cachefd, cur_lib->libname, strlen(cur_lib->libname) + 1) != strlen(cur_lib->libname) + 1) err(EXIT_FATAL,"can't write %s~ (%s)", cachefile, strerror(errno)); } diff --git a/utils/ldd.c b/utils/ldd.c index dbd2f6de8..4545cf328 100644 --- a/utils/ldd.c +++ b/utils/ldd.c @@ -191,7 +191,7 @@ inline uint64_t byteswap64_to_host(uint64_t value) # define byteswap_to_host(x) byteswap64_to_host(x) #endif -ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) +ElfW(Shdr) * elf_find_section_type( uint32_t key, ElfW(Ehdr) *ehdr) { int j; ElfW(Shdr) *shdr; @@ -204,7 +204,7 @@ ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) return NULL; } -ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) +ElfW(Phdr) * elf_find_phdr_type( uint32_t type, ElfW(Ehdr) *ehdr) { int j; ElfW(Phdr) *phdr = (ElfW(Phdr) *)(ehdr->e_phoff + (char *)ehdr); @@ -217,7 +217,7 @@ ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) } /* Returns value if return_val==1, ptr otherwise */ -void * elf_find_dynamic(int const key, ElfW(Dyn) *dynp, +void * elf_find_dynamic( int64_t const key, ElfW(Dyn) *dynp, ElfW(Ehdr) *ehdr, int return_val) { ElfW(Phdr) *pt_text = elf_find_phdr_type(PT_LOAD, ehdr); @@ -648,6 +648,7 @@ static struct library * find_elf_interpreter(ElfW(Ehdr)* ehdr) } /* map the .so, and locate interesting pieces */ +#warning "There may be two warnings here about vfork() clobbering, ignore them" int find_dependancies(char* filename) { int is_suid = 0; diff --git a/utils/readelf.c b/utils/readelf.c index c7516ef4f..0aaf2de65 100644 --- a/utils/readelf.c +++ b/utils/readelf.c @@ -64,7 +64,7 @@ inline uint64_t byteswap64_to_host(uint64_t value) # define byteswap_to_host(x) byteswap32_to_host(x) #endif -ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) +ElfW(Shdr) * elf_find_section_type( uint32_t key, ElfW(Ehdr) *ehdr) { int j; ElfW(Shdr) *shdr = (ElfW(Shdr) *)(ehdr->e_shoff + (char *)ehdr); @@ -76,7 +76,7 @@ ElfW(Shdr) * elf_find_section_type( int key, ElfW(Ehdr) *ehdr) return NULL; } -ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) +ElfW(Phdr) * elf_find_phdr_type( uint32_t type, ElfW(Ehdr) *ehdr) { int j; ElfW(Phdr) *phdr = (ElfW(Phdr) *)(ehdr->e_phoff + (char *)ehdr); @@ -89,7 +89,7 @@ ElfW(Phdr) * elf_find_phdr_type( int type, ElfW(Ehdr) *ehdr) } /* Returns value if return_val==1, ptr otherwise */ -void * elf_find_dynamic(int const key, ElfW(Dyn) *dynp, +void * elf_find_dynamic( int64_t const key, ElfW(Dyn) *dynp, ElfW(Ehdr) *ehdr, int return_val) { ElfW(Phdr) *pt_text = elf_find_phdr_type(PT_LOAD, ehdr); @@ -164,21 +164,22 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_386: tmp="Intel 80386"; break; case EM_68K: tmp="Motorola m68k family"; break; case EM_88K: tmp="Motorola m88k family"; break; + case EM_486: tmp="Intel 80486"; break; case EM_860: tmp="Intel 80860"; break; case EM_MIPS: tmp="MIPS R3000 big-endian"; break; case EM_S370: tmp="IBM System/370"; break; case EM_MIPS_RS3_LE: tmp="MIPS R3000 little-endian"; break; + case EM_OLD_SPARCV9: tmp="Sparc v9 (old)"; break; case EM_PARISC: tmp="HPPA"; break; - case EM_VPP500: tmp="Fujitsu VPP500"; break; + /*case EM_PPC_OLD: tmp="Power PC (old)"; break; conflicts with EM_VPP500 */ case EM_SPARC32PLUS: tmp="Sun's v8plus"; break; case EM_960: tmp="Intel 80960"; break; case EM_PPC: tmp="PowerPC"; break; case EM_PPC64: tmp="PowerPC 64-bit"; break; - case EM_S390: tmp="IBM S390"; break; case EM_V800: tmp="NEC V800 series"; break; case EM_FR20: tmp="Fujitsu FR20"; break; case EM_RH32: tmp="TRW RH-32"; break; - case EM_RCE: tmp="Motorola RCE"; break; + case EM_MCORE: tmp="MCORE"; break; case EM_ARM: tmp="ARM"; break; case EM_FAKE_ALPHA: tmp="Digital Alpha"; break; case EM_SH: tmp="Renesas SH"; break; @@ -193,6 +194,24 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_MIPS_X: tmp="Stanford MIPS-X"; break; case EM_COLDFIRE: tmp="Motorola Coldfire"; break; case EM_68HC12: tmp="Motorola M68HC12"; break; + case EM_ALPHA: tmp="Alpha"; break; + case EM_CYGNUS_D10V: + case EM_D10V: tmp="Mitsubishi D10V"; break; + case EM_CYGNUS_D30V: + case EM_D30V: tmp="Mitsubishi D30V"; break; + case EM_CYGNUS_M32R: + case EM_M32R: tmp="Renesas M32R (formerly Mitsubishi M32r)"; break; + case EM_CYGNUS_V850: + case EM_V850: tmp="NEC v850"; break; + case EM_CYGNUS_MN10300: + case EM_MN10300: tmp="Matsushita MN10300"; break; + case EM_CYGNUS_MN10200: + case EM_MN10200: tmp="Matsushita MN10200"; break; + case EM_CYGNUS_FR30: + case EM_FR30: tmp="Fujitsu FR30"; break; + case EM_CYGNUS_FRV: + case EM_PJ_OLD: + case EM_PJ: tmp="picoJava"; break; case EM_MMA: tmp="Fujitsu MMA Multimedia Accelerator"; break; case EM_PCP: tmp="Siemens PCP"; break; case EM_NCPU: tmp="Sony nCPU embeeded RISC"; break; @@ -201,8 +220,6 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_ME16: tmp="Toyota ME16 processor"; break; case EM_ST100: tmp="STMicroelectronic ST100 processor"; break; case EM_TINYJ: tmp="Advanced Logic Corp. Tinyj emb.fam"; break; - case EM_X86_64: tmp="AMD x86-64 architecture"; break; - case EM_PDSP: tmp="Sony DSP Processor"; break; case EM_FX66: tmp="Siemens FX66 microcontroller"; break; case EM_ST9PLUS: tmp="STMicroelectronics ST9+ 8/16 mc"; break; case EM_ST7: tmp="STmicroelectronics ST7 8 bit mc"; break; @@ -213,6 +230,8 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_SVX: tmp="Silicon Graphics SVx"; break; case EM_ST19: tmp="STMicroelectronics ST19 8 bit mc"; break; case EM_VAX: tmp="Digital VAX"; break; + case EM_AVR_OLD: + case EM_AVR: tmp="Atmel AVR 8-bit microcontroller"; break; case EM_CRIS: tmp="Axis Communications 32-bit embedded processor"; break; case EM_JAVELIN: tmp="Infineon Technologies 32-bit embedded processor"; break; case EM_FIREPATH: tmp="Element 14 64-bit DSP Processor"; break; @@ -220,15 +239,26 @@ static void describe_elf_hdr(ElfW(Ehdr)* ehdr) case EM_MMIX: tmp="Donald Knuth's educational 64-bit processor"; break; case EM_HUANY: tmp="Harvard University machine-independent object files"; break; case EM_PRISM: tmp="SiTera Prism"; break; - case EM_AVR: tmp="Atmel AVR 8-bit microcontroller"; break; - case EM_FR30: tmp="Fujitsu FR30"; break; - case EM_D10V: tmp="Mitsubishi D10V"; break; - case EM_D30V: tmp="Mitsubishi D30V"; break; - case EM_V850: tmp="NEC v850"; break; - case EM_M32R: tmp="Renesas M32R"; break; - case EM_MN10300: tmp="Matsushita MN10300"; break; - case EM_MN10200: tmp="Matsushita MN10200"; break; - case EM_PJ: tmp="picoJava"; break; + case EM_X86_64: tmp="AMD x86-64 architecture"; break; + case EM_S390_OLD: + case EM_S390: tmp="IBM S390"; break; + case EM_XSTORMY16: tmp="Sanyo Xstormy16 CPU core"; break; + case EM_OPENRISC: + case EM_OR32: tmp="OpenRISC"; break; + case EM_CRX: tmp="National Semiconductor CRX microprocessor"; break; + case EM_DLX: tmp="OpenDLX"; break; + case EM_IP2K_OLD: + case EM_IP2K: tmp="Ubicom IP2xxx 8-bit microcontrollers"; break; + case EM_IQ2000: tmp="Vitesse IQ2000"; break; + case EM_XTENSA_OLD: + case EM_XTENSA: tmp="Tensilica Xtensa Processor"; break; + case EM_M32C: tmp="Renesas M32c"; break; + case EM_MT: tmp="Morpho Techologies MT processor"; break; + case EM_BLACKFIN: tmp="Analog Devices Blackfin"; break; + case EM_NIOS32: tmp="Altera Nios 32"; break; + case EM_ALTERA_NIOS2: tmp="Altera Nios II"; break; + case EM_VPP500: tmp="Fujitsu VPP500"; break; + case EM_PDSP: tmp="Sony DSP Processor"; break; default: tmp="unknown"; } printf( "Machine:\t%s\n", tmp); 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); |