summaryrefslogtreecommitdiffstats
path: root/compiler/elf_writer_quick.cc
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2014-06-18 10:35:45 -0700
committerBrian Carlstrom <bdc@google.com>2014-06-27 16:46:29 -0700
commit3470ab4011b5e18d590d5375e2f13a1e3bd69222 (patch)
tree79efa1be55a16a43447f7373f0aa8722828204d5 /compiler/elf_writer_quick.cc
parentbaa1323d66a05fd2d7b9c6c131b232945b0a4ebb (diff)
downloadart-3470ab4011b5e18d590d5375e2f13a1e3bd69222.zip
art-3470ab4011b5e18d590d5375e2f13a1e3bd69222.tar.gz
art-3470ab4011b5e18d590d5375e2f13a1e3bd69222.tar.bz2
Fixed gdb support and added some ElfFile functions
Fixed gdb support so that it would continue working even when debug symbols or other sections are included in the elf file. Also made it actually read parts of the DWARF information so it should work even if there are minor changes to how and where DWARF information is written out. Added a dwarf.h file with the dwarf constants. Added a FindSectionByName function, a FindDynamicSymbol function, and the ability to specify the mmap protection and flags directly if we are mapping in the whole file. Modified elf_writer_quick.cc to use the dwarf constants from dwarf.h. Change-Id: I09e15c425fab252b331a2e4719863552e8b6b137
Diffstat (limited to 'compiler/elf_writer_quick.cc')
-rw-r--r--compiler/elf_writer_quick.cc42
1 files changed, 9 insertions, 33 deletions
diff --git a/compiler/elf_writer_quick.cc b/compiler/elf_writer_quick.cc
index 78757ec..e4dcaa7 100644
--- a/compiler/elf_writer_quick.cc
+++ b/compiler/elf_writer_quick.cc
@@ -20,6 +20,7 @@
#include "base/unix_file/fd_file.h"
#include "buffered_output_stream.h"
#include "driver/compiler_driver.h"
+#include "dwarf.h"
#include "elf_utils.h"
#include "file_output_stream.h"
#include "globals.h"
@@ -469,9 +470,9 @@ bool ElfWriterQuick::ElfBuilder::Write() {
pieces.push_back(ElfFilePiece(".hash", hash_builder_.section_.sh_offset,
hash.data(), hash.size() * sizeof(Elf32_Word)));
pieces.push_back(ElfFilePiece(".rodata", rodata_builder_.section_.sh_offset,
- NULL, rodata_builder_.section_.sh_size));
+ nullptr, rodata_builder_.section_.sh_size));
pieces.push_back(ElfFilePiece(".text", text_builder_.section_.sh_offset,
- NULL, text_builder_.section_.sh_size));
+ nullptr, text_builder_.section_.sh_size));
if (IncludingDebugSymbols()) {
pieces.push_back(ElfFilePiece(".symtab", symtab_builder_.section_.sh_offset,
symtab.data(), symtab.size() * sizeof(Elf32_Sym)));
@@ -547,7 +548,7 @@ void ElfWriterQuick::ElfDynamicBuilder::AddDynamicTag(Elf32_Sword tag, Elf32_Wor
if (tag == DT_NULL) {
return;
}
- dynamics_.push_back({NULL, tag, d_un});
+ dynamics_.push_back({nullptr, tag, d_un});
}
void ElfWriterQuick::ElfDynamicBuilder::AddDynamicTag(Elf32_Sword tag, Elf32_Word d_un,
@@ -650,7 +651,7 @@ std::vector<Elf32_Word> ElfWriterQuick::ElfSymtabBuilder::GenerateHashContents()
// Lets say the state is something like this.
// +--------+ +--------+ +-----------+
// | symtab | | bucket | | chain |
- // | NULL | | 1 | | STN_UNDEF |
+ // | nullptr | | 1 | | STN_UNDEF |
// | <sym1> | | 4 | | 2 |
// | <sym2> | | | | 5 |
// | <sym3> | | | | STN_UNDEF |
@@ -821,10 +822,10 @@ bool ElfWriterQuick::Write(OatWriter* oat_writer,
bool generateDebugInformation = compiler_driver_->GetCallFrameInformation() != nullptr;
if (generateDebugInformation) {
- ElfRawSectionBuilder debug_info(".debug_info", SHT_PROGBITS, 0, NULL, 0, 1, 0);
- ElfRawSectionBuilder debug_abbrev(".debug_abbrev", SHT_PROGBITS, 0, NULL, 0, 1, 0);
- ElfRawSectionBuilder debug_str(".debug_str", SHT_PROGBITS, 0, NULL, 0, 1, 0);
- ElfRawSectionBuilder debug_frame(".debug_frame", SHT_PROGBITS, 0, NULL, 0, 4, 0);
+ ElfRawSectionBuilder debug_info(".debug_info", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
+ ElfRawSectionBuilder debug_abbrev(".debug_abbrev", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
+ ElfRawSectionBuilder debug_str(".debug_str", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
+ ElfRawSectionBuilder debug_frame(".debug_frame", SHT_PROGBITS, 0, nullptr, 0, 4, 0);
debug_frame.SetBuffer(*compiler_driver_->GetCallFrameInformation());
FillInCFIInformation(oat_writer, debug_info.GetBuffer(),
@@ -866,31 +867,6 @@ static void PushHalf(std::vector<uint8_t>*buf, int data) {
buf->push_back((data >> 8) & 0xff);
}
-// DWARF constants needed to generate CFI information.
-enum {
- // Tag encodings.
- DW_TAG_compile_unit = 0x11,
- DW_TAG_subprogram = 0X2e,
-
- // Attribute encodings.
- DW_AT_name = 0x03,
- DW_AT_low_pc = 0x11,
- DW_AT_high_pc = 0x12,
- DW_AT_language = 0x13,
-
- // Constant encoding.
- DW_CHILDREN_no = 0x00,
- DW_CHILDREN_yes = 0x01,
-
- // Attribute form encodings.
- DW_FORM_addr = 0x01,
- DW_FORM_data1 = 0x0b,
- DW_FORM_strp = 0x0e,
-
- // Language encoding.
- DW_LANG_Java = 0x000b
-};
-
void ElfWriterQuick::FillInCFIInformation(OatWriter* oat_writer,
std::vector<uint8_t>* dbg_info,
std::vector<uint8_t>* dbg_abbrev,