Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
elfio mirror
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Third Party Mirrors
elfio mirror
Commits
7409369f
Commit
7409369f
authored
4 years ago
by
Serge Lamikhov-Center
Browse files
Options
Downloads
Patches
Plain Diff
Change the data segment alignment for newer Linux kernels
parent
a01d7285
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
elfio/elfio_utils.hpp
+4
-3
4 additions, 3 deletions
elfio/elfio_utils.hpp
examples/writer/writer.cpp
+7
-7
7 additions, 7 deletions
examples/writer/writer.cpp
with
11 additions
and
10 deletions
elfio/elfio_utils.hpp
+
4
−
3
View file @
7409369f
...
...
@@ -23,7 +23,8 @@ THE SOFTWARE.
#ifndef ELFIO_UTILS_HPP
#define ELFIO_UTILS_HPP
#include
<iostream>
#include
<cstdint>
#include
<ostream>
#define ELFIO_GET_ACCESS( TYPE, NAME, FIELD ) \
TYPE get_##NAME() const { return ( *convertor )( FIELD ); }
...
...
@@ -174,10 +175,10 @@ inline uint32_t elf_hash( const unsigned char* name )
return
h
;
}
inline
std
::
string
to_hex_string
(
Elf64_Addr
value
)
inline
std
::
string
to_hex_string
(
uint64_t
value
)
{
std
::
string
str
;
while
(
value
)
{
auto
digit
=
value
&
0xF
;
if
(
digit
<
0xA
)
...
...
This diff is collapsed.
Click to expand it.
examples/writer/writer.cpp
+
7
−
7
View file @
7409369f
...
...
@@ -45,7 +45,7 @@ int main( void )
char
text
[]
=
{
'\xB8'
,
'\x04'
,
'\x00'
,
'\x00'
,
'\x00'
,
// mov eax, 4
'\xBB'
,
'\x01'
,
'\x00'
,
'\x00'
,
'\x00'
,
// mov ebx, 1
'\xB9'
,
'\x
2
0'
,
'\x
8
0'
,
'\x
0
4'
,
'\x0
8
'
,
// mov ecx, msg
'\xB9'
,
'\x
0
0'
,
'\x
2
0'
,
'\x4
0
'
,
'\x0
0
'
,
// mov ecx, msg
'\xBA'
,
'\x0E'
,
'\x00'
,
'\x00'
,
'\x00'
,
// mov edx, 14
'\xCD'
,
'\x80'
,
// int 0x80
'\xB8'
,
'\x01'
,
'\x00'
,
'\x00'
,
'\x00'
,
// mov eax, 1
...
...
@@ -56,8 +56,8 @@ int main( void )
// Create a loadable segment
segment
*
text_seg
=
writer
.
segments
.
add
();
text_seg
->
set_type
(
PT_LOAD
);
text_seg
->
set_virtual_address
(
0x0
8
04
8
000
);
text_seg
->
set_physical_address
(
0x0
8
04
8
000
);
text_seg
->
set_virtual_address
(
0x004
01
000
);
text_seg
->
set_physical_address
(
0x004
01
000
);
text_seg
->
set_flags
(
PF_X
|
PF_R
);
text_seg
->
set_align
(
0x1000
);
...
...
@@ -80,10 +80,10 @@ int main( void )
// Create a read/write segment
segment
*
data_seg
=
writer
.
segments
.
add
();
data_seg
->
set_type
(
PT_LOAD
);
data_seg
->
set_virtual_address
(
0x0
8
04
8
020
);
data_seg
->
set_physical_address
(
0x0
8
04
8
020
);
data_seg
->
set_virtual_address
(
0x004020
00
);
data_seg
->
set_physical_address
(
0x004020
00
);
data_seg
->
set_flags
(
PF_W
|
PF_R
);
data_seg
->
set_align
(
0x10
);
data_seg
->
set_align
(
0x10
00
);
// Add code section into program segment
data_seg
->
add_section_index
(
data_sec
->
get_index
(),
...
...
@@ -103,7 +103,7 @@ int main( void )
// In this example, the code starts at the first address of the
// 'text_seg' segment. Therefore, the start address is set
// to be equal to the segment location
writer
.
set_entry
(
0x0
8
04
8
000
);
writer
.
set_entry
(
0x004
01
000
);
// Create ELF file
writer
.
save
(
"hello_x86_64"
);
...
...
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