mirror of
https://github.com/serge1/ELFIO.git
synced 2024-11-19 11:14:46 +00:00
Implement swap_symbols() for relocation section.
The function can be used as a callback for arrange_local_symbols()
This commit is contained in:
parent
f3bde175a1
commit
fe17eb40aa
3
.vscode/c_cpp_properties.json
vendored
3
.vscode/c_cpp_properties.json
vendored
@ -9,8 +9,7 @@
|
||||
"compilerPath": "/usr/bin/g++",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"configurationProvider": "ms-vscode.cmake-tools"
|
||||
"intelliSenseMode": "clang-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
|
@ -306,6 +306,28 @@ class relocation_section_accessor_template
|
||||
add_entry( offset, sym_index, type );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
swap_symbols(Elf_Xword first, Elf_Xword second)
|
||||
{
|
||||
Elf64_Addr offset;
|
||||
Elf_Word symbol;
|
||||
Elf_Word rtype;
|
||||
Elf_Sxword addend;
|
||||
for (Elf_Word i = 0; i < get_entries_num(); i++)
|
||||
{
|
||||
get_entry(i, offset, symbol, rtype, addend);
|
||||
if (symbol == first)
|
||||
{
|
||||
set_entry(i, offset, (Elf_Word)second, rtype, addend);
|
||||
}
|
||||
if (symbol == second)
|
||||
{
|
||||
set_entry(i, offset, (Elf_Word)first, rtype, addend);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
private:
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -812,20 +812,24 @@ BOOST_AUTO_TEST_CASE(rearrange_local_symbols_with_reallocation)
|
||||
before.push_back(name);
|
||||
}
|
||||
|
||||
// symbols.arrange_local_symbols([&](Elf_Xword first, Elf_Xword second) -> void {
|
||||
// Elf64_Addr offset;
|
||||
// Elf_Word symbol;
|
||||
// Elf_Word rtype;
|
||||
// Elf_Sxword addend;
|
||||
// for (Elf_Word i = 0; i < rela.get_entries_num(); i++) {
|
||||
// rela.get_entry(i, offset, symbol, rtype, addend);
|
||||
// if (symbol == first) {
|
||||
// rela.set_entry(i, offset, (Elf_Word)second, rtype, addend);
|
||||
// }
|
||||
// if (symbol == second) {
|
||||
// rela.set_entry(i, offset, (Elf_Word)first, rtype, addend);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
symbols.arrange_local_symbols([&](Elf_Xword first, Elf_Xword second) -> void {
|
||||
Elf64_Addr offset;
|
||||
Elf_Word symbol;
|
||||
Elf_Word rtype;
|
||||
Elf_Sxword addend;
|
||||
for (Elf_Word i = 0; i < rela.get_entries_num(); i++) {
|
||||
rela.get_entry(i, offset, symbol, rtype, addend);
|
||||
if (symbol == first) {
|
||||
rela.set_entry(i, offset, (Elf_Word)second, rtype, addend);
|
||||
}
|
||||
if (symbol == second) {
|
||||
rela.set_entry(i, offset, (Elf_Word)first, rtype, addend);
|
||||
}
|
||||
}
|
||||
rela.swap_symbols(first, second);
|
||||
});
|
||||
|
||||
BOOST_REQUIRE_EQUAL(writer.save(file_name), true);
|
||||
|
Loading…
Reference in New Issue
Block a user