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
7b5d2345
There was an error fetching the commit references. Please try again later.
Commit
7b5d2345
authored
1 year ago
by
Liam
Browse files
Options
Downloads
Patches
Plain Diff
jit: add support for relr-type relocations
parent
84b0e29b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/elf.h
+8
-0
8 additions, 0 deletions
src/common/elf.h
src/core/hle/service/jit/jit_context.cpp
+34
-2
34 additions, 2 deletions
src/core/hle/service/jit/jit_context.cpp
with
42 additions
and
2 deletions
src/common/elf.h
+
8
−
0
View file @
7b5d2345
...
@@ -211,6 +211,11 @@ struct Elf64_Rela {
...
@@ -211,6 +211,11 @@ struct Elf64_Rela {
Elf64_Sxword
r_addend
;
/* Addend */
Elf64_Sxword
r_addend
;
/* Addend */
};
};
/* RELR relocation table entry */
using
Elf32_Relr
=
Elf32_Word
;
using
Elf64_Relr
=
Elf64_Xword
;
/* How to extract and insert information held in the r_info field. */
/* How to extract and insert information held in the r_info field. */
static
inline
u32
Elf32RelSymIndex
(
Elf32_Word
r_info
)
{
static
inline
u32
Elf32RelSymIndex
(
Elf32_Word
r_info
)
{
...
@@ -328,6 +333,9 @@ constexpr u32 ElfDtFiniArray = 26; /* Array with addresses of fini fct */
...
@@ -328,6 +333,9 @@ constexpr u32 ElfDtFiniArray = 26; /* Array with addresses of fini fct */
constexpr
u32
ElfDtInitArraySz
=
27
;
/* Size in bytes of DT_INIT_ARRAY */
constexpr
u32
ElfDtInitArraySz
=
27
;
/* Size in bytes of DT_INIT_ARRAY */
constexpr
u32
ElfDtFiniArraySz
=
28
;
/* Size in bytes of DT_FINI_ARRAY */
constexpr
u32
ElfDtFiniArraySz
=
28
;
/* Size in bytes of DT_FINI_ARRAY */
constexpr
u32
ElfDtSymtabShndx
=
34
;
/* Address of SYMTAB_SHNDX section */
constexpr
u32
ElfDtSymtabShndx
=
34
;
/* Address of SYMTAB_SHNDX section */
constexpr
u32
ElfDtRelrsz
=
35
;
/* Size of RELR relative relocations */
constexpr
u32
ElfDtRelr
=
36
;
/* Address of RELR relative relocations */
constexpr
u32
ElfDtRelrent
=
37
;
/* Size of one RELR relative relocation */
}
// namespace ELF
}
// namespace ELF
}
// namespace Common
}
// namespace Common
This diff is collapsed.
Click to expand it.
src/core/hle/service/jit/jit_context.cpp
+
34
−
2
View file @
7b5d2345
...
@@ -156,6 +156,8 @@ public:
...
@@ -156,6 +156,8 @@ public:
bool
LoadNRO
(
std
::
span
<
const
u8
>
data
)
{
bool
LoadNRO
(
std
::
span
<
const
u8
>
data
)
{
local_memory
.
clear
();
local_memory
.
clear
();
relocbase
=
local_memory
.
size
();
local_memory
.
insert
(
local_memory
.
end
(),
data
.
begin
(),
data
.
end
());
local_memory
.
insert
(
local_memory
.
end
(),
data
.
begin
(),
data
.
end
());
if
(
FixupRelocations
())
{
if
(
FixupRelocations
())
{
...
@@ -181,8 +183,8 @@ public:
...
@@ -181,8 +183,8 @@ public:
// https://refspecs.linuxbase.org/elf/gabi4+/ch5.dynamic.html
// https://refspecs.linuxbase.org/elf/gabi4+/ch5.dynamic.html
// https://refspecs.linuxbase.org/elf/gabi4+/ch4.reloc.html
// https://refspecs.linuxbase.org/elf/gabi4+/ch4.reloc.html
VAddr
dynamic_offset
{
mod_offset
+
callbacks
->
MemoryRead32
(
mod_offset
+
4
)};
VAddr
dynamic_offset
{
mod_offset
+
callbacks
->
MemoryRead32
(
mod_offset
+
4
)};
VAddr
rela_dyn
=
0
;
VAddr
rela_dyn
=
0
,
relr_dyn
=
0
;
size_t
num_rela
=
0
;
size_t
num_rela
=
0
,
num_relr
=
0
;
while
(
true
)
{
while
(
true
)
{
const
auto
dyn
{
callbacks
->
ReadMemory
<
Elf64_Dyn
>
(
dynamic_offset
)};
const
auto
dyn
{
callbacks
->
ReadMemory
<
Elf64_Dyn
>
(
dynamic_offset
)};
dynamic_offset
+=
sizeof
(
Elf64_Dyn
);
dynamic_offset
+=
sizeof
(
Elf64_Dyn
);
...
@@ -196,6 +198,12 @@ public:
...
@@ -196,6 +198,12 @@ public:
if
(
dyn
.
d_tag
==
ElfDtRelasz
)
{
if
(
dyn
.
d_tag
==
ElfDtRelasz
)
{
num_rela
=
dyn
.
d_un
.
d_val
/
sizeof
(
Elf64_Rela
);
num_rela
=
dyn
.
d_un
.
d_val
/
sizeof
(
Elf64_Rela
);
}
}
if
(
dyn
.
d_tag
==
ElfDtRelr
)
{
relr_dyn
=
dyn
.
d_un
.
d_ptr
;
}
if
(
dyn
.
d_tag
==
ElfDtRelrsz
)
{
num_relr
=
dyn
.
d_un
.
d_val
/
sizeof
(
Elf64_Relr
);
}
}
}
for
(
size_t
i
=
0
;
i
<
num_rela
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
num_rela
;
i
++
)
{
...
@@ -207,6 +215,29 @@ public:
...
@@ -207,6 +215,29 @@ public:
callbacks
->
MemoryWrite64
(
rela
.
r_offset
,
contents
+
rela
.
r_addend
);
callbacks
->
MemoryWrite64
(
rela
.
r_offset
,
contents
+
rela
.
r_addend
);
}
}
VAddr
relr_where
=
0
;
for
(
size_t
i
=
0
;
i
<
num_relr
;
i
++
)
{
const
auto
relr
{
callbacks
->
ReadMemory
<
Elf64_Relr
>
(
relr_dyn
+
i
*
sizeof
(
Elf64_Relr
))};
const
auto
incr
{[
&
](
VAddr
where
)
{
callbacks
->
MemoryWrite64
(
where
,
callbacks
->
MemoryRead64
(
where
)
+
relocbase
);
}};
if
((
relr
&
1
)
==
0
)
{
// where pointer
relr_where
=
relocbase
+
relr
;
incr
(
relr_where
);
relr_where
+=
sizeof
(
Elf64_Addr
);
}
else
{
// bitmap
for
(
int
bit
=
1
;
bit
<
64
;
bit
++
)
{
if
((
relr
&
(
1ULL
<<
bit
))
!=
0
)
{
incr
(
relr_where
+
i
*
sizeof
(
Elf64_Addr
));
}
}
relr_where
+=
63
*
sizeof
(
Elf64_Addr
);
}
}
return
true
;
return
true
;
}
}
...
@@ -313,6 +344,7 @@ public:
...
@@ -313,6 +344,7 @@ public:
Core
::
Memory
::
Memory
&
memory
;
Core
::
Memory
::
Memory
&
memory
;
VAddr
top_of_stack
;
VAddr
top_of_stack
;
VAddr
heap_pointer
;
VAddr
heap_pointer
;
VAddr
relocbase
;
};
};
void
DynarmicCallbacks64
::
CallSVC
(
u32
swi
)
{
void
DynarmicCallbacks64
::
CallSVC
(
u32
swi
)
{
...
...
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