ElfToolChain - How to build the libelf library w/o the rest of the package?

筅森魡賤 提交于 2019-12-12 02:52:57

问题


I need to parse the loadable parts of an ELF executable for a simple loader. Found the nice "libelf by Example" tutorial (by J. Koshy) that gives a nice overview on the structure of an ELF. It then lead me to the ELF Toolchain project, which implements, among other things, the libelf library of ELF handling functions.

The nice thing about using this library is that it encapsulates the variations in ELF formats and makes the code more portable and future proof. However, I found out that in order to be able to build the package on Ubuntu, I needed to install a great amount of prerequisites.

I tried to build only the libelf part by running pmake in the libelf directory, but got a build error complaining on missing header file - which is apparently automatically generated by the global make process and is architecture dependent.

My question is - how can I build just the libelf part of ELF Toolchain?


回答1:


You can build select parts of the Elftoolchain source tree by commenting out the appropriate SUBDIR lines in the top-level Makefile.

For building libelf, you should be able to get by with the following two directories:

% grep ^SUBDIR Makefile | head -2
SUBDIR += common
SUBDIR += libelf

Note: On Ubuntu, you could also use GNU libelf, which offers a different implementation of the same API, and for which there appears to be ready-made packages.



来源:https://stackoverflow.com/questions/19065062/elftoolchain-how-to-build-the-libelf-library-w-o-the-rest-of-the-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!