summaryrefslogtreecommitdiffstats
path: root/courgette/disassembler_elf_32_x86.h
diff options
context:
space:
mode:
authorcsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 23:26:37 +0000
committercsilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-07 23:26:37 +0000
commitf9e11f6d768d37ca829c2b84f34886ca21109990 (patch)
tree8a155f171684ea973343b77fa990e6cce40cc648 /courgette/disassembler_elf_32_x86.h
parent31cee2c4aa51b30ed1cf9f970bc2caa6b86575c6 (diff)
downloadchromium_src-f9e11f6d768d37ca829c2b84f34886ca21109990.zip
chromium_src-f9e11f6d768d37ca829c2b84f34886ca21109990.tar.gz
chromium_src-f9e11f6d768d37ca829c2b84f34886ca21109990.tar.bz2
Revert 108929 - Add Elf 32 Support to Courgette.
This change takes advantage of recent refactoring and adds support for Elf X86 32 executables to courgette. It should have no effect on handling of Windows PE executables. We have planned ahead to be able to restrict the code size of the courgette library in different cases to reduce patcher sizes, but this change does not yet take advantage of that (all platforms are supported everywhere). Also, the patcher class currently contains a very small amount of Elf/PE specific code for recreating relocation tables that cannot (currently) be compiled out. BUG=chromium-os:22149 TEST=Please verify that Chrome/Chromium patches can still be generated and work. Also, please see how much the updater executable which is downloaded to users has changed in size since R16. Review URL: http://codereview.chromium.org/8428009 TBR=dgarrett@chromium.org Review URL: http://codereview.chromium.org/8490023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/disassembler_elf_32_x86.h')
-rw-r--r--courgette/disassembler_elf_32_x86.h143
1 files changed, 0 insertions, 143 deletions
diff --git a/courgette/disassembler_elf_32_x86.h b/courgette/disassembler_elf_32_x86.h
deleted file mode 100644
index c797a8b..0000000
--- a/courgette/disassembler_elf_32_x86.h
+++ /dev/null
@@ -1,143 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COURGETTE_DISASSEMBLER_ELF_32_X86_H_
-#define COURGETTE_DISASSEMBLER_ELF_32_X86_H_
-
-#include "base/basictypes.h"
-#include "courgette/disassembler.h"
-#include "courgette/memory_allocator.h"
-#include "courgette/types_elf.h"
-
-namespace courgette {
-
-class AssemblyProgram;
-
-class DisassemblerElf32X86 : public Disassembler {
- public:
- explicit DisassemblerElf32X86(const void* start, size_t length);
-
- virtual ExecutableType kind() { return EXE_ELF_32_X86; }
-
- // Returns 'true' if the buffer appears to point to a valid ELF executable
- // for X86 32 bitWindows 32 bit. If ParseHeader() succeeds, other member
- // functions may be called.
- virtual bool ParseHeader();
-
- virtual bool Disassemble(AssemblyProgram* target);
-
- // Public for unittests only
- std::vector<RVA> &Abs32Locations() { return abs32_locations_; }
- std::vector<RVA> &Rel32Locations() { return rel32_locations_; }
-
- protected:
-
- uint32 DiscoverLength();
-
- // Misc Section Helpers
-
- const Elf32_Half SectionHeaderCount() const {
- return section_header_table_size_;
- }
-
- const Elf32_Shdr *SectionHeader(int id) const {
- assert(id >= 0 && id < SectionHeaderCount());
- return section_header_table_ + id;
- }
-
- const uint8 *SectionBody(int id) const {
- return OffsetToPointer(SectionHeader(id)->sh_offset);
- }
-
- const Elf32_Word SectionBodySize(int id) const {
- return SectionHeader(id)->sh_size;
- }
-
- // Misc Segment Helpers
-
- const Elf32_Half ProgramSegmentHeaderCount() const {
- return program_header_table_size_;
- }
-
- const Elf32_Phdr *ProgramSegmentHeader(int id) const {
- assert(id >= 0 && id < ProgramSegmentHeaderCount());
- return program_header_table_ + id;
- }
-
- // The virtual memory address at which this program segment will be loaded
- const Elf32_Addr ProgramSegmentMemoryBegin(int id) const {
- return ProgramSegmentHeader(id)->p_vaddr;
- }
-
- // The number of virtual memory bytes for this program segment
- const Elf32_Word ProgramSegmentMemorySize(int id) const {
- return ProgramSegmentHeader(id)->p_memsz;
- }
-
- // Pointer into the source file for this program segment
- const Elf32_Addr ProgramSegmentFileOffset(int id) const {
- return ProgramSegmentHeader(id)->p_offset;
- }
-
- // Number of file bytes for this program segment. Is <= ProgramMemorySize.
- const Elf32_Word ProgramSegmentFileSize(int id) const {
- return ProgramSegmentHeader(id)->p_filesz;
- }
-
- // Misc address space helpers
-
- CheckBool IsValidRVA(RVA rva) const WARN_UNUSED_RESULT;
-
- // Convert an ELF relocation struction into an RVA
- CheckBool RelToRVA(Elf32_Rel rel, RVA* result) const WARN_UNUSED_RESULT;
-
- // Returns kNoOffset if there is no file offset corresponding to 'rva'.
- CheckBool RVAToFileOffset(RVA rva, size_t* result) const WARN_UNUSED_RESULT;
-
- RVA FileOffsetToRVA(size_t offset) const WARN_UNUSED_RESULT;
-
- CheckBool RVAsToOffsets(std::vector<RVA>* rvas /*in*/,
- std::vector<size_t>* offsets /*out*/);
-
- // Parsing Code used to really implement Disassemble
-
- CheckBool ParseFile(AssemblyProgram* target) WARN_UNUSED_RESULT;
- CheckBool ParseRelocationSection(
- const Elf32_Shdr *section_header,
- AssemblyProgram* program) WARN_UNUSED_RESULT;
- CheckBool ParseProgbitsSection(
- const Elf32_Shdr *section_header,
- std::vector<size_t>::iterator* current_abs_offset,
- std::vector<size_t>::iterator end_abs_offset,
- std::vector<size_t>::iterator* current_rel_offset,
- std::vector<size_t>::iterator end_rel_offset,
- AssemblyProgram* program) WARN_UNUSED_RESULT;
- CheckBool ParseSimpleRegion(size_t start_file_offset,
- size_t end_file_offset,
- AssemblyProgram* program) WARN_UNUSED_RESULT;
-
- CheckBool ParseAbs32Relocs() WARN_UNUSED_RESULT;
- CheckBool ParseRel32RelocsFromSections() WARN_UNUSED_RESULT;
- CheckBool ParseRel32RelocsFromSection(
- const Elf32_Shdr* section) WARN_UNUSED_RESULT;
-
- Elf32_Ehdr *header_;
- Elf32_Shdr *section_header_table_;
- Elf32_Half section_header_table_size_;
-
- Elf32_Phdr *program_header_table_;
- Elf32_Half program_header_table_size_;
-
- // Section header for default
- const char *default_string_section_;
-
- std::vector<RVA> abs32_locations_;
- std::vector<RVA> rel32_locations_;
-
- DISALLOW_COPY_AND_ASSIGN(DisassemblerElf32X86);
-};
-
-} // namespace courgette
-
-#endif // COURGETTE_DISASSEMBLER_ELF_32_X86_H_