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
24d29a21
You need to sign in or sign up before continuing.
Commit
24d29a21
authored
3 years ago
by
Serge Lamikhov-Center
Committed by
Serge Lamikhov-Center
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Move constructor and assignment has been implemented
parent
3a76e30a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
elfio/elfio.hpp
+33
-4
33 additions, 4 deletions
elfio/elfio.hpp
tests/ELFIOTest2.cpp
+26
-1
26 additions, 1 deletion
tests/ELFIOTest2.cpp
with
59 additions
and
5 deletions
elfio/elfio.hpp
+
33
−
4
View file @
24d29a21
...
...
@@ -68,19 +68,48 @@ class elfio
{
public:
//------------------------------------------------------------------------------
elfio
()
:
sections
(
this
),
segments
(
this
)
elfio
()
noexcept
:
sections
(
this
),
segments
(
this
)
{
header
=
nullptr
;
current_file_pos
=
0
;
create
(
ELFCLASS32
,
ELFDATA2LSB
);
}
elfio
(
elfio
&&
other
)
noexcept
:
sections
(
this
),
segments
(
this
)
{
header
=
std
::
move
(
other
.
header
);
sections_
=
std
::
move
(
other
.
sections_
);
segments_
=
std
::
move
(
other
.
segments_
);
convertor
=
std
::
move
(
other
.
convertor
);
current_file_pos
=
std
::
move
(
other
.
current_file_pos
);
other
.
header
=
nullptr
;
other
.
sections_
.
clear
();
other
.
segments_
.
clear
();
}
elfio
&
operator
=
(
elfio
&&
other
)
noexcept
{
if
(
this
!=
&
other
)
{
clean
();
header
=
std
::
move
(
other
.
header
);
sections_
=
std
::
move
(
other
.
sections_
);
segments_
=
std
::
move
(
other
.
segments_
);
convertor
=
std
::
move
(
other
.
convertor
);
current_file_pos
=
std
::
move
(
other
.
current_file_pos
);
other
.
header
=
nullptr
;
other
.
sections_
.
clear
();
other
.
segments_
.
clear
();
}
return
*
this
;
}
//------------------------------------------------------------------------------
// clang-format off
elfio
(
const
elfio
&
)
=
delete
;
elfio
&
operator
=
(
const
elfio
&
)
=
delete
;
elfio
(
elfio
&&
)
=
default
;
elfio
&
operator
=
(
elfio
&&
)
=
default
;
// clang-format on
//------------------------------------------------------------------------------
...
...
@@ -779,7 +808,7 @@ class elfio
align
=
1
;
}
Elf64_Off
error
=
current_file_pos
%
align
;
section_align
=
(
align
-
error
)
%
align
;
section_align
=
(
align
-
error
)
%
align
;
}
else
if
(
section_generated
[
index
]
)
{
// Alignment for already generated sections
...
...
This diff is collapsed.
Click to expand it.
tests/ELFIOTest2.cpp
+
26
−
1
View file @
24d29a21
...
...
@@ -399,7 +399,32 @@ BOOST_AUTO_TEST_CASE( gnu_version_64_le )
if
(
verindex
>
1
)
{
Elf64_Addr
value
=
0
;
vern
.
get_entry
(
verindex
*
8
,
value
);
std
::
cout
<<
value
<<
std
::
endl
;
//
std::cout << value << std::endl;
}
}
}
////////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE
(
move_constructor_and_assignment
)
{
elfio
r1
;
// Load ELF data
BOOST_REQUIRE_EQUAL
(
r1
.
load
(
"elf_examples/hello_64"
),
true
);
Elf64_Addr
entry
=
r1
.
get_entry
();
std
::
string
sec_name
=
r1
.
sections
[
".text"
]
->
get_name
();
Elf_Xword
seg_size
=
r1
.
segments
[
1
]
->
get_memory_size
();
// Move to a vector element
std
::
vector
<
elfio
>
v
;
v
.
emplace_back
(
std
::
move
(
r1
)
);
BOOST_CHECK_EQUAL
(
v
[
0
].
get_entry
(),
entry
);
BOOST_CHECK_EQUAL
(
v
[
0
].
sections
[
".text"
]
->
get_name
(),
sec_name
);
BOOST_CHECK_EQUAL
(
v
[
0
].
segments
[
1
]
->
get_memory_size
(),
seg_size
);
elfio
r2
;
r2
=
std
::
move
(
v
[
0
]
);
BOOST_CHECK_EQUAL
(
r2
.
get_entry
(),
entry
);
BOOST_CHECK_EQUAL
(
r2
.
sections
[
".text"
]
->
get_name
(),
sec_name
);
BOOST_CHECK_EQUAL
(
r2
.
segments
[
1
]
->
get_memory_size
(),
seg_size
);
}
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