Skip to content

Commit

Permalink
Rename 'sizeof_section_header' to 'section_header_size' (ELF's header)
Browse files Browse the repository at this point in the history
API changes:
  [C]      Elf_Header_t.sizeof_section_header -> Elf_Header_t.section_header_size
  [C++]    LIEF::ELF::Header::sizeof_section_header -> LIEF::ELF::Header::section_header_size
  [Python] lief.ELF.sizeof_section_header -> lief.ELF.section_header_size

Resolve #62
  • Loading branch information
romainthomas committed Jul 24, 2017
1 parent 9391238 commit d96971b
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion api/c/ELF/Binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int elf_binary_save_header(Elf_Binary_t* binary) {
hdr.header_size(binary->header.header_size);
hdr.program_header_size(binary->header.program_header_size);
hdr.numberof_segments(binary->header.numberof_segments);
hdr.sizeof_section_header(binary->header.sizeof_section_header);
hdr.section_header_size(binary->header.section_header_size);
hdr.numberof_sections(binary->header.numberof_sections);
hdr.section_name_table_idx(binary->header.name_string_table_idx);
hdr.entrypoint(binary->header.entrypoint);
Expand Down
2 changes: 1 addition & 1 deletion api/c/ELF/Header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void init_c_header(Elf_Binary_t* c_binary, Binary* binary) {
c_binary->header.header_size = hdr.header_size();
c_binary->header.program_header_size = hdr.program_header_size();
c_binary->header.numberof_segments = hdr.numberof_segments();
c_binary->header.sizeof_section_header = hdr.sizeof_section_header();
c_binary->header.section_header_size = hdr.section_header_size();
c_binary->header.numberof_sections = hdr.numberof_sections();
c_binary->header.name_string_table_idx = hdr.section_name_table_idx();
c_binary->header.entrypoint = hdr.entrypoint();
Expand Down
2 changes: 1 addition & 1 deletion api/c/include/LIEF/ELF/Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct Elf_Header_t {
uint32_t header_size;
uint32_t program_header_size;
uint32_t numberof_segments;
uint32_t sizeof_section_header;
uint32_t section_header_size;
uint32_t numberof_sections;
uint32_t name_string_table_idx;
};
Expand Down
8 changes: 4 additions & 4 deletions api/python/ELF/objects/pyHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ void init_ELF_Header_class(py::module& m) {
static_cast<setter_t<uint32_t>>(&Header::numberof_segments),
"Return the number of program headers (segments)")

.def_property("sizeof_section_header",
static_cast<getter_t<uint32_t>>(&Header::sizeof_section_header),
static_cast<setter_t<uint32_t>>(&Header::sizeof_section_header),
"Return the size of an section header entry")
.def_property("section_header_size",
static_cast<getter_t<uint32_t>>(&Header::section_header_size),
static_cast<setter_t<uint32_t>>(&Header::section_header_size),
"Return the size of a section header entry")

.def_property("numberof_sections",
static_cast<getter_t<uint32_t>>(&Header::numberof_sections),
Expand Down
3 changes: 1 addition & 2 deletions examples/c/elf_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ int main(int argc, char **argv) {
fprintf(stdout, "Header Size: %x\n", header.header_size);
fprintf(stdout, "Program header size: %x\n", header.program_header_size);
fprintf(stdout, "Nb segments: %d\n", header.numberof_segments);
fprintf(stdout, "Section header size: %x\n", header.sizeof_section_header);
fprintf(stdout, "Section header size: %x\n", header.sizeof_section_header);
fprintf(stdout, "Section header size: %x\n", header.section_header_size);
fprintf(stdout, "Nb sections: %d\n", header.numberof_sections);
fprintf(stdout, "Name string table idx: %d\n", header.name_string_table_idx);

Expand Down
1 change: 1 addition & 0 deletions examples/python/elf_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def print_header(binary):
print(format_hex.format("Processor flags:", header.processor_flag))
print(format_dec.format("Header Size:", header.header_size))
print(format_dec.format("Program Header Size:", header.program_header_size))
print(format_dec.format("Section Header Size:", header.section_header_size))
print(format_dec.format("Number of segments:", header.numberof_segments))
print(format_dec.format("Number of sections:", header.numberof_sections))
print("")
Expand Down
4 changes: 2 additions & 2 deletions include/LIEF/ELF/Header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class DLL_PUBLIC Header : public Visitable {
//!
//! This size should be 64 for a ``ELF64`` binary and 40 for
//! a ``ELF32`` one.
uint32_t sizeof_section_header(void) const;
uint32_t section_header_size(void) const;

//! @brief Return the the number of sections's headers
//! registred in the header
Expand Down Expand Up @@ -125,7 +125,7 @@ class DLL_PUBLIC Header : public Visitable {
void header_size(uint32_t headerSize);
void program_header_size(uint32_t programHeaderSize);
void numberof_segments(uint32_t n);
void sizeof_section_header(uint32_t sizeOfSectionHeaderEntries);
void section_header_size(uint32_t sizeOfSectionHeaderEntries);
void numberof_sections(uint32_t n);
void section_name_table_idx(uint32_t sectionNameStringTableIdx);
void identity(const std::string& identity);
Expand Down
2 changes: 1 addition & 1 deletion src/ELF/Builder.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void Builder::build_header(void) {
ehdr.e_ehsize = static_cast<Elf_Half>(header.header_size());
ehdr.e_phentsize = static_cast<Elf_Half>(header.program_header_size());
ehdr.e_phnum = static_cast<Elf_Half>(header.numberof_segments());
ehdr.e_shentsize = static_cast<Elf_Half>(header.sizeof_section_header());
ehdr.e_shentsize = static_cast<Elf_Half>(header.section_header_size());
ehdr.e_shnum = static_cast<Elf_Half>(header.numberof_sections());
ehdr.e_shstrndx = static_cast<Elf_Half>(header.section_name_table_idx());

Expand Down
12 changes: 5 additions & 7 deletions src/ELF/Header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,10 @@ uint32_t Header::numberof_segments(void) const {
return this->numberof_segments_;
}

//! @todo rename
uint32_t Header::sizeof_section_header(void) const {
uint32_t Header::section_header_size(void) const {
return this->sizeOfSectionHeaderEntries_;
}


uint32_t Header::numberof_sections(void) const {
return this->numberof_sections_;
}
Expand Down Expand Up @@ -294,7 +292,7 @@ void Header::numberof_segments(uint32_t n) {
}


void Header::sizeof_section_header(uint32_t sizeOfSectionHeaderEntries) {
void Header::section_header_size(uint32_t sizeOfSectionHeaderEntries) {
this->sizeOfSectionHeaderEntries_ = sizeOfSectionHeaderEntries;
}

Expand Down Expand Up @@ -352,7 +350,7 @@ void Header::accept(LIEF::Visitor& visitor) const {
visitor.visit(this->header_size());
visitor.visit(this->program_header_size());
visitor.visit(this->numberof_segments());
visitor.visit(this->sizeof_section_header());
visitor.visit(this->section_header_size());
visitor.visit(this->section_name_table_idx());
visitor.visit(this->identity_class());
visitor.visit(this->identity_data());
Expand Down Expand Up @@ -397,9 +395,9 @@ std::ostream& operator<<(std::ostream& os, const Header& hdr)
os << std::setw(33) << std::setfill(' ') << "Section header offset:" << hdr.section_headers_offset() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Processor Flag" << hdr.processor_flag() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Header size:" << hdr.header_size() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Program header size:" << hdr.program_header_size() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Size of program header :" << hdr.program_header_size() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Number of program header:" << hdr.numberof_segments() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Size of section header:" << hdr.sizeof_section_header() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Size of section header:" << hdr.section_header_size() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Number of section headers:" << hdr.numberof_sections() << std::endl;
os << std::setw(33) << std::setfill(' ') << "Section Name Table idx:" << hdr.section_name_table_idx() << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion src/visitors/elf_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void JsonVisitor::visit(const Header& header) {
this->node_["header_size"] = header.header_size();
this->node_["program_header_size"] = header.program_header_size();
this->node_["processornumberof_segments_flag"] = header.numberof_segments();
this->node_["sizeof_section_header"] = header.sizeof_section_header();
this->node_["section_header_size"] = header.section_header_size();
this->node_["numberof_sections"] = header.numberof_sections();
this->node_["section_name_table_idx"] = header.section_name_table_idx();
this->node_["identity_class"] = to_string(header.identity_class());
Expand Down

0 comments on commit d96971b

Please sign in to comment.