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
7aa0e4a7
There was an error fetching the commit references. Please try again later.
Commit
7aa0e4a7
authored
5 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
loader: nso: Fix loading of static objects to be properly sized and aligned.
parent
b11b424a
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/loader/nso.cpp
+9
-19
9 additions, 19 deletions
src/core/loader/nso.cpp
with
9 additions
and
19 deletions
src/core/loader/nso.cpp
+
9
−
19
View file @
7aa0e4a7
...
...
@@ -97,13 +97,12 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
if
(
nso_header
.
IsSegmentCompressed
(
i
))
{
data
=
DecompressSegment
(
data
,
nso_header
.
segments
[
i
]);
}
program_image
.
resize
(
nso_header
.
segments
[
i
].
location
+
PageAlignSize
(
static_cast
<
u32
>
(
data
.
size
())));
program_image
.
resize
(
nso_header
.
segments
[
i
].
location
+
static_cast
<
u32
>
(
data
.
size
()));
std
::
memcpy
(
program_image
.
data
()
+
nso_header
.
segments
[
i
].
location
,
data
.
data
(),
data
.
size
());
codeset
.
segments
[
i
].
addr
=
nso_header
.
segments
[
i
].
location
;
codeset
.
segments
[
i
].
offset
=
nso_header
.
segments
[
i
].
location
;
codeset
.
segments
[
i
].
size
=
PageAlignSize
(
static_cast
<
u32
>
(
data
.
size
()))
;
codeset
.
segments
[
i
].
size
=
nso_header
.
segments
[
i
]
.
size
;
}
if
(
should_pass_arguments
)
{
...
...
@@ -123,24 +122,15 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
arg_data
.
size
());
}
// MOD header pointer is at .text offset + 4
u32
module_offset
;
std
::
memcpy
(
&
module_offset
,
program_image
.
data
()
+
4
,
sizeof
(
u32
));
// Read MOD header
MODHeader
mod_header
{};
// Default .bss to size in segment header if MOD0 section doesn't exist
u32
bss_size
{
PageAlignSize
(
nso_header
.
segments
[
2
].
bss_size
)};
std
::
memcpy
(
&
mod_header
,
program_image
.
data
()
+
module_offset
,
sizeof
(
MODHeader
));
const
bool
has_mod_header
{
mod_header
.
magic
==
Common
::
MakeMagic
(
'M'
,
'O'
,
'D'
,
'0'
)};
if
(
has_mod_header
)
{
// Resize program image to include .bss section and page align each section
bss_size
=
PageAlignSize
(
mod_header
.
bss_end_offset
-
mod_header
.
bss_start_offset
);
}
codeset
.
DataSegment
().
size
+=
bss_size
;
const
u32
image_size
{
PageAlignSize
(
static_cast
<
u32
>
(
program_image
.
size
())
+
bss_size
)};
codeset
.
DataSegment
().
size
+=
nso_header
.
segments
[
2
].
bss_size
;
const
u32
image_size
{
PageAlignSize
(
static_cast
<
u32
>
(
program_image
.
size
())
+
nso_header
.
segments
[
2
].
bss_size
)};
program_image
.
resize
(
image_size
);
for
(
std
::
size_t
i
=
0
;
i
<
nso_header
.
segments
.
size
();
++
i
)
{
codeset
.
segments
[
i
].
size
=
PageAlignSize
(
codeset
.
segments
[
i
].
size
);
}
// Apply patches if necessary
if
(
pm
&&
(
pm
->
HasNSOPatch
(
nso_header
.
build_id
)
||
Settings
::
values
.
dump_nso
))
{
std
::
vector
<
u8
>
pi_header
;
...
...
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