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
e8afffec
Commit
e8afffec
authored
11 years ago
by
Serge Lamikhov-Center
Committed by
Serge Lamikhov-Center
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Dump for section and segment data added
parent
17f03740
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
elfio/elfio_dump.hpp
+104
-0
104 additions, 0 deletions
elfio/elfio_dump.hpp
examples/elfdump/elfdump.cpp
+2
-0
2 additions, 0 deletions
examples/elfdump/elfdump.cpp
with
106 additions
and
0 deletions
elfio/elfio_dump.hpp
+
104
−
0
View file @
e8afffec
...
@@ -23,6 +23,7 @@ THE SOFTWARE.
...
@@ -23,6 +23,7 @@ THE SOFTWARE.
#ifndef ELFIO_DUMP_HPP
#ifndef ELFIO_DUMP_HPP
#define ELFIO_DUMP_HPP
#define ELFIO_DUMP_HPP
#include
<algorithm>
#include
<string>
#include
<string>
#include
<ostream>
#include
<ostream>
#include
<sstream>
#include
<sstream>
...
@@ -424,6 +425,8 @@ class dump
...
@@ -424,6 +425,8 @@ class dump
std::hex << std::left
std::hex << std::left
public:
public:
static
const
ELFIO
::
Elf_Xword
MAX_DATA_ENTRIES
=
64
;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static
void
static
void
header
(
std
::
ostream
&
out
,
const
elfio
&
reader
)
header
(
std
::
ostream
&
out
,
const
elfio
&
reader
)
...
@@ -763,6 +766,107 @@ class dump
...
@@ -763,6 +766,107 @@ class dump
}
}
out
<<
std
::
endl
;
out
<<
std
::
endl
;
}
}
//------------------------------------------------------------------------------
static
void
section_data
(
std
::
ostream
&
out
,
const
section
*
sec
)
{
std
::
ios_base
::
fmtflags
original_flags
=
out
.
flags
();
out
<<
sec
->
get_name
()
<<
std
::
endl
;
const
char
*
pdata
=
sec
->
get_data
();
ELFIO
::
Elf_Xword
i
;
for
(
i
=
0
;
i
<
std
::
min
(
sec
->
get_size
(),
MAX_DATA_ENTRIES
);
++
i
)
{
if
(
i
%
16
==
0
)
{
out
<<
"["
<<
DUMP_HEX_FORMAT
(
8
)
<<
i
<<
"]"
;
}
out
<<
" "
<<
DUMP_HEX_FORMAT
(
2
)
<<
(
pdata
[
i
]
&
0x000000FF
);
if
(
i
%
16
==
15
)
{
out
<<
std
::
endl
;
}
}
if
(
i
%
16
!=
0
)
{
out
<<
std
::
endl
;
}
out
.
flags
(
original_flags
);
return
;
}
//------------------------------------------------------------------------------
static
void
section_datas
(
std
::
ostream
&
out
,
const
elfio
&
reader
)
{
Elf_Half
n
=
reader
.
sections
.
size
();
if
(
n
==
0
)
{
return
;
}
out
<<
"Section Data:"
<<
std
::
endl
;
for
(
Elf_Half
i
=
1
;
i
<
n
;
++
i
)
{
// For all sections
section
*
sec
=
reader
.
sections
[
i
];
if
(
sec
->
get_type
()
==
SHT_NOBITS
)
{
continue
;
}
section_data
(
out
,
sec
);
}
out
<<
std
::
endl
;
}
//------------------------------------------------------------------------------
static
void
segment_data
(
std
::
ostream
&
out
,
Elf_Half
no
,
const
segment
*
seg
)
{
std
::
ios_base
::
fmtflags
original_flags
=
out
.
flags
();
out
<<
"Segment # "
<<
no
<<
std
::
endl
;
const
char
*
pdata
=
seg
->
get_data
();
ELFIO
::
Elf_Xword
i
;
for
(
i
=
0
;
i
<
std
::
min
(
seg
->
get_file_size
(),
MAX_DATA_ENTRIES
);
++
i
)
{
if
(
i
%
16
==
0
)
{
out
<<
"["
<<
DUMP_HEX_FORMAT
(
8
)
<<
i
<<
"]"
;
}
out
<<
" "
<<
DUMP_HEX_FORMAT
(
2
)
<<
(
pdata
[
i
]
&
0x000000FF
);
if
(
i
%
16
==
15
)
{
out
<<
std
::
endl
;
}
}
if
(
i
%
16
!=
0
)
{
out
<<
std
::
endl
;
}
out
.
flags
(
original_flags
);
return
;
}
//------------------------------------------------------------------------------
static
void
segment_datas
(
std
::
ostream
&
out
,
const
elfio
&
reader
)
{
Elf_Half
n
=
reader
.
segments
.
size
();
if
(
n
==
0
)
{
return
;
}
out
<<
"Segment Data:"
<<
std
::
endl
;
for
(
Elf_Half
i
=
0
;
i
<
n
;
++
i
)
{
// For all sections
segment
*
seg
=
reader
.
segments
[
i
];
segment_data
(
out
,
i
,
seg
);
}
out
<<
std
::
endl
;
}
private
:
private
:
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
examples/elfdump/elfdump.cpp
+
2
−
0
View file @
e8afffec
...
@@ -52,6 +52,8 @@ int main( int argc, char** argv )
...
@@ -52,6 +52,8 @@ int main( int argc, char** argv )
dump
::
symbol_tables
(
std
::
cout
,
reader
);
dump
::
symbol_tables
(
std
::
cout
,
reader
);
dump
::
notes
(
std
::
cout
,
reader
);
dump
::
notes
(
std
::
cout
,
reader
);
dump
::
dynamic_tags
(
std
::
cout
,
reader
);
dump
::
dynamic_tags
(
std
::
cout
,
reader
);
dump
::
section_datas
(
std
::
cout
,
reader
);
dump
::
segment_datas
(
std
::
cout
,
reader
);
return
0
;
return
0
;
}
}
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