gelf.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * gelf.h - public header file for libelf.
  3. * Copyright (C) 2000 - 2006 Michael Riepe
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  18. */
  19. /* @(#) $Id: gelf.h,v 1.16 2008/05/23 08:15:34 michael Exp $ */
  20. #ifndef _GELF_H
  21. #define _GELF_H
  22. #if __LIBELF_INTERNAL__
  23. #include <libelf.h>
  24. #else /* __LIBELF_INTERNAL__ */
  25. #include <libelf/libelf.h>
  26. #endif /* __LIBELF_INTERNAL__ */
  27. #if __LIBELF_NEED_LINK_H
  28. #include <link.h>
  29. #elif __LIBELF_NEED_SYS_LINK_H
  30. #include <sys/link.h>
  31. #endif /* __LIBELF_NEED_LINK_H */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif /* __cplusplus */
  35. #ifndef __P
  36. # if (__STDC__ + 0) || defined(__cplusplus) || defined(_WIN32)
  37. # define __P(args) args
  38. # else /* __STDC__ || defined(__cplusplus) */
  39. # define __P(args) ()
  40. # endif /* __STDC__ || defined(__cplusplus) */
  41. #endif /* __P */
  42. #if !__LIBELF64
  43. #error "GElf is not supported on this system."
  44. #else /* __LIBELF64 */
  45. typedef Elf64_Addr GElf_Addr;
  46. typedef Elf64_Half GElf_Half;
  47. typedef Elf64_Off GElf_Off;
  48. typedef Elf64_Sword GElf_Sword;
  49. typedef Elf64_Word GElf_Word;
  50. typedef Elf64_Sxword GElf_Sxword;
  51. typedef Elf64_Xword GElf_Xword;
  52. typedef Elf64_Ehdr GElf_Ehdr;
  53. typedef Elf64_Phdr GElf_Phdr;
  54. typedef Elf64_Shdr GElf_Shdr;
  55. typedef Elf64_Dyn GElf_Dyn;
  56. typedef Elf64_Rel GElf_Rel;
  57. typedef Elf64_Rela GElf_Rela;
  58. typedef Elf64_Sym GElf_Sym;
  59. /*
  60. * Symbol versioning
  61. */
  62. #if __LIBELF_SYMBOL_VERSIONS
  63. typedef Elf64_Verdef GElf_Verdef;
  64. typedef Elf64_Verneed GElf_Verneed;
  65. typedef Elf64_Verdaux GElf_Verdaux;
  66. typedef Elf64_Vernaux GElf_Vernaux;
  67. #endif /* __LIBELF_SYMBOL_VERSIONS */
  68. /*
  69. * These types aren't implemented (yet)
  70. *
  71. typedef Elf64_Move GElf_Move;
  72. typedef Elf64_Syminfo GElf_Syminfo;
  73. */
  74. /*
  75. * Generic macros
  76. */
  77. #define GELF_ST_BIND ELF64_ST_BIND
  78. #define GELF_ST_TYPE ELF64_ST_TYPE
  79. #define GELF_ST_INFO ELF64_ST_INFO
  80. #define GELF_R_TYPE ELF64_R_TYPE
  81. #define GELF_R_SYM ELF64_R_SYM
  82. #define GELF_R_INFO ELF64_R_INFO
  83. /*
  84. * Function declarations
  85. */
  86. extern int gelf_getclass __P((Elf *__elf));
  87. extern size_t gelf_fsize __P((Elf *__elf, Elf_Type __type, size_t __count, unsigned __ver));
  88. extern Elf_Data *gelf_xlatetof __P((Elf *__elf, Elf_Data *__dst, const Elf_Data *__src, unsigned __encode));
  89. extern Elf_Data *gelf_xlatetom __P((Elf *__elf, Elf_Data *__dst, const Elf_Data *__src, unsigned __encode));
  90. extern GElf_Ehdr *gelf_getehdr __P((Elf *__elf, GElf_Ehdr *__dst));
  91. extern int gelf_update_ehdr __P((Elf *__elf, GElf_Ehdr *__src));
  92. extern unsigned long gelf_newehdr __P((Elf *__elf, int __elfclass));
  93. extern GElf_Phdr *gelf_getphdr __P((Elf *__elf, int ndx, GElf_Phdr *__dst));
  94. extern int gelf_update_phdr __P((Elf *__elf, int ndx, GElf_Phdr *__src));
  95. extern unsigned long gelf_newphdr __P((Elf *__elf, size_t __phnum));
  96. extern GElf_Shdr *gelf_getshdr __P((Elf_Scn *__scn, GElf_Shdr *__dst));
  97. extern int gelf_update_shdr __P((Elf_Scn *__scn, GElf_Shdr *__src));
  98. extern GElf_Dyn *gelf_getdyn __P((Elf_Data *__src, int __ndx, GElf_Dyn *__dst));
  99. extern int gelf_update_dyn __P((Elf_Data *__dst, int __ndx, GElf_Dyn *__src));
  100. extern GElf_Rel *gelf_getrel __P((Elf_Data *__src, int __ndx, GElf_Rel *__dst));
  101. extern int gelf_update_rel __P((Elf_Data *__dst, int __ndx, GElf_Rel *__src));
  102. extern GElf_Rela *gelf_getrela __P((Elf_Data *__src, int __ndx, GElf_Rela *__dst));
  103. extern int gelf_update_rela __P((Elf_Data *__dst, int __ndx, GElf_Rela *__src));
  104. extern GElf_Sym *gelf_getsym __P((Elf_Data *__src, int __ndx, GElf_Sym *__dst));
  105. extern int gelf_update_sym __P((Elf_Data *__dst, int __ndx, GElf_Sym *__src));
  106. extern long gelf_checksum __P((Elf *__elf));
  107. /*
  108. * These functions aren't implemented (yet)
  109. *
  110. extern GElf_Move *gelf_getmove __P((Elf_Data *__src, int __ndx, GElf_Move *__src));
  111. extern int gelf_update_move __P((Elf_Data *__dst, int __ndx, GElf_Move *__src));
  112. *
  113. extern GElf_Syminfo* gelf_getsyminfo __P((Elf_Data *__src, int __ndx, GElf_Syminfo *__dst));
  114. extern int gelf_update_syminfo __P((Elf_Data *__dst, int __ndx, GElf_Syminfo *__src));
  115. */
  116. /*
  117. * Extensions (not available in other versions of libelf)
  118. */
  119. extern size_t gelf_msize __P((Elf *__elf, Elf_Type __type, size_t __count, unsigned __ver));
  120. #endif /* __LIBELF64 */
  121. #ifdef __cplusplus
  122. }
  123. #endif /* __cplusplus */
  124. #endif /* _GELF_H */