Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
67095f80
There was an error fetching the commit references. Please try again later.
Commit
67095f80
authored
11 years ago
by
Mathieu Vaillancourt
Browse files
Options
Downloads
Patches
Plain Diff
Implement simple LoadSymbols for ELF files
parent
d046cfbb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/elf/elf_reader.cpp
+13
-63
13 additions, 63 deletions
src/core/elf/elf_reader.cpp
with
13 additions
and
63 deletions
src/core/elf/elf_reader.cpp
+
13
−
63
View file @
67095f80
...
@@ -6,13 +6,10 @@
...
@@ -6,13 +6,10 @@
#include
"common/common.h"
#include
"common/common.h"
#include
"common/symbols.h"
#include
"core/mem_map.h"
#include
"core/mem_map.h"
#include
"core/elf/elf_reader.h"
#include
"core/elf/elf_reader.h"
//#include "Core/Debugger/Debugger_SymbolMap.h"
//#include "Core/HW/Memmap.h"
//#include "Core/PowerPC/PPCSymbolDB.h"
//void bswap(Elf32_Word &w) {w = Common::swap32(w);}
//void bswap(Elf32_Word &w) {w = Common::swap32(w);}
//void bswap(Elf32_Half &w) {w = Common::swap16(w);}
//void bswap(Elf32_Half &w) {w = Common::swap16(w);}
...
@@ -71,16 +68,9 @@ ElfReader::ElfReader(void *ptr)
...
@@ -71,16 +68,9 @@ ElfReader::ElfReader(void *ptr)
segments
=
(
Elf32_Phdr
*
)(
base
+
header
->
e_phoff
);
segments
=
(
Elf32_Phdr
*
)(
base
+
header
->
e_phoff
);
sections
=
(
Elf32_Shdr
*
)(
base
+
header
->
e_shoff
);
sections
=
(
Elf32_Shdr
*
)(
base
+
header
->
e_shoff
);
//for (int i = 0; i < GetNumSegments(); i++)
//{
// byteswapSegment(segments[i]);
//}
//for (int i = 0; i < GetNumSections(); i++)
//{
// byteswapSection(sections[i]);
//}
entryPoint
=
header
->
e_entry
;
entryPoint
=
header
->
e_entry
;
LoadSymbols
();
}
}
const
char
*
ElfReader
::
GetSectionName
(
int
section
)
const
const
char
*
ElfReader
::
GetSectionName
(
int
section
)
const
...
@@ -101,9 +91,6 @@ bool ElfReader::LoadInto(u32 vaddr)
...
@@ -101,9 +91,6 @@ bool ElfReader::LoadInto(u32 vaddr)
{
{
DEBUG_LOG
(
MASTER_LOG
,
"String section: %i"
,
header
->
e_shstrndx
);
DEBUG_LOG
(
MASTER_LOG
,
"String section: %i"
,
header
->
e_shstrndx
);
// sectionOffsets = new u32[GetNumSections()];
// sectionAddrs = new u32[GetNumSections()];
// Should we relocate?
// Should we relocate?
bRelocate
=
(
header
->
e_type
!=
ET_EXEC
);
bRelocate
=
(
header
->
e_type
!=
ET_EXEC
);
...
@@ -153,30 +140,8 @@ bool ElfReader::LoadInto(u32 vaddr)
...
@@ -153,30 +140,8 @@ bool ElfReader::LoadInto(u32 vaddr)
}
}
}
}
/*
LOG(MASTER_LOG,"%i sections:", header->e_shnum);
for (int i=0; i<GetNumSections(); i++)
{
Elf32_Shdr *s = §ions[i];
const char *name = GetSectionName(i);
u32 writeAddr = s->sh_addr + baseAddress;
INFO_LOG
(
MASTER_LOG
,
"Done loading."
);
sectionOffsets[i] = writeAddr - vaddr;
sectionAddrs[i] = writeAddr;
if (s->sh_flags & SHF_ALLOC)
{
LOG(MASTER_LOG,"Data Section found: %s Sitting at %08x, size %08x", name, writeAddr, s->sh_size);
}
else
{
LOG(MASTER_LOG,"NonData Section found: %s Ignoring (size=%08x) (flags=%08x)", name, s->sh_size, s->sh_flags);
}
}
*/
INFO_LOG
(
MASTER_LOG
,
"Done loading."
);
return
true
;
return
true
;
}
}
...
@@ -192,8 +157,6 @@ SectionID ElfReader::GetSectionByName(const char *name, int firstSection) const
...
@@ -192,8 +157,6 @@ SectionID ElfReader::GetSectionByName(const char *name, int firstSection) const
return
-
1
;
return
-
1
;
}
}
/* TODO(bunnei): The following is verbatim from Dolphin - needs to be updated for this project:
bool
ElfReader
::
LoadSymbols
()
bool
ElfReader
::
LoadSymbols
()
{
{
bool
hasSymbols
=
false
;
bool
hasSymbols
=
false
;
...
@@ -208,33 +171,20 @@ bool ElfReader::LoadSymbols()
...
@@ -208,33 +171,20 @@ bool ElfReader::LoadSymbols()
int
numSymbols
=
sections
[
sec
].
sh_size
/
sizeof
(
Elf32_Sym
);
int
numSymbols
=
sections
[
sec
].
sh_size
/
sizeof
(
Elf32_Sym
);
for
(
int
sym
=
0
;
sym
<
numSymbols
;
sym
++
)
for
(
int
sym
=
0
;
sym
<
numSymbols
;
sym
++
)
{
{
int size = Common::swap32(
symtab[sym].st_size
)
;
int
size
=
symtab
[
sym
].
st_size
;
if
(
size
==
0
)
if
(
size
==
0
)
continue
;
continue
;
// int bind = symtab[sym].st_info >> 4;
// int bind = symtab[sym].st_info >> 4;
int
type
=
symtab
[
sym
].
st_info
&
0xF
;
int
type
=
symtab
[
sym
].
st_info
&
0xF
;
int sectionIndex = Common::swap16(symtab[sym].st_shndx);
int value = Common::swap32(symtab[sym].st_value);
const
char
*
name
=
stringBase
+
symtab
[
sym
].
st_name
;
const char *name = stringBase + Common::swap32(symtab[sym].st_name);
if (bRelocate)
Symbols
::
Add
(
symtab
[
sym
].
st_value
,
name
,
size
,
type
);
value += sectionAddrs[sectionIndex];
hasSymbols
=
true
;
int symtype = Symbol::SYMBOL_DATA;
switch (type)
{
case STT_OBJECT:
symtype = Symbol::SYMBOL_DATA; break;
case STT_FUNC:
symtype = Symbol::SYMBOL_FUNCTION; break;
default:
continue;
}
g_symbolDB.AddKnownSymbol(value, size, name, symtype);
hasSymbols = true;
}
}
}
}
g_symbolDB.Index();
return hasSymbols;
return
hasSymbols
;
}
}
*/
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment