ElfToolChain-如何在没有包其余部分的情况下构建libelf库? [英] ElfToolChain - How to build the libelf library w/o the rest of the package?

查看:125
本文介绍了ElfToolChain-如何在没有包其余部分的情况下构建libelf库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为一个简单的加载器解析ELF可执行文件的可加载部分.找到了不错的"libelf by Example"教程(由J. Koshy撰写),该教程对ELF的结构进行了很好的概述.然后,它引导我进入 ELF工具链项目,该项目除其他外实现了libelf库ELF处理功能.

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.

使用此库的好处是,它封装了ELF格式的变体,并使代码更具可移植性,并可以将来使用.但是,我发现,为了能够在Ubuntu上构建该软件包,我需要安装大量先决条件.

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.

我试图通过在libelf目录中运行pmake来仅构建libelf部分,但由于抱怨缺少头文件而出现了构建错误-显然是全局make进程自动生成的并且依赖于体系结构.

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.

我的问题是-我怎样才能仅构建ELF工具链的libelf部分?

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

推荐答案

您可以通过注释掉顶级Makefile中相应的SUBDIR行,来构建Elftoolchain源代码树的选定部分.

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

对于构建libelf,您应该能够使用以下两个目录:

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

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

注意:在Ubuntu上,您还可以使用 GNU libelf ,它提供了相同API的不同实现,并且似乎有现成的软件包.

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.

这篇关于ElfToolChain-如何在没有包其余部分的情况下构建libelf库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆