ELF: Run clang-format on everything.

This commit is contained in:
Andreas Kling 2019-06-07 17:12:30 +02:00
parent e42c3b4fd7
commit 9145917bf0
Notes: sideshowbarker 2024-07-19 13:41:06 +09:00
5 changed files with 551 additions and 547 deletions

View file

@ -14,12 +14,18 @@ ELFImage::~ELFImage()
static const char* object_file_type_to_string(Elf32_Half type)
{
switch (type) {
case ET_NONE: return "None";
case ET_REL: return "Relocatable";
case ET_EXEC: return "Executable";
case ET_DYN: return "Shared object";
case ET_CORE: return "Core";
default: return "(?)";
case ET_NONE:
return "None";
case ET_REL:
return "Relocatable";
case ET_EXEC:
return "Executable";
case ET_DYN:
return "Shared object";
case ET_CORE:
return "Core";
default:
return "(?)";
}
}

View file

@ -1,9 +1,9 @@
#pragma once
#include <AK/OwnPtr.h>
#include <AK/HashMap.h>
#include <AK/AKString.h>
#include <AK/ELF/exec_elf.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>
class ELFImage {
public:
@ -65,6 +65,7 @@ public:
bool is_writable() const { return flags() & PF_W; }
bool is_executable() const { return flags() & PF_X; }
const char* raw_data() const { return m_image.raw_data(m_program_header.p_offset); }
private:
const ELFImage& m_image;
const Elf32_Phdr& m_program_header;
@ -109,10 +110,14 @@ public:
const Section section(unsigned) const;
const ProgramHeader program_header(unsigned const) const;
template<typename F> void for_each_section(F) const;
template<typename F> void for_each_section_of_type(unsigned, F) const;
template<typename F> void for_each_symbol(F) const;
template<typename F> void for_each_program_header(F) const;
template<typename F>
void for_each_section(F) const;
template<typename F>
void for_each_section_of_type(unsigned, F) const;
template<typename F>
void for_each_symbol(F) const;
template<typename F>
void for_each_program_header(F) const;
bool is_executable() const { return header().e_type == ET_EXEC; }
bool is_relocatable() const { return header().e_type == ET_REL; }
@ -158,7 +163,7 @@ template<typename F>
inline void ELFImage::for_each_symbol(F func) const
{
for (unsigned i = 0; i < symbol_count(); ++i) {
if (func(symbol(i)) == IterationDecision::Abort)
if (func(symbol(i)) == IterationDecision::Break)
break;
}
}

View file

@ -1,6 +1,6 @@
#include "ELFLoader.h"
#include <AK/kstdio.h>
#include <AK/QuickSort.h>
#include <AK/kstdio.h>
//#define ELFLOADER_DEBUG
@ -43,8 +43,7 @@ bool ELFLoader::layout()
program_header.alignment(),
program_header.is_readable(),
program_header.is_writable(),
String::format("elf-alloc-%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "")
);
String::format("elf-alloc-%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : ""));
memcpy(program_header.vaddr().as_ptr(), program_header.raw_data(), program_header.size_in_image());
} else {
map_section_hook(
@ -55,8 +54,7 @@ bool ELFLoader::layout()
program_header.is_readable(),
program_header.is_writable(),
program_header.is_executable(),
String::format("elf-map-%s%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "", program_header.is_executable() ? "x" : "")
);
String::format("elf-map-%s%s%s", program_header.is_readable() ? "r" : "", program_header.is_writable() ? "w" : "", program_header.is_executable() ? "x" : ""));
}
});
return !failed;
@ -74,7 +72,7 @@ char* ELFLoader::symbol_ptr(const char* name)
found_ptr = (char*)symbol.value();
else
ASSERT_NOT_REACHED();
return IterationDecision::Abort;
return IterationDecision::Break;
});
return found_ptr;
}

View file

@ -52,4 +52,3 @@ private:
};
mutable Vector<SortedSymbol> m_sorted_symbols;
};

View file

@ -117,10 +117,7 @@ typedef uint16_t Elf64_Quarter;
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
/* e_ident */
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
(ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
(ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
(ehdr).e_ident[EI_MAG3] == ELFMAG3)
#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && (ehdr).e_ident[EI_MAG1] == ELFMAG1 && (ehdr).e_ident[EI_MAG2] == ELFMAG2 && (ehdr).e_ident[EI_MAG3] == ELFMAG3)
/* ELF Header */
typedef struct elfhdr {
@ -311,7 +308,6 @@ typedef struct {
#define ELF_TEXT ".text" /* code */
#define ELF_OPENBSDRANDOMDATA ".openbsd.randomdata" /* constant randomdata */
/* Section Attribute Flags - sh_flags */
#define SHF_WRITE 0x1 /* Writable */
#define SHF_ALLOC 0x2 /* occupies memory */
@ -518,7 +514,7 @@ typedef struct {
#define DT_INIT 12 /* address of initialization func. */
#define DT_FINI 13 /* address of termination function */
#define DT_SONAME 14 /* string table offset of shared obj */
#define DT_RPATH 15 /* string table offset of library
#define DT_RPATH 15 /* string table offset of library \
search path */
#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
#define DT_REL 17 /* address of rel. tbl. w addends */