|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| .github/workflows/ | | 12-May-2024 | - | 120 | 79 |
| .vscode/ | | 12-May-2024 | - | 188 | 188 |
| cmake/ | | 12-May-2024 | - | 5 | 4 |
| doc/ | | 12-May-2024 | - | 3,760 | 3,606 |
| elfio/ | | 12-May-2024 | - | 5,426 | 4,126 |
| examples/ | | 12-May-2024 | - | 5,749 | 4,535 |
| tests/ | | 12-May-2024 | - | 10,527 | 8,699 |
| .clang-format | D | 12-May-2024 | 1.3 KiB | 35 | 33 |
| .gitignore | D | 12-May-2024 | 1.8 KiB | 99 | 84 |
| .travis.yml | D | 12-May-2024 | 432 | 39 | 28 |
| AUTHORS | D | 12-May-2024 | 86 | 3 | 2 |
| BUILD.gn | D | 12-May-2024 | 884 | 30 | 24 |
| CMakeLists.txt | D | 12-May-2024 | 3.5 KiB | 113 | 93 |
| COPYING | D | 12-May-2024 | 1.1 KiB | 22 | 17 |
| ChangeLog | D | 12-May-2024 | 0 | | |
| INSTALL | D | 12-May-2024 | 518 | 17 | 12 |
| Makefile.am | D | 12-May-2024 | 925 | 17 | 13 |
| Makefile.in | D | 12-May-2024 | 39.3 KiB | 1,178 | 1,047 |
| NEWS | D | 12-May-2024 | 0 | | |
| OAT.xml | D | 12-May-2024 | 5.4 KiB | 79 | 32 |
| README | D | 12-May-2024 | 478 | 10 | 7 |
| README-OH.md | D | 12-May-2024 | 4.2 KiB | 103 | 75 |
| README.OpenSource | D | 12-May-2024 | 497 | 11 | 11 |
| README.md | D | 12-May-2024 | 978 | 17 | 12 |
| aclocal.m4 | D | 12-May-2024 | 41 KiB | 1,138 | 1,033 |
| autogen.sh | D | 12-May-2024 | 21 | 2 | 1 |
| bundle.json | D | 12-May-2024 | 816 | 31 | 31 |
| compile | D | 12-May-2024 | 7.2 KiB | 349 | 259 |
| configure | D | 12-May-2024 | 151.8 KiB | 5,195 | 4,273 |
| configure.ac | D | 12-May-2024 | 487 | 16 | 15 |
| depcomp | D | 12-May-2024 | 23 KiB | 792 | 502 |
| install-sh | D | 12-May-2024 | 15.3 KiB | 530 | 346 |
| missing | D | 12-May-2024 | 6.7 KiB | 216 | 143 |
| test-driver | D | 12-May-2024 | 4.5 KiB | 149 | 87 |
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 §ion : 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 §ion : 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]