• Home
Name Date Size #Lines LOC

..--

.github/workflows/12-May-2024-12079

.vscode/12-May-2024-188188

cmake/12-May-2024-54

doc/12-May-2024-3,7603,606

elfio/12-May-2024-5,4264,126

examples/12-May-2024-5,7494,535

tests/12-May-2024-10,5278,699

.clang-formatD12-May-20241.3 KiB3533

.gitignoreD12-May-20241.8 KiB9984

.travis.ymlD12-May-2024432 3928

AUTHORSD12-May-202486 32

BUILD.gnD12-May-2024884 3024

CMakeLists.txtD12-May-20243.5 KiB11393

COPYINGD12-May-20241.1 KiB2217

ChangeLogD12-May-20240

INSTALLD12-May-2024518 1712

Makefile.amD12-May-2024925 1713

Makefile.inD12-May-202439.3 KiB1,1781,047

NEWSD12-May-20240

OAT.xmlD12-May-20245.4 KiB7932

READMED12-May-2024478 107

README-OH.mdD12-May-20244.2 KiB10375

README.OpenSourceD12-May-2024497 1111

README.mdD12-May-2024978 1712

aclocal.m4D12-May-202441 KiB1,1381,033

autogen.shD12-May-202421 21

bundle.jsonD12-May-2024816 3131

compileD12-May-20247.2 KiB349259

configureD12-May-2024151.8 KiB5,1954,273

configure.acD12-May-2024487 1615

depcompD12-May-202423 KiB792502

install-shD12-May-202415.3 KiB530346

missingD12-May-20246.7 KiB216143

test-driverD12-May-20244.5 KiB14987

README

1ELFIO is a header-only C++ library intended for reading and generating
2files in the ELF binary format. It is used as a standalone library - it is not
3dependent on any other product or project. Adhering to ISO C++, it compiles on
4a wide variety of architectures and compilers.
5
6While written in C++, the library provides a C-language interface wrapper.
7
8The full library documentation can be found in "ELFIO - Tutorial and User
9Manual" at http://elfio.sourceforge.net/elfio.pdf.
10

README-OH.md

1# ELFIO
2
3[![Build](https://travis-ci.com/serge1/ELFIO.svg?branch=master)](https://travis-ci.com/serge1/ELFIO)
4![C/C++ CI](https://github.com/serge1/ELFIO/workflows/C/C++%20CI/badge.svg)
5![CodeQL](https://github.com/serge1/ELFIO/workflows/CodeQL/badge.svg)
6[![Documentation](https://img.shields.io/badge/doc-download-brightgreen)](http://elfio.sourceforge.net/elfio.pdf)
7[![License](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/serge1/ELFIO/blob/master/COPYING)
8
9ELFIO是一个只有头文件的C++库,用于读取和生成ELF二进制格式文件。它被用作一个独立的库,它不依赖于任何其他产品或项目。
10它遵循ISO C++,可以在各种架构和编译器上编译。
11
12虽然是用C++编写的,但是该库也提供了一个C语言接口封装器。
13
14完整的库文档可以在【ELFIO-教程和用户手册】(http://elfio.sourceforge.net/elfio.pdf)中找到。
15
16
17# 目录结构
18.
19├── elfio_array.hpp                      # array section访问类,提供对array section的处理
20├── elfio_demo.cpp                       # 空源文件,目的是为了编译出动态库
21├── elfio_dump.hpp                       # elf dump类,dump出elf文件的各类信息,例如:elf header、section headers、segment headers等
22├── elfio_dynamic.hpp                    # dynamic section访问类,提供对dynamic section的处理
23├── elfio_header.hpp                     # elf header类,解析elf header的section
24├── elfio.hpp                            # elfio库的主要类,可以创建、加载、保存elf文件
25├── elfio_modinfo.hpp                    # modinfo section访问类,提供对modinfo section的处理
26├── elfio_note.hpp                       # note section访问类,提供对note section的处理
27├── elfio_relocation.hpp                 # relocation section访问类,提供对relocation section的处理
28├── elfio_section.hpp                    # section类
29├── elfio_segment.hpp                    # segment类
30├── elfio_strings.hpp                    # string section访问类,提供对string section的处理
31├── elfio_symbols.hpp                    # symbol section访问类,提供对symbol section的处理
32├── elfio_utils.hpp                      # elf工具类
33├── elfio_version.hpp                    # 定义elfio库版本号
34└── elf_types.hpp                        # elf类型类,定义了elf文件类型、文件版本等
35
36
37# 使用说明
38
39(一)加载elf文件
40
411.  调用elfio类的load\(\)接口加载elf文件。
42
43    ELFIO::elfio elfIo;
44    elfIo.load(fileName);
45
46
47(二)获取section名称
48
491.  遍历elf文件的sections。
502.  调用section_impl的get_name\(\)接口获取section名称。
51
52    ELFIO::elfio elfIo;
53    for (const auto &section : elfIo.sections) {
54        if (section->get_name() == "xxx")
55    }
56
57
58(三)获取section数据
59
601.  遍历elf文件的sections。
612.  调用section_impl的get_data\(\)接口获取section数据。
62
63    ELFIO::elfio elfIo;
64    for (const auto &section : elfIo_.sections) {
65        if (section->get_name() == "xxx") {
66            section->get_data();
67        }
68    }
69
70
71(四)获取symbol section
72
731.  遍历elf文件的symbol sections。
742.  调用symbol_section_accessor的get_symbol\(\)接口获取symbol section。
75
76    const symbol_section_accessor symbols(reader, psec);
77    for (unsigned int i = 0; i < symbols.get_symbols_num(); ++i) {
78        std::string name;
79        Elf64_Addr value;
80        Elf_Xword size;
81        unsigned char bind;
82        unsigned char type;
83        Elf_Half section_index;
84        unsigned char other;
85        symbols.get_symbol(i, name, value, size, bind, type, section_index, other);
86    }
87
88
89(五)获取relocation section
90
911.  调用relocation_section_accessor的get_entry\(\)接口获取relocation section。
92
93    Elf64_Addr offset;
94    Elf64_Addr symbolValue;
95    string symbolName;
96    Elf_Word type;
97    Elf_Sxword addend;
98    Elf_Sxword calcValue;
99    relocation_section_accessor reloc(elfIo_, sec);
100    for (uint32_t i = 0; i < sec->get_size() / sec->get_entry_size(); i++) {
101        reloc.get_entry(i, offset, symbolValue, symbolName, type, addend, calcValue);
102    }
103

README.OpenSource

1[
2    {
3        "Name"                  : "elfio",
4        "License"               : "The MIT License",
5        "License File"          : "COPYING",
6        "Version Number"        : "Release_3.9",
7        "Owner"                 : "lichunlin2@huawei.com",
8        "Upstream URL"          : "http://elfio.sourceforge.net/",
9        "Description"           : "ELFIO is a small, header-only C++ library that provides a simple interface for reading and generating files in ELF binary format."
10    }
11]

README.md

1# ELFIO
2
3[![Build](https://travis-ci.com/serge1/ELFIO.svg?branch=master)](https://travis-ci.com/serge1/ELFIO)
4![C/C++ CI](https://github.com/serge1/ELFIO/workflows/C/C++%20CI/badge.svg)
5![CodeQL](https://github.com/serge1/ELFIO/workflows/CodeQL/badge.svg)
6[![Documentation](https://img.shields.io/badge/doc-download-brightgreen)](http://elfio.sourceforge.net/elfio.pdf)
7[![License](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/serge1/ELFIO/blob/master/COPYING)
8
9ELFIO is a header-only C++ library intended for reading and generating
10files in the ELF binary format. It is used as a standalone library - it is not
11dependent on any other product or project. Adhering to ISO C++, it compiles on
12a wide variety of architectures and compilers.
13
14While written in C++, the library also provides a C-language interface wrapper.
15
16The full library documentation can be found in *[ELFIO - Tutorial and User Manual](http://elfio.sourceforge.net/elfio.pdf)*.
17