README 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. This is the public release of libelf-0.8.13, a free ELF object
  2. file access library. If you have problems with applications
  3. that use libelf and work with the commercial (SVR4, Solaris)
  4. version but not with this one, please contact me.
  5. IMPORTANT NOTE: If you have libelf-0.5.2 installed, you probably
  6. have a file .../include/elf.h that contains the single line
  7. ``#include <libelf/elf.h>''. REMOVE THIS FILE BEFORE YOU RUN
  8. configure.
  9. Installation is straightforward - the package is autoconf'ed. Just do
  10. ``cd libelf-0.8.13; ./configure; make; make install''. Header files
  11. will be installed in .../include/libelf/. If your system does not
  12. provide its own versions of libelf.h, nlist.h or gelf.h, ``make
  13. install'' will add the missing headers. If you prefer not to have
  14. these files installed in /usr/include, use ``--disable-compat'' and
  15. add ``-I /usr/include/libelf'' to your CFLAGS when compiling
  16. libelf-based programs.
  17. Note to distribution makers: You can install libelf in a separate root
  18. hierarchy by using the command ``make instroot=/my/root install''.
  19. You should also use the ``--enable-compat'' configure option in that
  20. case, or run ``make instroot=/my/root install-compat'' manually, to
  21. install all the required header files.
  22. If you are running Linux with libc 5.* as the default C library,
  23. and you plan to use the 64-bit functions, you must either use
  24. ``-I.../include/libelf'', or remove /usr/include/libelf.h and use
  25. ``--enable-compat'' when running configure. Libc 6.* (aka glibc2)
  26. doesn't have its own <libelf.h>, <nlist.h> or <gelf.h>.
  27. You need an ANSI/ISO C compiler to build libelf. Gcc is optimal.
  28. On some systems (in particular, Solaris and all variants of Linux),
  29. ``make'' will try to build a shared library. If you run into problems
  30. on your system, please pass ``--disable-shared'' to configure.
  31. If you build a shared library and want it to be installed as
  32. ``libelf-0.8.13.so'' rather than ``libelf.so.0.8.13'', please use
  33. ``./configure --enable-gnu-names''. Other files, e.g. ``libelf.so'' and
  34. ``libelf.so.0'' are NOT affected.
  35. Another configure option, ``--enable-debug'', adds debugging code to
  36. libelf; if you don't run into problems, you will probably not need it.
  37. When creating an ELF shared library, it is possible to add references
  38. to other shared libraries in the DYNAMIC section of the resulting
  39. file. The make variable DEPSHLIBS contains a list of libraries to add.
  40. It is set to ``-lc'' on Linux systems, and empty otherwise. To
  41. override this setting, use something like ``make DEPSHLIBS="-la -lb"''.
  42. For Linux, `-lc' is included automagically.
  43. NLS is available and enabled by default. To turn it off, pass the
  44. ``--disable-nls'' option to configure.
  45. Libelf can use gettext or catgets for accessing message
  46. catalogs. If gettext is available AND is part of libc (i.e. not
  47. in a separate library), it will be used. Otherwise, configure
  48. will look for catgets. If you have gettext in a separate
  49. library and want to use it, you should pass the library's name
  50. to configure, e.g. ``LIBS=-lintl ./configure''. Note that you
  51. MUST link your libelf-based applications with -lintl then,
  52. which is probably not what you want, or change the DEPSHLIBS variable
  53. described above (in case you're building a shared library).
  54. If you have GNU gettext 0.10 installed on your system, and if GNU gettext
  55. runs on top of the catgets interface (rather old Linux systems, using
  56. libc5), configure will refuse to use it and use catgets instead. If you
  57. absolutely want to use GNU gettext, go ahead and rebuild it (which is
  58. IMHO a good idea in general in this case):
  59. cd .../gettext-0.10
  60. ac_cv_func_catgets=no ac_cv_func_gettext=no ./configure
  61. make
  62. make install
  63. After that, return to the libelf build directory, remove
  64. config.cache, and start over.
  65. *** Large File Support (LFS) applications ***
  66. Some 32-bit systems support files that are larger than the address space
  67. of the architecture. On these, the `off_t' data type may have 32 or
  68. 64 bits, depending on the API you choose. Since off_t is also part of
  69. the libelf API, in particular the Elf_Data and Elf_Arhdr structures,
  70. an application compiled with large file support will need a version of
  71. libelf that has also been compiled with LFS; otherwise, it won't work
  72. correctly. Similarly, a program compiled without LFS needs a library
  73. compiled without LFS.
  74. Note that libelf is currently unable to process large files on 32-bit
  75. architectures, whether you compile it for LFS or not, for the simple
  76. reason that the files won't fit into the processes' address space.
  77. Therefore, libelf is compiled without LFS by default. It can of course
  78. read and write ELF files for 64-bit architectures, but they will be
  79. limited in length on a 32-bit system.
  80. You may compile libelf with large file support by setting CPPFLAGS at
  81. configuration time:
  82. CPPFLAGS=`getconf LFS_CFLAGS` ./configure
  83. But I really, really recommend you don't, because it breaks binary
  84. compatibility with existing libelf based applications.
  85. *** 64-bit support ***
  86. Starting with libelf-0.7.0, libelf also supports 64-bit ELF files.
  87. This is enabled by default unless your system (or your compiler) does
  88. not support 64-bit integers, or lacks 64-bit declarations in <elf.h>.
  89. If you have problems building with 64-bit support, please do
  90. ./configure --disable-elf64
  91. for the moment, and contact me. Please note that I haven't tested 64-bit
  92. support much. There are still some unresolved problems, e.g. IRIX
  93. uses different Elf64_Rel and Elf64_Rela structures (they replaced the
  94. r_info member), and the enumeration values for Elf_Type differ from
  95. the commercial (SVR4) implementation of libelf - they broke binary
  96. compatibility for no good reason, and I'm not willing to follow their
  97. footsteps. The result is that libelf-0.7.* ist upward compatible with
  98. libelf-0.6.4 (as it should be) but INCOMPATIBLE WITH SVR4 LIBELF. If you
  99. have both versions installed, you'd better make sure that you link with
  100. the library that matches the <libelf.h> you're #include'ing.
  101. *** Symbol Versioning ***
  102. Libelf >= 0.8.0 supports the data structures and definitions used for
  103. symbol versioning on Solaris and Linux, in particular, the Elfxx_Verdef,
  104. Elfxx_Verdaux, Elfxx_Verneed, Elfxx_Vernaux and Elfxx_Versym structures
  105. and the SHT_XXX_verdef, SHT_XXX_verneed and SHT_XXX_versym section types
  106. (where `xx' is either `32' or `64', and `XXX' is either `SUNW' or `GNU').
  107. Libelf now translates versioning sections to/from their external
  108. representation properly (earlier versions left them in `raw' format,
  109. with the data type set to ELF_T_BYTE). This may cause problems on
  110. systems which use the same (OS-specific) section types for different
  111. purposes. The configure program tries to figure out if your OS uses
  112. versioning; if that check fails, you can use
  113. ./configure --disable-versioning
  114. to turn off versioning translation support.
  115. *** W32 Support ***
  116. There is now some support for building on W32 systems (requires Microsoft
  117. VC++). In order to build a W32 DLL, cd into the `lib' subdirectory, edit
  118. build.bat if necessary (it needs the path to your compiler binaries) and
  119. run it. If you're lucky, libelf.dll and the import/export libraries will
  120. be built. If not, please drop me a line.
  121. I tested it on XP Pro (SP2), using VC++ 2005 Express Edition.
  122. Apparently, Visual Studio .NET 2003 works fine as well.
  123. Various notes regarding the W32 port:
  124. - When you open() an ELF file, remember to use the O_BINARY flag.
  125. - You may have to add /MD to the linker command line.
  126. *** Missing things ***
  127. * There is no documentation. You can use the Solaris
  128. manpages instead (available at http://docs.sun.com/).
  129. The ELF file format is described in several places;
  130. among them Suns "Linker and Libraries Guide" and the
  131. "System V Application Binary Interface" documents;
  132. http://www.caldera.com/developer/devspecs/gabi41.pdf and
  133. http://www.caldera.com/developer/gabi/ are probably good
  134. starting points. Processor-specific documentation is spread
  135. across a number of `Processor Supplement' documents, one
  136. for each architecture; you'll have to use a search engine to
  137. find them.
  138. * The COFF file format is not understood. This is so obsolete
  139. that it will probably never be implemented.
  140. * nlist(3) is incomplete; the n_type and n_sclass
  141. members of struct nl are set to zero even if type
  142. (that is, debug) information is available.
  143. * Libelf does not translate Solaris' `Move' and `Syminfo'
  144. sections. You can read them using elf_getdata(), but you'll
  145. only get raw (untranslated) bytes.
  146. Changes since 0.8.12:
  147. * New function elf_getaroff().
  148. * Build fixes.
  149. Changes since 0.8.11:
  150. * Due to some unfortunate confusion, the elf_getphnum(),
  151. elf_getshnum() and elf_getshstrndx() are not compatible
  152. between libelf implementations. Therefore, the developers
  153. decided to replace them with new functions: elf_getphdrnum(),
  154. elf_getshdrnum() and elf_getshdrstrndx(), which will always
  155. return -1 on failure and 0 on success. Code using the old
  156. interface should be upgraded to increase portability.
  157. Changes since 0.8.10:
  158. * Fixed a bug in elf_rawfile().
  159. * If you use ELF_F_LAYOUT together with ELF_F_LAYOUT_OVERLAP,
  160. elf_update() will now tolerate overlapping sections.
  161. Changes since 0.8.9:
  162. * Ported to QNX Neutrino.
  163. * Fixed Windows build errors.
  164. * Parallel (make -j) installation should work now.
  165. * It's now possible to enable and disable select sanity checks
  166. libelf performs. Currently, this affects the "NUL terminated
  167. string table entry" check performed in elf_strptr(). By
  168. default, the function will return an error if the string
  169. requested is not properly terminated - because some
  170. applications might dump core otherwise. If you configure
  171. libelf with `--disable-sanity-checks', however, the check
  172. (and, in the future, probably others as well) is disabled
  173. by default. You can still turn it on and off at runtime by
  174. setting the LIBELF_SANITY_CHECKS environment variable to
  175. an integer value:
  176. # disable all sanity checks
  177. export LIBELF_SANITY_CHECKS=0
  178. # enable all sanity checks
  179. export LIBELF_SANITY_CHECKS=-1
  180. Each bit of the value corresponds to a particular check,
  181. so you could use LIBELF_SANITY_CHECKS=1 to enable only
  182. the elf_strptr() check. You may also use a value in hex
  183. (0x...) or octal (0...) format.
  184. Changes since 0.8.8:
  185. * Improved translator for symbol versioning sections.
  186. * The W32 library is now built in the `lib' subdirectory.
  187. * Windows DLLs should work now.
  188. Changes since 0.8.6:
  189. * added elf_getphnum().
  190. * added elf_getshnum().
  191. * added elf_getshstrndx().
  192. * added elfx_update_shstrndx().
  193. * handle interrupted reads/writes more gracefully.
  194. * added (partial) support for unusual e_[ps]hentsize values.
  195. * fixed the bugs introduced in 0.8.7.
  196. Changes since 0.8.5:
  197. * added W32 support.
  198. * added workaround for alignment errors in archive members.
  199. * my email address has changed again ;)
  200. Changes since 0.8.4:
  201. * elf_strptr() should now work more safely with fragmented
  202. or badly formatted string tables.
  203. Changes since 0.8.3:
  204. * Fixed a bug in elf_update() that was introduced in 0.8.3.
  205. Changes since 0.8.2:
  206. * Should compile on MacOSX now.
  207. * Can read and write files with more than 65280 sections
  208. * Tries to handle 64-bit ELF files that use 8-byte hash table
  209. entries. In particular, libelf tries to guess the data type in
  210. elf_getdata(), and doesn't override sh_entsize in elf_update()
  211. any longer. If you want the library to pick the entry size,
  212. you must set its value to 0 before you call elf_update().
  213. * No longer dumps core in elf_update() when a versioning section
  214. has no data. Instead, it returns an error message. Note that
  215. you're supposed to provide a valid d_buf for any section, unless
  216. it's empty or has SHT_NOBITS type.
  217. * Building a shared library is now the default (if supported).
  218. Changes since 0.8.0:
  219. * Corrected typo in lib/{32,64}.xlatetof.c that sometimes
  220. caused a compilation failure.
  221. * Use open(name, O_RDONLY|O_BINARY) in lib/nlist.c.
  222. Changes since 0.7.0:
  223. * I implemented the gelf_* interface, as found on Solaris.
  224. I don't know whether it's compatible -- the Solaris manpage
  225. isn't very specific, so I had to guess return values etc. in
  226. some cases.
  227. * Added elf{32,64}_checksum (supposed to be compatible with
  228. Solaris).
  229. * Added symbol versioning support.
  230. Changes since 0.6.4:
  231. * Fixed configure for IRIX systems
  232. * Added check for truncated archive members
  233. * Added check for misaligned SHDR/PHDR tables
  234. * Support for building libelf together with GNU libc
  235. * Added elf_memory(3)
  236. * Added 64-bit support
  237. Changes since 0.5.2:
  238. * some bug fixes
  239. * mmap support
  240. * new directory layout
  241. * There is a new function, elf_delscn(), that deletes
  242. a section from an ELF file. It also adjusts the
  243. sh_link and sh_info members in the section header
  244. table, if (and ONLY if) the ELF standard indicates
  245. that these values are section indices. References
  246. to the deleted section will be cleared, so be careful.
  247. * my email address has changed ;)
  248. Where to get libelf:
  249. ftp://ftp.ibiblio.org/pub/Linux/libs/
  250. http://www.mr511.de/software/
  251. Michael "Tired" Riepe
  252. <libelf@mr511.de>