Skip to content

Commit 0bfb943

Browse files
sjindel-googlecommit-bot@chromium.org
authored andcommitted
[vm] Locate ELF/Mach-O scripts with realpath in dart_precompiled_runtime.
Change-Id: I93f38bbd59c565c19677eedf7f434b52ffa9fb71 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109401 Commit-Queue: Samir Jindel <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
1 parent 5e2a950 commit 0bfb943

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

pkg/vm/tool/dart_precompiled_runtime2

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,4 @@ fi
3333
export DART_CONFIGURATION=${DART_CONFIGURATION:-ReleaseX64}
3434
BIN_DIR="$OUT_DIR$DART_CONFIGURATION"
3535

36-
OPTIONS=()
37-
SNAPSHOT=()
38-
for arg in "$@"; do
39-
case $arg in
40-
--*)
41-
OPTIONS+=("$arg")
42-
;;
43-
*)
44-
SNAPSHOT="$arg"
45-
;;
46-
esac
47-
done
48-
49-
# Pass an absolute file path to the snapshot so that the dynamic linker can find
50-
# ELF snapshots which are not in the system load path.
51-
SNAPSHOT=$(realpath "$SNAPSHOT")
52-
53-
exec "$BIN_DIR"/dart_precompiled_runtime "${OPTIONS[@]}" "$SNAPSHOT"
36+
exec "$BIN_DIR"/dart_precompiled_runtime "$@"

runtime/bin/snapshot_utils.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
#include <memory>
6+
57
#include "bin/snapshot_utils.h"
68

79
#include "bin/dartutils.h"
@@ -240,7 +242,17 @@ AppSnapshot* Snapshot::TryReadAppSnapshot(const char* script_name) {
240242
#if defined(DART_PRECOMPILED_RUNTIME)
241243
// For testing AOT with the standalone embedder, we also support loading
242244
// from a dynamic library to simulate what happens on iOS.
245+
246+
#if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS)
247+
// On Linux and OSX, resolve the script path before passing into dlopen()
248+
// since dlopen will not search the filesystem for paths like 'libtest.so'.
249+
std::unique_ptr<char, decltype(std::free)*> absolute_path{
250+
realpath(script_name, nullptr), std::free};
251+
script_name = absolute_path.get();
252+
#endif
253+
243254
snapshot = TryReadAppSnapshotDynamicLibrary(script_name);
255+
244256
if (snapshot != NULL) {
245257
return snapshot;
246258
}

0 commit comments

Comments
 (0)