mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-01-09 19:35:30 +00:00
Defer adding sections until ELF::Finish in synth_elf
A=Mike Hommey <mh@glandium.org> R=ted at https://breakpad.appspot.com/543002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1135 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
ece9df9386
commit
637c392d1c
|
@ -115,18 +115,22 @@ int ELF::AddSection(const string& name, const Section& section,
|
|||
// sh_entsize
|
||||
.Append(endianness(), addr_size_, entsize);
|
||||
|
||||
sections_.push_back(ElfSection(section, type, offset, offset_label));
|
||||
return index;
|
||||
}
|
||||
|
||||
void ELF::AppendSection(ElfSection §ion) {
|
||||
// NULL and NOBITS sections have no content, so they
|
||||
// don't need to be written to the file.
|
||||
if (type == SHT_NULL) {
|
||||
offset_label = 0;
|
||||
} else if (type == SHT_NOBITS) {
|
||||
offset_label = offset;
|
||||
if (section.type_ == SHT_NULL) {
|
||||
section.offset_label_ = 0;
|
||||
} else if (section.type_ == SHT_NOBITS) {
|
||||
section.offset_label_ = section.offset_;
|
||||
} else {
|
||||
Mark(&offset_label);
|
||||
Mark(§ion.offset_label_);
|
||||
Append(section);
|
||||
Align(4);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void ELF::Finish() {
|
||||
|
@ -136,6 +140,10 @@ void ELF::Finish() {
|
|||
AddSection(".shstrtab", section_header_strings_, SHT_STRTAB);
|
||||
//printf("section_count_: %ld, sections_.size(): %ld\n",
|
||||
// section_count_, sections_.size());
|
||||
for (vector<ElfSection>::iterator it = sections_.begin();
|
||||
it < sections_.end(); ++it) {
|
||||
AppendSection(*it);
|
||||
}
|
||||
section_count_label_ = section_count_;
|
||||
program_count_label_ = program_count_;
|
||||
// TODO: allow adding entries to program header table
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "common/test_assembler.h"
|
||||
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
@ -49,6 +50,7 @@ namespace google_breakpad {
|
|||
namespace synth_elf {
|
||||
|
||||
using std::list;
|
||||
using std::vector;
|
||||
using std::map;
|
||||
using std::pair;
|
||||
using test_assembler::Endianness;
|
||||
|
@ -128,6 +130,23 @@ class ELF : public Section {
|
|||
Label section_header_string_index_;
|
||||
// Section containing the names of section header table entries.
|
||||
StringTable section_header_strings_;
|
||||
|
||||
// Record of an added section
|
||||
struct ElfSection : public Section {
|
||||
ElfSection(const Section& section, uint32_t type, uint32_t offset,
|
||||
Label offset_label)
|
||||
: Section(section), type_(type), offset_(offset)
|
||||
, offset_label_(offset_label) {
|
||||
}
|
||||
|
||||
uint32_t type_;
|
||||
uint32_t offset_;
|
||||
Label offset_label_;
|
||||
};
|
||||
|
||||
vector<ElfSection> sections_;
|
||||
|
||||
void AppendSection(ElfSection §ion);
|
||||
};
|
||||
|
||||
// A class to build .symtab or .dynsym sections.
|
||||
|
|
Loading…
Reference in a new issue