From 5f8802b82faecb77038ea00f96be72632203bae5 Mon Sep 17 00:00:00 2001 From: Teagan Strickland Date: Wed, 18 Mar 2020 10:23:36 +0000 Subject: [PATCH] [vm] Add sizes to ELF static symbols for Code payloads. Change-Id: I7868ec621e08773b7d379e95fe091e820bf29c94 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139807 Reviewed-by: Daco Harkes Commit-Queue: Teagan Strickland --- runtime/vm/dwarf.cc | 3 ++- runtime/vm/elf.cc | 7 ++++--- runtime/vm/elf.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/runtime/vm/dwarf.cc b/runtime/vm/dwarf.cc index be78898f89e..c70ed6ae9be 100644 --- a/runtime/vm/dwarf.cc +++ b/runtime/vm/dwarf.cc @@ -124,7 +124,8 @@ void Dwarf::AddCode(const Code& code, ASSERT(name != nullptr); ASSERT(payload_start >= 0); auto const virtual_address = elf_->NextMemoryOffset() + payload_start; - elf_->AddStaticSymbol(elf_->NextSectionIndex(), name, virtual_address); + elf_->AddStaticSymbol(elf_->NextSectionIndex(), name, virtual_address, + code.Size()); ASSERT(!code.IsNull()); ASSERT(code_to_address_.Lookup(&code) == nullptr); diff --git a/runtime/vm/elf.cc b/runtime/vm/elf.cc index 60e9b6282d2..e3f3bd0677e 100644 --- a/runtime/vm/elf.cc +++ b/runtime/vm/elf.cc @@ -650,7 +650,8 @@ intptr_t Elf::AddText(const char* name, const uint8_t* bytes, intptr_t size) { void Elf::AddStaticSymbol(intptr_t section, const char* name, - size_t memory_offset) { + intptr_t address, + intptr_t size) { // Lazily allocate the static string and symbol tables, as we only add static // symbols in unstripped ELF files. if (strtab_ == nullptr) { @@ -661,8 +662,8 @@ void Elf::AddStaticSymbol(intptr_t section, auto const name_index = strtab_->AddString(name); auto const info = (elf::STB_GLOBAL << 4) | elf::STT_FUNC; - Symbol* symbol = new (zone_) - Symbol(name, name_index, info, section, memory_offset, /*size=*/0); + Symbol* symbol = + new (zone_) Symbol(name, name_index, info, section, address, size); symtab_->AddSymbol(symbol); } diff --git a/runtime/vm/elf.h b/runtime/vm/elf.h index f270dacde84..4cd877a5514 100644 --- a/runtime/vm/elf.h +++ b/runtime/vm/elf.h @@ -33,7 +33,8 @@ class Elf : public ZoneAllocated { void AddDebug(const char* name, const uint8_t* bytes, intptr_t size); void AddStaticSymbol(intptr_t section, const char* name, - size_t memory_offset); + intptr_t address, + intptr_t size); void Finalize();