Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2. libelf.h - public header file for libelf.
  3. Copyright (C) 1995 - 1998 Michael Riepe <michael@stud.uni-hannover.de>
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public
  7. License as published by the Free Software Foundation; either
  8. version 2 of the License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19.  
  20. /* @(#) $Id: libelf.h,v 1.5 1998/06/01 19:47:18 michael Exp $ */
  21.  
  22. #ifndef _LIBELF_H
  23. #define _LIBELF_H
  24.  
  25. #include <sys/types.h>
  26.  
  27. #if __LIBELF_INTERNAL__
  28. #include <sys_elf.h>
  29. #else /* __LIBELF_INTERNAL__ */
  30. #include <libelf/sys_elf.h>
  31. #endif /* __LIBELF_INTERNAL__ */
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif /* __cplusplus */
  36.  
  37. #ifndef __P
  38. # if __STDC__ || defined(__cplusplus)
  39. #  define __P(args) args
  40. # else /* __STDC__ || defined(__cplusplus) */
  41. #  define __P(args) ()
  42. # endif /* __STDC__ || defined(__cplusplus) */
  43. #endif /* __P */
  44.  
  45. /*
  46.  * Commands
  47.  */
  48. typedef enum {
  49.     ELF_C_NULL = 0,     /* must be first, 0 */
  50.     ELF_C_READ,
  51.     ELF_C_WRITE,
  52.     ELF_C_CLR,
  53.     ELF_C_SET,
  54.     ELF_C_FDDONE,
  55.     ELF_C_FDREAD,
  56.     ELF_C_RDWR,
  57.     ELF_C_NUM           /* must be last */
  58. } Elf_Cmd;
  59.  
  60. /*
  61.  * Flags
  62.  */
  63. #define ELF_F_DIRTY     0x1
  64. #define ELF_F_LAYOUT    0x4
  65.  
  66. /*
  67.  * File types
  68.  */
  69. typedef enum {
  70.     ELF_K_NONE = 0,     /* must be first, 0 */
  71.     ELF_K_AR,
  72.     ELF_K_COFF,
  73.     ELF_K_ELF,
  74.     ELF_K_NUM           /* must be last */
  75. } Elf_Kind;
  76.  
  77. /*
  78.  * Data types
  79.  */
  80. typedef enum {
  81.     ELF_T_BYTE = 0,     /* must be first, 0 */
  82.     ELF_T_ADDR,
  83.     ELF_T_DYN,
  84.     ELF_T_EHDR,
  85.     ELF_T_HALF,
  86.     ELF_T_OFF,
  87.     ELF_T_PHDR,
  88.     ELF_T_RELA,
  89.     ELF_T_REL,
  90.     ELF_T_SHDR,
  91.     ELF_T_SWORD,
  92.     ELF_T_SYM,
  93.     ELF_T_WORD,
  94.     /*
  95.      * New stuff for 64-bit.
  96.      *
  97.      * Most implementations add ELF_T_SXWORD after ELF_T_SWORD
  98.      * which breaks binary compatibility with earlier versions.
  99.      * If this causes problems for you, contact me.
  100.      */
  101.     ELF_T_SXWORD,
  102.     ELF_T_XWORD,
  103.     ELF_T_NUM           /* must be last */
  104. } Elf_Type;
  105.  
  106. /*
  107.  * Elf descriptor
  108.  */
  109. typedef struct Elf      Elf;
  110.  
  111. /*
  112.  * Section descriptor
  113.  */
  114. typedef struct Elf_Scn  Elf_Scn;
  115.  
  116. /*
  117.  * Archive member header
  118.  */
  119. typedef struct {
  120.     char*               ar_name;
  121.     time_t              ar_date;
  122.     long                ar_uid;
  123.     long                ar_gid;
  124.     unsigned long       ar_mode;
  125.     off_t               ar_size;
  126.     char*               ar_rawname;
  127. } Elf_Arhdr;
  128.  
  129. /*
  130.  * Archive symbol table
  131.  */
  132. typedef struct {
  133.     char*               as_name;
  134.     size_t              as_off;
  135.     unsigned long       as_hash;
  136. } Elf_Arsym;
  137.  
  138. /*
  139.  * Data descriptor
  140.  */
  141. typedef struct {
  142.     void*               d_buf;
  143.     Elf_Type            d_type;
  144.     size_t              d_size;
  145.     off_t               d_off;
  146.     size_t              d_align;
  147.     unsigned            d_version;
  148. } Elf_Data;
  149.  
  150. /*
  151.  * Function declarations
  152.  */
  153. extern Elf *elf_begin __P((int __fd, Elf_Cmd __cmd, Elf *__ref));
  154. extern Elf *elf_memory __P((char *__image, size_t __size));
  155. extern int elf_cntl __P((Elf *__elf, Elf_Cmd __cmd));
  156. extern int elf_end __P((Elf *__elf));
  157. extern const char *elf_errmsg __P((int __err));
  158. extern int elf_errno __P((void));
  159. extern void elf_fill __P((int __fill));
  160. extern unsigned elf_flagdata __P((Elf_Data *__data, Elf_Cmd __cmd,
  161.         unsigned __flags));
  162. extern unsigned elf_flagehdr __P((Elf *__elf, Elf_Cmd __cmd,
  163.         unsigned __flags));
  164. extern unsigned elf_flagelf __P((Elf *__elf, Elf_Cmd __cmd,
  165.         unsigned __flags));
  166. extern unsigned elf_flagphdr __P((Elf *__elf, Elf_Cmd __cmd,
  167.         unsigned __flags));
  168. extern unsigned elf_flagscn __P((Elf_Scn *__scn, Elf_Cmd __cmd,
  169.         unsigned __flags));
  170. extern unsigned elf_flagshdr __P((Elf_Scn *__scn, Elf_Cmd __cmd,
  171.         unsigned __flags));
  172. extern size_t elf32_fsize __P((Elf_Type __type, size_t __count,
  173.         unsigned __ver));
  174. extern Elf_Arhdr *elf_getarhdr __P((Elf *__elf));
  175. extern Elf_Arsym *elf_getarsym __P((Elf *__elf, size_t *__ptr));
  176. extern off_t elf_getbase __P((Elf *__elf));
  177. extern Elf_Data *elf_getdata __P((Elf_Scn *__scn, Elf_Data *__data));
  178. extern Elf32_Ehdr *elf32_getehdr __P((Elf *__elf));
  179. extern char *elf_getident __P((Elf *__elf, size_t *__ptr));
  180. extern Elf32_Phdr *elf32_getphdr __P((Elf *__elf));
  181. extern Elf_Scn *elf_getscn __P((Elf *__elf, size_t __index));
  182. extern Elf32_Shdr *elf32_getshdr __P((Elf_Scn *__scn));
  183. extern unsigned long elf_hash __P((const char *__name));
  184. extern Elf_Kind elf_kind __P((Elf *__elf));
  185. extern size_t elf_ndxscn __P((Elf_Scn *__scn));
  186. extern Elf_Data *elf_newdata __P((Elf_Scn *__scn));
  187. extern Elf32_Ehdr *elf32_newehdr __P((Elf *__elf));
  188. extern Elf32_Phdr *elf32_newphdr __P((Elf *__elf, size_t __count));
  189. extern Elf_Scn *elf_newscn __P((Elf *__elf));
  190. extern Elf_Cmd elf_next __P((Elf *__elf));
  191. extern Elf_Scn *elf_nextscn __P((Elf *__elf, Elf_Scn *__scn));
  192. extern size_t elf_rand __P((Elf *__elf, size_t __offset));
  193. extern Elf_Data *elf_rawdata __P((Elf_Scn *__scn, Elf_Data *__data));
  194. extern char *elf_rawfile __P((Elf *__elf, size_t *__ptr));
  195. extern char *elf_strptr __P((Elf *__elf, size_t __section, size_t __offset));
  196. extern off_t elf_update __P((Elf *__elf, Elf_Cmd __cmd));
  197. extern unsigned elf_version __P((unsigned __ver));
  198. extern Elf_Data *elf32_xlatetof __P((Elf_Data *__dst, const Elf_Data *__src,
  199.         unsigned __encode));
  200. extern Elf_Data *elf32_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src,
  201.         unsigned __encode));
  202.  
  203. #if __LIBELF64
  204. /*
  205.  * 64-bit ELF functions
  206.  * Not available on all platforms
  207.  */
  208. extern Elf64_Ehdr *elf64_getehdr __P((Elf *__elf));
  209. extern Elf64_Ehdr *elf64_newehdr __P((Elf *__elf));
  210. extern Elf64_Phdr *elf64_getphdr __P((Elf *__elf));
  211. extern Elf64_Phdr *elf64_newphdr __P((Elf *__elf, size_t __count));
  212. extern Elf64_Shdr *elf64_getshdr __P((Elf_Scn *__scn));
  213. extern size_t elf64_fsize __P((Elf_Type __type, size_t __count,
  214.         unsigned __ver));
  215. extern Elf_Data *elf64_xlatetof __P((Elf_Data *__dst, const Elf_Data *__src,
  216.         unsigned __encode));
  217. extern Elf_Data *elf64_xlatetom __P((Elf_Data *__dst, const Elf_Data *__src,
  218.         unsigned __encode));
  219. #endif /* __LIBELF64 */
  220.  
  221. /*
  222.  * More function declarations
  223.  * These functions are NOT available
  224.  * in the SYSV version of libelf!
  225.  */
  226. extern size_t elf_delscn __P((Elf *__elf, Elf_Scn *__scn));
  227.  
  228. #ifdef __cplusplus
  229. }
  230. #endif /* __cplusplus */
  231.  
  232. #endif /* _LIBELF_H */
  233.