[vm/elf] Fix .eh_frame encoding

When FDE refers to CIE it needs to use the offset to CIE start
not CIE's payload start.

TEST=manually

Change-Id: Ic0661e882ab9284d34f5768070d05f9dad440dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206362
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
This commit is contained in:
Vyacheslav Egorov 2021-07-09 13:48:25 +00:00 committed by commit-bot@chromium.org
parent 1b3b8f8a84
commit 6d503a7c13
3 changed files with 10 additions and 7 deletions

View file

@ -246,7 +246,7 @@ class DwarfWriteStream : public ValueObject {
// Prefixes the content added by body with its length. Returns an
// appropriately encoded representation of the start of the content added by
// the body (_not_ the start of the prefixed length).
// the body (including the length prefix).
//
// symbol_prefix is used when a local symbol is created for the length.
virtual EncodedPosition WritePrefixedLength(const char* symbol_prefix,

View file

@ -1074,7 +1074,7 @@ class DwarfElfStream : public DwarfWriteStream {
stream_->SetPosition(fixup);
u4(end - start);
stream_->SetPosition(end);
return EncodedPosition(start);
return EncodedPosition(fixup);
}
// Shorthand for when working directly with DwarfElfStreams.
intptr_t WritePrefixedLength(std::function<void()> body) {

View file

@ -914,17 +914,20 @@ class DwarfAssemblyStream : public DwarfWriteStream {
EncodedPosition WritePrefixedLength(const char* prefix,
std::function<void()> body) {
ASSERT(prefix != nullptr);
const char* const start_symbol = OS::SCreate(zone_, ".L%s_start", prefix);
const char* const length_prefix_symbol =
OS::SCreate(zone_, ".L%s_length_prefix", prefix);
// Assignment to temp works around buggy Mac assembler.
stream_->Printf("L%s_size = .L%s_end - %s\n", prefix, prefix, start_symbol);
stream_->Printf("L%s_size = .L%s_end - .L%s_start\n", prefix, prefix,
prefix);
// We assume DWARF v2 currently, so all sizes are 32-bit.
stream_->Printf("%s L%s_size\n", kSizeDirectives[kInt32SizeLog2], prefix);
stream_->Printf("%s: %s L%s_size\n", length_prefix_symbol,
kSizeDirectives[kInt32SizeLog2], prefix);
// All sizes for DWARF sections measure the size of the section data _after_
// the size value.
stream_->Printf("%s:\n", start_symbol);
stream_->Printf(".L%s_start:\n", prefix);
body();
stream_->Printf(".L%s_end:\n", prefix);
return EncodedPosition(start_symbol);
return EncodedPosition(length_prefix_symbol);
}
void OffsetFromSymbol(const char* symbol, intptr_t offset) {
if (offset == 0) {