Generate .eh_frame_hdr section and PT_GNU_EH_FRAME segment.
Fixes issue 20125400 - ART: Need .eh_frame_hdr and PT_GNU_EH_FRAME
for libunwind.
.eh_frame_hdr serves two purposes. Firstly, it can optionally contain
binary search table for fast eh_frame lookup. This is important for
C++ exception handling, but we do not need it so we omit it.
Secondly, it contains a relative .eh_frame pointer which makes it
easier for run-time code to locate the .eh_frame section.
libunwind seems to rely on this relative pointer.
Bug: 20125400
Change-Id: I7c1e3f68d914f70781404c508395831a3296a7da
diff --git a/compiler/dwarf/dwarf_test.h b/compiler/dwarf/dwarf_test.h
index dd5e0c2..cbe700a 100644
--- a/compiler/dwarf/dwarf_test.h
+++ b/compiler/dwarf/dwarf_test.h
@@ -100,30 +100,30 @@
Elf_Sym, Elf_Ehdr, Elf_Phdr, Elf_Shdr> builder(
&code, file.GetFile(), isa, 0, 0, 0, 0, 0, 0, false, false);
typedef ElfRawSectionBuilder<Elf_Word, Elf_Sword, Elf_Shdr> Section;
+ Section debug_info(".debug_info", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
+ Section debug_abbrev(".debug_abbrev", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
+ Section debug_str(".debug_str", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
+ Section debug_line(".debug_line", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
+ Section eh_frame(".eh_frame", SHT_PROGBITS, SHF_ALLOC, nullptr, 0, 4, 0);
if (!debug_info_data_.empty()) {
- Section debug_info(".debug_info", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
debug_info.SetBuffer(debug_info_data_);
- builder.RegisterRawSection(debug_info);
+ builder.RegisterRawSection(&debug_info);
}
if (!debug_abbrev_data_.empty()) {
- Section debug_abbrev(".debug_abbrev", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
debug_abbrev.SetBuffer(debug_abbrev_data_);
- builder.RegisterRawSection(debug_abbrev);
+ builder.RegisterRawSection(&debug_abbrev);
}
if (!debug_str_data_.empty()) {
- Section debug_str(".debug_str", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
debug_str.SetBuffer(debug_str_data_);
- builder.RegisterRawSection(debug_str);
+ builder.RegisterRawSection(&debug_str);
}
if (!debug_line_data_.empty()) {
- Section debug_line(".debug_line", SHT_PROGBITS, 0, nullptr, 0, 1, 0);
debug_line.SetBuffer(debug_line_data_);
- builder.RegisterRawSection(debug_line);
+ builder.RegisterRawSection(&debug_line);
}
if (!eh_frame_data_.empty()) {
- Section eh_frame(".eh_frame", SHT_PROGBITS, SHF_ALLOC, nullptr, 0, 4, 0);
eh_frame.SetBuffer(eh_frame_data_);
- builder.RegisterRawSection(eh_frame);
+ builder.RegisterRawSection(&eh_frame);
}
builder.Init();
builder.Write();