From 4c69b9f793fc1eae9190d8ba26dba25db616272f Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 8 Aug 2002 14:28:47 +0000 Subject: Patch from Stefan Allius and Edie C. Dost to let ldd and readelf compile under solaris. --- ldso/util/ldd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ldso/util/ldd.c') diff --git a/ldso/util/ldd.c b/ldso/util/ldd.c index 6b9326b53..29c520c60 100644 --- a/ldso/util/ldd.c +++ b/ldso/util/ldd.c @@ -29,7 +29,6 @@ #define _GNU_SOURCE -#include #include #include #include @@ -38,9 +37,14 @@ #include #include #include -#include -#include + +#include "bswap.h" +#if defined (sun) +#include "link.h" +#else #include "elf.h" +#endif + #ifdef DMALLOC #include #endif @@ -102,7 +106,7 @@ void * elf_find_dynamic(int const key, Elf32_Dyn *dynp, for (; DT_NULL!=byteswap32_to_host(dynp->d_tag); ++dynp) { if (key == byteswap32_to_host(dynp->d_tag)) { if (return_val == 1) - return (void *)byteswap32_to_host(dynp->d_un.d_val); + return (void *)(intptr_t)byteswap32_to_host(dynp->d_un.d_val); else return (void *)(byteswap32_to_host(dynp->d_un.d_val) - tx_reloc + (char *)ehdr ); } @@ -133,6 +137,7 @@ int check_elf_header(Elf32_Ehdr *const ehdr) #else #error Unknown host byte order! #endif + /* Be vary lazy, and only byteswap the stuff we use */ if (byteswap==1) { ehdr->e_type=bswap_16(ehdr->e_type); @@ -457,7 +462,7 @@ foo: dynsec = elf_find_section_type(SHT_DYNAMIC, ehdr); find_elf_interpreter(ehdr, dynamic, dynstr, is_suid); if (dynsec) { - dynamic = (Elf32_Dyn*)(byteswap32_to_host(dynsec->sh_offset) + (int)ehdr); + dynamic = (Elf32_Dyn*)(byteswap32_to_host(dynsec->sh_offset) + (intptr_t)ehdr); dynstr = (char *)elf_find_dynamic(DT_STRTAB, dynamic, ehdr, 0); find_needed_libraries(ehdr, dynamic, dynstr, is_suid); } -- cgit v1.2.3