Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
Zipr Toolchain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
Zipr Toolchain
Commits
6b01c949
Commit
6b01c949
authored
6 years ago
by
Jason Hiser
Browse files
Options
Downloads
Patches
Plain Diff
fixed fix from centos
parent
d87b3215
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/elfwrite.cpp
+10
-4
10 additions, 4 deletions
src/elfwrite.cpp
with
10 additions
and
4 deletions
src/elfwrite.cpp
+
10
−
4
View file @
6b01c949
...
...
@@ -540,6 +540,10 @@ void ElfWriterImpl<T_Elf_Ehdr,T_Elf_Phdr,T_Elf_Addr,T_Elf_Shdr,T_Elf_Sym, T_Elf
template
<
class
T_Elf_Ehdr
,
class
T_Elf_Phdr
,
class
T_Elf_Addr
,
class
T_Elf_Shdr
,
class
T_Elf_Sym
,
class
T_Elf_Rel
,
class
T_Elf_Rela
,
class
T_Elf_Dyn
>
void
ElfWriterImpl
<
T_Elf_Ehdr
,
T_Elf_Phdr
,
T_Elf_Addr
,
T_Elf_Shdr
,
T_Elf_Sym
,
T_Elf_Rel
,
T_Elf_Rela
,
T_Elf_Dyn
>::
trim_last_segment_filesz
(
FileIR_t
*
firp
)
{
// this seems OK and is necessary on centos... but on ubuntu, it's a no-go (segfault from loader).
// for now, disabling this optimization until we can figure out what's up.
#if 0
// skip trimming if we aren't doing bss optimization.
if(!m_bss_opts) return;
...
...
@@ -573,13 +577,16 @@ void ElfWriterImpl<T_Elf_Ehdr,T_Elf_Phdr,T_Elf_Addr,T_Elf_Shdr,T_Elf_Sym, T_Elf_
break;
}
const auto last_nonzero_byte_in_seg = k;
const
auto
bytes_to_trim
=
(
PAGE_SIZE
-
1
)
-
last_nonzero_byte_in_seg
;
(void)last_nonzero_byte_in_seg;
const auto bytes_to_trim = 1 (PAGE_SIZE - 1) - last_nonzero_byte_in_seg;
// lastly, update the filesz so we don't need the reste of those bytes.
// memsz is allowed to be bigger than filesz.
new_phdrs
[
seg_to_trim
].
p_filesz
-=
bytes_to_trim
;
new_phdrs[seg_to_trim].p_filesz -=
(
bytes_to_trim
)
;
return;
#endif
}
...
...
@@ -735,7 +742,6 @@ bool ElfWriterImpl<T_Elf_Ehdr,T_Elf_Phdr,T_Elf_Addr,T_Elf_Shdr,T_Elf_Sym, T_Elf_
update_phdr_for_scoop_sections
(
m_firp
);
trim_last_segment_filesz
(
m_firp
);
return
true
;
}
...
...
@@ -769,7 +775,7 @@ void ElfWriterImpl<T_Elf_Ehdr,T_Elf_Phdr,T_Elf_Addr,T_Elf_Shdr,T_Elf_Sym, T_Elf_
else
{
#if 0
note: this does not work on centos as it leave
s
the segments
note: this does not work on centos as it
can
leave the segments
start address + filesize to be a number greater than the entire files size.
This causes the loader to complain. The "right" way to do this is to update the
filesz before we start writing out the elf. See "trim_last_seg_filesz"
...
...
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