Coder Social home page Coder Social logo

readelf's Introduction

readelf

A simple implement of readelf with -h, -S, -l options.

usage:

# -h, -S, -l选项三选一,与系统库中readelf选项一致,分别对应解析elf header,解析section headers table, 解析program headers table。
bin/readelf <-h|-S|-l> elffile

hierarchy:

readelf
├── bin
│   └── readelf
├── CMakeLists.txt
├── include
│   └── func.h
├── lib
│   └── libfunc.so
├── LICENSE
├── README.md
└── src
    ├── func.c
    └── main.c

main.c

elf文件中提取信息填充Elf64_Ehdr, Elf64_Shdr, Elf64_Phdr结构体。

func.c

解析main.c中填充的三类结构体(基本全是printf)。

额外说明

  1. 只做了64位的(32位与64位解析方法基本相同)。
  2. 因为用到了Elf64_Ehdr, Elf64_Shdr, Elf64_Phdr这些结构体以及相关的类型定义,所以需要依赖elf.h头文件。
  3. 输出格式与系统中的readelf基本相同。Elf64_Ehdr中没有与elf header解析结果中的OS/ABIABI Version与之对应的字段,故在解析结果中将这两条留空;section headerprogram header中的typeflags以十进制整数的形式输出,没有实现对应的to_string;三种数据结构中没有与program headers table解析结果中的sectionsegment的映射对应的字段,故这部分也留空。
  4. 因为编译采用了动态链接的方式,所以bin/readelf可能不能在其他电脑上直接运行,需要用cmake重新编译。

readelf's People

Contributors

gpf233 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.