Files
sdk/runtime/bin/mappable.cc
Tess Strickland f7699740cc [vm] Allow manual loading of Mach-O dynamic library snapshots.
Adds a Mach-O loader, similar to the existing ELF loader, that
can be used on platforms that do not support loading Mach-O dynamic
libraries via dlopen().

Other changes:

* Renames the --force-load-elf-from-memory command line argument
  to --force-load-from-memory.
* Use CPU_TYPE_ANY and CPU_SUBTYPE_ANY for architectures that do
  not have specific constants in <mach/machine.h> (e.g., RISCV),
  as the snapshot header check after loading also catches architecture
  mismatches.
* Emit the unwinding information at the end of the text segment
  for Windows Mach-O snapshots as is done for ELF ones.

TEST=vm/dart/unobfuscated_static_symbols_test
     vm/dart/use_dwarf_stack_traces_flag_test

Issue: https://github.com/dart-lang/sdk/issues/60307
Change-Id: I34a2a334f47d18d5c4f4a712956e71fd0ac94024
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-mac-release-arm64-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try,vm-fuchsia-release-x64-try,vm-fuchsia-release-arm64-try,vm-linux-debug-ia32-try,vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv32-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-release-simarm_x64-try,vm-gcc-linux-try,vm-ubsan-linux-release-arm64-try,vm-aot-win-release-arm64-try,vm-aot-win-release-x64-try,vm-win-release-x64-try,vm-win-release-arm64-try,vm-aot-win-debug-arm64-try,vm-win-debug-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430100
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-03 05:56:59 -07:00

31 lines
834 B
C++

// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "bin/mappable.h"
#include "platform/globals.h"
#include "bin/file.h"
namespace dart {
namespace bin {
Mappable* Mappable::FromPath(const char* path) {
return new FileMappable(File::Open(/*namespc=*/nullptr, path, File::kRead,
/*executable=*/true));
}
#if defined(DART_HOST_OS_FUCHSIA) || defined(DART_HOST_OS_LINUX)
Mappable* Mappable::FromFD(int fd) {
return new FileMappable(File::OpenFD(fd));
}
#endif
Mappable* Mappable::FromMemory(const uint8_t* memory, size_t size) {
return new MemoryMappable(memory, size);
}
} // namespace bin
} // namespace dart