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
6d60be2d
Commit
6d60be2d
authored
12 years ago
by
Serge Lamikhov-Center
Browse files
Options
Downloads
Patches
Plain Diff
A test program added; str_elf_class output implemented
parent
daa8c81b
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
+97
-0
97 additions, 0 deletions
elfio/elfio_dump.hpp
elfio/elfio_dump_test.cpp
+27
-0
27 additions, 0 deletions
elfio/elfio_dump_test.cpp
with
124 additions
and
0 deletions
elfio/elfio_dump.hpp
+
97
−
0
View file @
6d60be2d
/*
Copyright (C) 2001-2011 by Serge Lamikhov-Center
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef ELFIO_DUMP_HPP
#define ELFIO_DUMP_HPP
#include
<string>
#include
<ostream>
#include
<elfio.hpp>
namespace
ELFIO
{
//------------------------------------------------------------------------------
class
dump
{
public:
//------------------------------------------------------------------------------
static
void
header
(
std
::
ostream
&
out
,
elfio
&
reader
)
{
out
<<
"ELF Header
\n
"
<<
std
::
endl
;
out
<<
" Class: "
<<
str_elf_class
(
reader
.
get_class
()
)
<<
"("
<<
(
int
)
reader
.
get_class
()
<<
")"
<<
std
::
endl
;
out
<<
" Encoding: "
<<
(
(
ELFDATA2LSB
==
reader
.
get_encoding
()
)
?
"Little endian"
:
""
)
<<
(
(
ELFDATA2MSB
==
reader
.
get_encoding
()
)
?
"Big endian"
:
""
)
<<
(
(
(
ELFDATA2LSB
!=
reader
.
get_encoding
()
)
&&
(
ELFDATA2MSB
!=
reader
.
get_encoding
()
)
)
?
"Unknown"
:
""
)
<<
std
::
endl
;
out
<<
" ELFVersion: "
<<
(
(
EV_CURRENT
==
reader
.
get_elf_version
()
)
?
"Current"
:
"Unknown"
)
<<
"("
<<
(
int
)
reader
.
get_elf_version
()
<<
")"
<<
std
::
endl
;
out
<<
" Type: "
<<
std
::
hex
<<
reader
.
get_type
()
<<
std
::
endl
;
out
<<
" Machine: "
<<
std
::
hex
<<
reader
.
get_machine
()
<<
std
::
endl
;
out
<<
" Version: "
<<
std
::
hex
<<
reader
.
get_version
()
<<
std
::
endl
;
out
<<
" Entry: "
<<
std
::
hex
<<
reader
.
get_entry
()
<<
std
::
endl
;
out
<<
" Flags: "
<<
std
::
hex
<<
reader
.
get_flags
()
<<
std
::
endl
;
}
//------------------------------------------------------------------------------
static
std
::
string
str_section_type
(
Elf_Word
type
)
{
}
static
std
::
string
str_elf_class
(
Elf_Word
type
)
{
struct
convert
{
Elf_Word
type
;
const
char
*
str
;
};
convert
converts
[]
=
{
{
ELFCLASS32
,
"ELF32"
},
{
ELFCLASS64
,
"ELF64"
},
};
std
::
string
res
=
"UNKNOWN"
;
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
converts
)
/
sizeof
(
convert
);
++
i
)
{
if
(
converts
[
i
].
type
==
type
)
{
res
=
converts
[
i
].
str
;
break
;
}
}
return
res
;
}
};
}
// namespace ELFIO
#endif // ELFIO_DUMP_HPP
This diff is collapsed.
Click to expand it.
elfio/elfio_dump_test.cpp
0 → 100644
+
27
−
0
View file @
6d60be2d
#include
<iostream>
#include
<elfio_dump.hpp>
using
namespace
ELFIO
;
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
2
)
{
printf
(
"Usage: ELFDump <file_name>
\n
"
);
return
1
;
}
// Open ELF reader
elfio
reader
;
if
(
!
reader
.
load
(
argv
[
1
]
)
)
{
printf
(
"File %s is not found or it is not an ELF file
\n
"
,
argv
[
1
]
);
return
1
;
}
// Print ELF file header
dump
::
header
(
std
::
cout
,
reader
);
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