9 #define ELFDATA2 ELFDATA2MSB
11 #define ELFDATA2 ELFDATA2LSB
13 #if SIZEOF_VOID_P != 8 && SIZEOF_VOID_P != 4
14 #error "Unknown word size (SIZEOF_VOID_P)!"
18 unsigned char e_ident[EI_NIDENT];
36 #define DO_SWAPU32(x) ( !swap_bytes() ? x : (uint32_t)bswap_32(x) )
37 #define DO_SWAPU64(x) ( !swap_bytes() ? x : (uint64_t)bswap_64(x) )
38 #define DO_SWAPS32(x) ( !swap_bytes() ? x : (int32_t)bswap_32(x) )
39 #define DO_SWAPS64(x) ( !swap_bytes() ? x : (int64_t)bswap_64(x) )
41 #define EHDRS(x) (is_e32() ? DO_SWAPS32(ehdr.e32.x) : DO_SWAPS64(ehdr.e64.x))
42 #define EHDRU(x) (is_e32() ? DO_SWAPU32(ehdr.e32.x) : DO_SWAPU64(ehdr.e64.x))
43 #define PHDR(x) (is_e32() ? DO_SWAPU32(phdr.e32.x) : DO_SWAPU64(phdr.e64.x))
44 #define SHDR(x) (is_e32() ? DO_SWAPU32(shdr.e32.x) : DO_SWAPU64(shdr.e64.x))
45 #define DYNSU(i,x) (is_e32() ? DO_SWAPU32(((Elf32_Dyn *)dyns)[i].x) \
46 : DO_SWAPU64(((Elf64_Dyn *)dyns)[i].x))
47 #define DYNSS(i,x) (is_e32() ? DO_SWAPS32(((Elf32_Dyn *)dyns)[i].x) \
48 : DO_SWAPS64(((Elf64_Dyn *)dyns)[i].x))
50 int killrpath(const char *filename);
51 int chrpath(const char *filename, const char *newpath, int convert);
53 int elf_open(const char *filename, int flags, Elf_Ehdr *ehdr);
54 void elf_close(int fd);
55 int elf_find_dynamic_section(int fd, Elf_Ehdr *ehdr, Elf_Phdr *phdr);
56 const char *elf_tagname(int tag);
57 int elf_dynpath_tag(int tag);