mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 18:32:47 +00:00
Remove unused include and very small refactoring.
Unused include in unself.h, ELF.h. New line after an if to enable debugging. Rewrite strange boolean expression in ELF.cpp.
This commit is contained in:
parent
9834fc7f70
commit
7dafb164e8
rpcs3
@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Loader/SELF.h"
|
||||
#include "Loader/ELF.h"
|
||||
#include "Loader/ELF64.h"
|
||||
#include "Loader/ELF32.h"
|
||||
#include "key_vault.h"
|
||||
|
||||
struct AppInfo
|
||||
|
@ -50,9 +50,15 @@ u64 vfsStream::Seek(s64 offset, vfsSeekMode mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case vfsSeekSet: m_pos = offset; break;
|
||||
case vfsSeekCur: m_pos += offset; break;
|
||||
case vfsSeekEnd: m_pos = GetSize() + offset; break;
|
||||
case vfsSeekSet:
|
||||
m_pos = offset;
|
||||
break;
|
||||
case vfsSeekCur:
|
||||
m_pos += offset;
|
||||
break;
|
||||
case vfsSeekEnd:
|
||||
m_pos = GetSize() + offset;
|
||||
break;
|
||||
}
|
||||
|
||||
return m_pos;
|
||||
|
@ -104,6 +104,8 @@ void DisAsmFrame::Resume()
|
||||
|
||||
#include <Utilities/MTProgressDialog.h>
|
||||
#include "Loader/ELF.h"
|
||||
#include "Loader/ELF32.h"
|
||||
#include "Loader/ELF64.h"
|
||||
std::vector<Elf64_Shdr>* shdr_arr_64 = NULL;
|
||||
std::vector<Elf32_Shdr>* shdr_arr_32 = NULL;
|
||||
ELF64Loader* l_elf64 = NULL;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "stdafx.h"
|
||||
#include "Emu/FS/vfsStream.h"
|
||||
#include "ELF.h"
|
||||
#include "ELF64.h"
|
||||
#include "ELF32.h"
|
||||
|
||||
void Elf_Ehdr::Show()
|
||||
{
|
||||
@ -13,43 +15,49 @@ void Elf_Ehdr::Load(vfsStream& f)
|
||||
}
|
||||
|
||||
ELFLoader::ELFLoader(vfsStream& f)
|
||||
: elf_f(f)
|
||||
: m_elf_file(f)
|
||||
, LoaderBase()
|
||||
, loader(nullptr)
|
||||
, m_loader(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
bool ELFLoader::LoadInfo()
|
||||
{
|
||||
if(!elf_f.IsOpened()) return false;
|
||||
if(!m_elf_file.IsOpened())
|
||||
return false;
|
||||
|
||||
elf_f.Seek(0);
|
||||
ehdr.Load(elf_f);
|
||||
if(!ehdr.CheckMagic()) return false;
|
||||
m_elf_file.Seek(0);
|
||||
ehdr.Load(m_elf_file);
|
||||
if(!ehdr.CheckMagic())
|
||||
return false;
|
||||
|
||||
switch(ehdr.GetClass())
|
||||
{
|
||||
case CLASS_ELF32: loader = new ELF32Loader(elf_f); break;
|
||||
case CLASS_ELF64: loader = new ELF64Loader(elf_f); break;
|
||||
case CLASS_ELF32:
|
||||
m_loader = new ELF32Loader(m_elf_file);
|
||||
break;
|
||||
case CLASS_ELF64:
|
||||
m_loader = new ELF64Loader(m_elf_file);
|
||||
break;
|
||||
}
|
||||
|
||||
if(!loader || !loader->LoadInfo()) return false;
|
||||
if(!(m_loader && m_loader->LoadInfo()))
|
||||
return false;
|
||||
|
||||
entry = loader->GetEntry();
|
||||
machine = loader->GetMachine();
|
||||
entry = m_loader->GetEntry();
|
||||
machine = m_loader->GetMachine();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ELFLoader::LoadData(u64 offset)
|
||||
{
|
||||
if(!loader || !loader->LoadData(offset)) return false;
|
||||
return true;
|
||||
return m_loader && m_loader->LoadData(offset);
|
||||
}
|
||||
|
||||
bool ELFLoader::Close()
|
||||
{
|
||||
delete loader;
|
||||
loader = nullptr;
|
||||
return elf_f.Close();
|
||||
delete m_loader;
|
||||
m_loader = nullptr;
|
||||
return m_elf_file.Close();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "ELF64.h"
|
||||
#include "ELF32.h"
|
||||
#include "Loader.h"
|
||||
|
||||
class vfsStream;
|
||||
|
||||
enum ElfClass
|
||||
{
|
||||
@ -34,14 +35,17 @@ struct Elf_Ehdr
|
||||
|
||||
class ELFLoader : public LoaderBase
|
||||
{
|
||||
vfsStream& elf_f;
|
||||
LoaderBase* loader;
|
||||
vfsStream& m_elf_file;
|
||||
LoaderBase* m_loader;
|
||||
|
||||
public:
|
||||
Elf_Ehdr ehdr;
|
||||
|
||||
ELFLoader(vfsStream& f);
|
||||
virtual ~ELFLoader() {Close();}
|
||||
virtual ~ELFLoader()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
virtual bool LoadInfo();
|
||||
virtual bool LoadData(u64 offset = 0);
|
||||
|
@ -372,13 +372,16 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
|
||||
|
||||
auto& proc_param = vm::get_ref<sys_process_param>(offset + phdr.p_vaddr);
|
||||
|
||||
if (proc_param.size < sizeof(sys_process_param)) {
|
||||
if (proc_param.size < sizeof(sys_process_param))
|
||||
{
|
||||
LOG_WARNING(LOADER, "Bad proc param size! [0x%x : 0x%x]", proc_param.size, sizeof(sys_process_param));
|
||||
}
|
||||
if (proc_param.magic != 0x13bcc5f6) {
|
||||
if (proc_param.magic != 0x13bcc5f6)
|
||||
{
|
||||
LOG_ERROR(LOADER, "Bad magic! [0x%x]", proc_param.magic);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
#ifdef LOADER_DEBUG
|
||||
sys_process_param_info& info = Emu.GetInfo().GetProcParam();
|
||||
LOG_NOTICE(LOADER, "*** sdk version: 0x%x", info.sdk_version.ToLE());
|
||||
|
@ -121,14 +121,17 @@ void Loader::Open(vfsFileBase& stream)
|
||||
|
||||
LoaderBase* Loader::SearchLoader()
|
||||
{
|
||||
if(!m_stream) return nullptr;
|
||||
if(!m_stream)
|
||||
return nullptr;
|
||||
|
||||
LoaderBase* l;
|
||||
|
||||
if((l=new ELFLoader(*m_stream))->LoadInfo()) return l;
|
||||
LoaderBase* l = new ELFLoader(*m_stream);
|
||||
if(l->LoadInfo())
|
||||
return l;
|
||||
delete l;
|
||||
|
||||
if((l=new SELFLoader(*m_stream))->LoadInfo()) return l;
|
||||
l = new SELFLoader(*m_stream);
|
||||
if(l->LoadInfo())
|
||||
return l;
|
||||
delete l;
|
||||
|
||||
return nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user