Utility to determine if ELF binary is built with debug sections

栏目: IT技术 · 发布时间: 4年前

内容简介:This projectDebug sections in ELF binary usually are generated using theThe program is looking for the existence of sections with name starting with

elfdbg

About

This project elfdbg is a utility program to quickly identify if an ELF binary is built with debug sections

Debug sections in ELF binary usually are generated using the -g flag with the compiler. The compiler adds the new .debug_* sections in the binary.

The program is looking for the existence of sections with name starting with .debug_ to determine if the binary has been built with debug information.

The ELF format is a well-known standard. ELF TIS reference specification is available here and as a FreeBSD elf(5) man page.

Usage

This is intented to be used in shell script in order to avoid using file(1) and parsing the output like below:

`file /path/to/binary | awk '/debug_info/{print $2}'` != 'ELF'

To determine if binary has been built with debug, use the following:

if elfdbg -q /path/to/binary; then
        echo "No symbols"
    else
        echo "Binary with debug symbols"
fi

On FreeBSD, you can easily identify the binary packages with missing debug using similar one-liner:

pkg info -a -l|grep local/bin/|while read a; do echo $a: `elfdbg $a`; done

Build and install

The Makefile use the standard BSD Makefile to build the program.

make && sudo make install

If your on Linux, use make -f GNUMakefile to specify the GNU Makefile.

Test

The tests cases are implemented using the FreeBSD test suite framework with kyua and Kyuafile .

make test

History

  • 2015 I wrote this using libelf elf(3) and gelf(3) API f4b470b
  • 2020 I rewrote this without relying on libelf API 1960d10

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

改变未来的九大算法

改变未来的九大算法

[美] 约翰.麦考密克 / 管策 / 中信出版社 / 2013-6 / 39.00元

Google得出的搜索结果是如何产生的? 百度为何会陷入“搜索门”,又是什么机制使然? 身处在大数据时代的我们,究竟该如何应对变化莫测的世界? …… 没有满篇的专业术语,第一次让我们通过简单明了的语言、生动的例证了解支撑计算机王国的灵魂支柱——9大算法,包括人工智能、数据压缩,以及Google著名的PageRank等。 本书精彩地介绍了搜索引擎、PageRank、公开......一起来看看 《改变未来的九大算法》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

随机密码生成器
随机密码生成器

多种字符组合密码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器