mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-24 14:00:48 +02:00
ELF parsing: Convert vector to fextl
This commit is contained in:
1 parent
e8132b82d0
commit
823222702a
6 files changed
+30
-25
No files matched your search
@@ -8,6 +8,7 @@ $end_info$
|
||||
#include "Linux/Utils/ELFContainer.h"
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
#include <FEXCore/Utils/MathUtils.h>
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
@@ -1295,7 +1296,7 @@ void ELFContainer::PrintDynamicTable() const {
|
||||
}
|
||||
}
|
||||
|
||||
void ELFContainer::GetInitLocations(uint64_t GuestELFBase, std::vector<uint64_t> *Locations) {
|
||||
void ELFContainer::GetInitLocations(uint64_t GuestELFBase, fextl::vector<uint64_t> *Locations) {
|
||||
if (Mode == MODE_32BIT) {
|
||||
// If INIT exists then add that first
|
||||
for (uint32_t i = 0; i < SectionHeaders.size(); ++i) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <elf.h>
|
||||
#include <functional>
|
||||
@@ -9,7 +11,6 @@
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// Add macros which are missing in some versions of <elf.h>
|
||||
#ifndef ELF32_ST_VISIBILITY
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
bool WasLoaded() const { return Loaded; }
|
||||
std::string &InterpreterLocation() { return DynamicLinker; }
|
||||
|
||||
std::vector<char const*> const *GetNecessaryLibs() const { return &NecessaryLibs; }
|
||||
fextl::vector<char const*> const *GetNecessaryLibs() const { return &NecessaryLibs; }
|
||||
|
||||
void PrintRelocationTable() const;
|
||||
|
||||
@@ -89,7 +90,7 @@ public:
|
||||
using UnwindAdder = std::function<void(uintptr_t)>;
|
||||
void AddUnwindEntries(UnwindAdder Adder);
|
||||
|
||||
void GetInitLocations(uint64_t GuestELFBase, std::vector<uint64_t> *Locations);
|
||||
void GetInitLocations(uint64_t GuestELFBase, fextl::vector<uint64_t> *Locations);
|
||||
|
||||
|
||||
bool HasTLS() const { return TLSHeader._64 != nullptr; }
|
||||
@@ -139,7 +140,7 @@ private:
|
||||
void PrintInitArray() const;
|
||||
void PrintDynamicTable() const;
|
||||
|
||||
std::vector<char> RawFile;
|
||||
fextl::vector<char> RawFile;
|
||||
union {
|
||||
Elf32_Ehdr _32;
|
||||
Elf64_Ehdr _64;
|
||||
@@ -156,14 +157,14 @@ private:
|
||||
};
|
||||
|
||||
ELFMode Mode;
|
||||
std::vector<SectionHeader> SectionHeaders;
|
||||
std::vector<ProgramHeader> ProgramHeaders;
|
||||
std::vector<ELFSymbol> Symbols;
|
||||
std::vector<uintptr_t> UnwindEntries;
|
||||
fextl::vector<SectionHeader> SectionHeaders;
|
||||
fextl::vector<ProgramHeader> ProgramHeaders;
|
||||
fextl::vector<ELFSymbol> Symbols;
|
||||
fextl::vector<uintptr_t> UnwindEntries;
|
||||
std::unordered_map<std::string, ELFSymbol *> SymbolMap;
|
||||
std::map<uint64_t, ELFSymbol *> SymbolMapByAddress;
|
||||
|
||||
std::vector<char const*> NecessaryLibs;
|
||||
fextl::vector<char const*> NecessaryLibs;
|
||||
|
||||
uint64_t MinPhysicalMemoryLocation{0};
|
||||
uint64_t MaxPhysicalMemoryLocation{0};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
|
||||
#include <string>
|
||||
#include <elf.h>
|
||||
#include <fstream>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
|
||||
#include "Linux/Utils/ELFContainer.h"
|
||||
|
||||
/*
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
struct ELFParser {
|
||||
Elf64_Ehdr ehdr;
|
||||
std::vector<Elf64_Phdr> phdrs;
|
||||
fextl::vector<Elf64_Phdr> phdrs;
|
||||
::ELFLoader::ELFContainer::ELFType type {::ELFLoader::ELFContainer::TYPE_NONE};
|
||||
|
||||
std::string InterpreterElf;
|
||||
|
||||
@@ -10,6 +10,7 @@ $end_info$
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
#include <FEXCore/Utils/MathUtils.h>
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -70,8 +71,8 @@ ELFSymbolDatabase::ELFSymbolDatabase(::ELFLoader::ELFContainer *file)
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> UnfilledDependencies;
|
||||
std::vector<ELFInfo*> NewLibraries;
|
||||
fextl::vector<std::string> UnfilledDependencies;
|
||||
fextl::vector<ELFInfo*> NewLibraries;
|
||||
|
||||
auto FillDependencies = [&UnfilledDependencies, this](ELFInfo *ELF) {
|
||||
for (auto &Lib : *ELF->Container->GetNecessaryLibs()) {
|
||||
@@ -104,7 +105,7 @@ ELFSymbolDatabase::ELFSymbolDatabase(::ELFLoader::ELFContainer *file)
|
||||
NewLibraries.emplace_back(&LocalInfo);
|
||||
|
||||
do {
|
||||
std::vector<ELFInfo*> PreviousLibs;
|
||||
fextl::vector<ELFInfo*> PreviousLibs;
|
||||
PreviousLibs.swap(NewLibraries);
|
||||
for (auto ELF : PreviousLibs) {
|
||||
FillDependencies(ELF);
|
||||
@@ -345,7 +346,7 @@ ELFSymbol const *ELFSymbolDatabase::GetSymbolInRange(RangeType Address) {
|
||||
return Sym->second;
|
||||
}
|
||||
|
||||
void ELFSymbolDatabase::GetInitLocations(std::vector<uint64_t> *Locations) {
|
||||
void ELFSymbolDatabase::GetInitLocations(fextl::vector<uint64_t> *Locations) {
|
||||
// Walk the initialization order and fill the locations for initializations
|
||||
for (auto ELF : InitializationOrder) {
|
||||
ELF->Container->GetInitLocations(ELF->GuestBase, Locations);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
|
||||
#include "Linux/Utils/ELFContainer.h"
|
||||
|
||||
#include <cstdint>
|
||||
@@ -8,7 +10,6 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace ELFLoader {
|
||||
class ELFSymbolDatabase final {
|
||||
@@ -28,7 +29,7 @@ public:
|
||||
::ELFLoader::ELFSymbol const *GetGlobalSymbolInRange(RangeType Address);
|
||||
::ELFLoader::ELFSymbol const *GetNoWeakSymbolInRange(RangeType Address);
|
||||
|
||||
void GetInitLocations(std::vector<uint64_t> *Locations);
|
||||
void GetInitLocations(fextl::vector<uint64_t> *Locations);
|
||||
|
||||
private:
|
||||
::ELFLoader::ELFContainer *File;
|
||||
@@ -42,17 +43,17 @@ private:
|
||||
};
|
||||
|
||||
ELFInfo LocalInfo;
|
||||
std::vector<ELFInfo*> DynamicELFInfo;
|
||||
std::vector<ELFInfo*> InitializationOrder;
|
||||
fextl::vector<ELFInfo*> DynamicELFInfo;
|
||||
fextl::vector<ELFInfo*> InitializationOrder;
|
||||
uint64_t ELFMemorySize{};
|
||||
bool FixedNoReplace {true};
|
||||
void *ELFBase{};
|
||||
|
||||
std::unordered_map<std::string, ELFInfo*> NameToELF;
|
||||
std::vector<std::string> LibrarySearchPaths;
|
||||
fextl::vector<std::string> LibrarySearchPaths;
|
||||
|
||||
// Symbols
|
||||
std::vector<ELFLoader::ELFSymbol*> Symbols;
|
||||
fextl::vector<ELFLoader::ELFSymbol*> Symbols;
|
||||
using SymbolTableType = std::unordered_map<std::string, ELFLoader::ELFSymbol *>;
|
||||
SymbolTableType SymbolMap;
|
||||
SymbolTableType SymbolMapGlobalOnly;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
#include <FEXHeaderUtils/Syscalls.h>
|
||||
#include <FEXHeaderUtils/TypeDefines.h>
|
||||
#include <FEXHeaderUtils/SymlinkChecks.h>
|
||||
@@ -54,7 +55,7 @@ class ELFCodeLoader final : public FEXCore::CodeLoader {
|
||||
uintptr_t BrkStart;
|
||||
uintptr_t StackPointer;
|
||||
|
||||
size_t CalculateTotalElfSize(const std::vector<Elf64_Phdr> &headers)
|
||||
size_t CalculateTotalElfSize(const fextl::vector<Elf64_Phdr> &headers)
|
||||
{
|
||||
auto first = std::find_if(headers.begin(), headers.end(), [](const Elf64_Phdr &Header) { return Header.p_type == PT_LOAD; });
|
||||
auto last = std::find_if(headers.rbegin(), headers.rend(), [](const Elf64_Phdr &Header) { return Header.p_type == PT_LOAD; });
|
||||
|
||||
Reference in new issue
Block a user