Skip to content

Commit 6395633

Browse files
committed
(elfcpp) remove old elf lib and any reference of it
1 parent 81dd206 commit 6395633

File tree

8 files changed

+1
-521
lines changed

8 files changed

+1
-521
lines changed

CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ set(LYN_SOURCE_LIST
3333
core/binary_file.h
3434
core/binary_file.cpp
3535

36-
elf/raw_elf.h
37-
38-
elf/elf_file.h
39-
elf/elf_file.cpp
40-
4136
ea/event_code.h
4237
ea/event_code.cpp
4338

core/event_object.cpp

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -261,156 +261,6 @@ void event_object::append_from_elf(const char* fileName) {
261261
}
262262
}
263263

264-
void event_object::append_from_elf(const elf_file& elfFile) {
265-
std::vector<section_data> newSections(elfFile.sections().size());
266-
std::vector<bool> outMap(elfFile.sections().size(), false);
267-
268-
auto getLocalSymbolName = [this] (int section, int index) -> std::string {
269-
std::string result;
270-
result.reserve(4 + 8 + 4 + 4);
271-
272-
result.append("_L");
273-
274-
util::append_hex(result, size());
275-
result.append("_");
276-
util::append_hex(result, section);
277-
result.append("_");
278-
util::append_hex(result, index);
279-
280-
return result;
281-
};
282-
283-
auto getGlobalSymbolName = [this] (const char* name) -> std::string {
284-
std::string result(name);
285-
int find = 0;
286-
287-
while ((find = result.find('.')) != std::string::npos)
288-
result[find] = '_';
289-
290-
return result;
291-
};
292-
293-
// Initializing written Sections from relevant elf sections
294-
295-
for (int i=0; i<newSections.size(); ++i) {
296-
auto& elfSection = elfFile.sections()[i];
297-
298-
if ((elfSection.sh_type == elf::SHT_PROGBITS)) {
299-
if ((elfSection.sh_flags & elf::SHF_ALLOC) && !(elfSection.sh_flags & elf::SHF_WRITE)) {
300-
auto& sectionData = newSections[i];
301-
302-
sectionData.set_name(elfFile.get_section_name(elfSection));
303-
outMap[i] = true;
304-
sectionData.load_from_other(elfFile, elfSection.sh_offset, elfSection.sh_size);
305-
}
306-
}
307-
}
308-
309-
// Initializing labels, mappings & relocations from other elf sections
310-
311-
for (int sectionIndex=0; sectionIndex<elfFile.sections().size(); ++sectionIndex) {
312-
auto& elfSection = elfFile.sections()[sectionIndex];
313-
314-
if (elfSection.sh_type == elf::SHT_SYMTAB) {
315-
int symbolCount = elfSection.sh_size / elfSection.sh_entsize;
316-
317-
auto& nameElfSection = elfFile.sections()[elfSection.sh_link];
318-
319-
for (int i=0; i<symbolCount; ++i) {
320-
auto sym = elfFile.symbol(elfSection, i);
321-
322-
if (sym.st_shndx >= newSections.size()) {
323-
if ((sym.st_shndx == elf::SHN_ABS) && (sym.bind() == elf::STB_GLOBAL))
324-
mAbsoluteSymbols.push_back({ elfFile.string(nameElfSection, sym.st_name), sym.st_value, false });
325-
continue;
326-
}
327-
328-
if (!outMap[sym.st_shndx])
329-
continue;
330-
331-
auto& sectionData = newSections[sym.st_shndx];
332-
333-
std::string symbolName = elfFile.string(nameElfSection, sym.st_name);
334-
335-
if (sym.type() == elf::STT_NOTYPE && sym.bind() == elf::STB_LOCAL) {
336-
std::string subString = symbolName.substr(0, 3);
337-
338-
if ((symbolName == "$t") || (subString == "$t.")) {
339-
sectionData.set_mapping(sym.st_value, mapping::Thumb);
340-
continue;
341-
} else if ((symbolName == "$a") || (subString == "$a.")) {
342-
sectionData.set_mapping(sym.st_value, mapping::ARM);
343-
continue;
344-
} else if ((symbolName == "$d") || (subString == "$d.")) {
345-
sectionData.set_mapping(sym.st_value, mapping::Data);
346-
continue;
347-
}
348-
}
349-
350-
if (sym.bind() == elf::STB_LOCAL)
351-
symbolName = getLocalSymbolName(sectionIndex, i);
352-
else
353-
symbolName = getGlobalSymbolName(symbolName.c_str());
354-
355-
sectionData.symbols().push_back({ symbolName, sym.st_value, (sym.bind() == elf::STB_LOCAL) });
356-
}
357-
} else if (elfSection.sh_type == elf::SHT_REL) {
358-
int relCount = elfSection.sh_size / elfSection.sh_entsize;
359-
360-
auto& symbolSection = elfFile.sections()[elfSection.sh_link];
361-
auto& symbolNameSection = elfFile.sections()[symbolSection.sh_link];
362-
363-
auto& sectionData = newSections[elfSection.sh_info];
364-
365-
for (int i=0; i<relCount; ++i) {
366-
auto rel = elfFile.rel(elfSection, i);
367-
auto sym = elfFile.symbol(symbolSection, rel.symId());
368-
std::string name = elfFile.string(symbolNameSection, sym.st_name);
369-
370-
if (sym.bind() == elf::STB_LOCAL)
371-
name = getLocalSymbolName(elfSection.sh_link, rel.symId());
372-
else
373-
name = getGlobalSymbolName(name.c_str());
374-
375-
sectionData.relocations().push_back({ std::string(name), 0, rel.type(), rel.r_offset });
376-
}
377-
} else if (elfSection.sh_type == elf::SHT_RELA) {
378-
int relCount = elfSection.sh_size / elfSection.sh_entsize;
379-
380-
auto& symbolSection = elfFile.sections()[elfSection.sh_link];
381-
auto& symbolNameSection = elfFile.sections()[symbolSection.sh_link];
382-
383-
auto& sectionData = newSections[elfSection.sh_info];
384-
385-
for (int i=0; i<relCount; ++i) {
386-
auto rela = elfFile.rela(elfSection, i);
387-
auto sym = elfFile.symbol(symbolSection, rela.symId());
388-
std::string name = elfFile.string(symbolNameSection, sym.st_name);
389-
390-
if (sym.bind() == elf::STB_LOCAL)
391-
name = getLocalSymbolName(elfSection.sh_link, rela.symId());
392-
else
393-
name = getGlobalSymbolName(name.c_str());
394-
395-
sectionData.relocations().push_back({ std::string(name), rela.r_addend, rela.type(), rela.r_offset });
396-
}
397-
}
398-
}
399-
400-
// Remove empty sections
401-
402-
newSections.erase(std::remove_if(newSections.begin(), newSections.end(), [] (const section_data& sectionData) {
403-
return (sectionData.size()==0);
404-
}), newSections.end());
405-
406-
// Create the ultimate lifeform
407-
408-
for (auto& newSection : newSections) {
409-
combine_with(std::move(newSection));
410-
ensure_aligned(4);
411-
}
412-
}
413-
414264
void event_object::try_transform_relatives() {
415265
section_data trampolineData;
416266

core/event_object.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#include "arm_relocator.h"
55
#include "section_data.h"
66

7-
#include "../elf/elf_file.h"
8-
97
namespace lyn {
108

119
class event_object : public section_data {
@@ -17,7 +15,6 @@ class event_object : public section_data {
1715

1816
public:
1917
void append_from_elf(const char* fName);
20-
void append_from_elf(const lyn::elf_file& elfFile);
2118

2219
void try_transform_relatives();
2320

core/section_data.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
#include "binary_file.h"
55

6-
#include "../elf/elf_file.h"
7-
#include "../ea/event_section.h"
6+
#include "ea/event_section.h"
87

98
namespace lyn {
109

elf/elf_file.cpp

Lines changed: 0 additions & 131 deletions
This file was deleted.

elf/elf_file.h

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)