summaryrefslogtreecommitdiffstats
path: root/compiler/elf_writer_quick.h
diff options
context:
space:
mode:
authorYevgeny Rouban <yevgeny.y.rouban@intel.com>2014-08-08 16:29:38 +0700
committerTong Shen <endlessroad@google.com>2014-08-15 15:04:12 -0700
commite3ea83811d47152c00abea24a9b420651a33b496 (patch)
treedd3b8018176ada85d51b2f8ca46e515fbf55b50f /compiler/elf_writer_quick.h
parent9dcf75c80187504ec88e7ef91d64a6a68279eb9d (diff)
downloadandroid_art-e3ea83811d47152c00abea24a9b420651a33b496.tar.gz
android_art-e3ea83811d47152c00abea24a9b420651a33b496.tar.bz2
android_art-e3ea83811d47152c00abea24a9b420651a33b496.zip
ART source line debug info in OAT files
OAT files have source line information enough for ART runtime needs like jump to/from interpreter and thread suspension. But this information is not enough for finer grained source level debugging and low-level profiling (VTune or perf). This patch adds to OAT files two additional sections: .debug_line - DWARF formatted Elf32 section with detailed source line information (mapping from native PC to Java source lines). In addition to the debugging symbols added using the dex2oat option --include-debug-symbols, the source line information is added to the section .debug_line. The source line info can be read by many Elf reading tools like objdump, readelf, dwarfdump, gdb, perf, VTune, ... gdb can use this debug line information in x86. In 64-bit mode the information can be used if the oat file is mapped in the lower address space (address has higher 32 bits zeroed). Relocation works. Testing: 1. art/test/run-test --host --gdb [--64] 001-HelloWorld 2. in gdb: break Main.java:19 3. in gdb: break Runtime.java:111 4. in gdb: run - stops at void java.lang.Runtime.<init>() 5. in gdb: backtrace - shows call stack down to main() 6. in gdb: continue - stops at void Main.main() (only in 32-bit mode) 7. in gdb: backtrace - shows call stack down to main() 8. objdump -W <oat-file> - addresses are from VMA range of .text section reported by objdump -h <file> 9. dwarfdump -ka <oat-file> - no errors expected Size of aosp-x86-eng boot.oat increased by 11% from 80.5Mb to 89.2Mb with two sections added .debug_line (7.2Mb) and .rel.debug (1.5Mb). Change-Id: Ib8828832686e49782a63d5529008ff4814ed9cda Signed-off-by: Yevgeny Rouban <yevgeny.y.rouban@intel.com>
Diffstat (limited to 'compiler/elf_writer_quick.h')
-rw-r--r--compiler/elf_writer_quick.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/compiler/elf_writer_quick.h b/compiler/elf_writer_quick.h
index 8cfe550495..c7ef872174 100644
--- a/compiler/elf_writer_quick.h
+++ b/compiler/elf_writer_quick.h
@@ -48,7 +48,7 @@ class ElfWriterQuick FINAL : public ElfWriter {
~ElfWriterQuick() {}
class ElfBuilder;
- void WriteDebugSymbols(ElfBuilder& builder, OatWriter* oat_writer);
+ void WriteDebugSymbols(ElfBuilder* builder, OatWriter* oat_writer);
void ReservePatchSpace(std::vector<uint8_t>* buffer, bool debug);
class ElfSectionBuilder {
@@ -237,6 +237,7 @@ class ElfWriterQuick FINAL : public ElfWriter {
}
~ElfBuilder() {}
+ bool Init();
bool Write();
// Adds the given raw section to the builder. This will copy it. The caller
@@ -253,8 +254,29 @@ class ElfWriterQuick FINAL : public ElfWriter {
bool fatal_error_ = false;
+ // What phdr is.
+ static const uint32_t PHDR_OFFSET = sizeof(Elf32_Ehdr);
+ enum : uint8_t {
+ PH_PHDR = 0,
+ PH_LOAD_R__ = 1,
+ PH_LOAD_R_X = 2,
+ PH_LOAD_RW_ = 3,
+ PH_DYNAMIC = 4,
+ PH_NUM = 5,
+ };
+ static const uint32_t PHDR_SIZE = sizeof(Elf32_Phdr) * PH_NUM;
+ Elf32_Phdr program_headers_[PH_NUM];
+
Elf32_Ehdr elf_header_;
+ Elf32_Shdr null_hdr_;
+ std::string shstrtab_;
+ uint32_t section_index_;
+ std::string dynstr_;
+ uint32_t dynstr_soname_offset_;
+ std::vector<Elf32_Shdr*> section_ptrs_;
+ std::vector<Elf32_Word> hash_;
+
public:
ElfOatSectionBuilder text_builder_;
ElfOatSectionBuilder rodata_builder_;
@@ -316,7 +338,8 @@ class ElfWriterQuick FINAL : public ElfWriter {
* @param dbg_str Debug strings.
*/
void FillInCFIInformation(OatWriter* oat_writer, std::vector<uint8_t>* dbg_info,
- std::vector<uint8_t>* dbg_abbrev, std::vector<uint8_t>* dbg_str);
+ std::vector<uint8_t>* dbg_abbrev, std::vector<uint8_t>* dbg_str,
+ std::vector<uint8_t>* dbg_line, uint32_t text_section_offset);
DISALLOW_IMPLICIT_CONSTRUCTORS(ElfWriterQuick);
};