From ef8e7426945ed175dc6ef705bb34c60e7e05251d Mon Sep 17 00:00:00 2001 From: iris Date: Mon, 11 May 2026 11:54:46 +0200 Subject: [PATCH] read ELF --- .clang-format | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ .clangd | 4 ++++ CMakeLists.txt | 9 +++++++++ main.cpp | 13 ++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 .clang-format create mode 100644 .clangd create mode 100644 CMakeLists.txt diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..9f0277e --- /dev/null +++ b/.clang-format @@ -0,0 +1,54 @@ +--- +Language: Cpp +BasedOnStyle: LLVM +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignOperands: false +AlignTrailingComments: false +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: true + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: true + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakConstructorInitializers: AfterColon +BreakConstructorInitializersBeforeComma: false +ColumnLimit: 120 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ContinuationIndentWidth: 4 +IncludeCategories: + - Regex: '^<.*' + Priority: 1 + - Regex: '^".*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseBlocks: true +InsertNewlineAtEOF: true +MacroBlockBegin: '' +MacroBlockEnd: '' +SortIncludes: Never +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: Inner +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +TabWidth: 4 +IndentWidth: 4 +... diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..ab1a655 --- /dev/null +++ b/.clangd @@ -0,0 +1,4 @@ +CompileFlags: + CompilationDatabase: build/ +Completion: + HeaderInsertion: Never diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..90ca5a6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.23) +project(weee CXX) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +include_directories(external/ELFIO) + +add_executable(weee main.cpp) \ No newline at end of file diff --git a/main.cpp b/main.cpp index e69de29..1f95a5a 100644 --- a/main.cpp +++ b/main.cpp @@ -0,0 +1,13 @@ +#include +#include + +int main() { + ELFIO::elfio reader; + if(!reader.load("tests/elf/application.elf")) + return 1; + + for(ELFIO::Elf_Half i = 1; i < reader.sections.size(); i++) { + const auto& section = reader.sections[i]; + std::println(R"(Section n.{} "{}": 0x{:08X} -> 0x{:08X})", i, section->get_name(), section->get_address(), section->get_address() + section->get_size() - 1); + } +} \ No newline at end of file