-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathos.cc
30 lines (25 loc) · 978 Bytes
/
os.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) 2024, 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 "vm/os.h"
#include "platform/assert.h"
#include "vm/image_snapshot.h"
#include "vm/native_symbol.h"
namespace dart {
const uint8_t* OS::GetAppDSOBase(const uint8_t* snapshot_instructions) {
// Use the relocated address in the Image if the snapshot was compiled
// directly to ELF.
const Image instructions_image(snapshot_instructions);
if (instructions_image.compiled_to_elf()) {
return snapshot_instructions -
instructions_image.instructions_relocated_address();
}
uword dso_base;
if (NativeSymbolResolver::LookupSharedObject(
reinterpret_cast<uword>(snapshot_instructions), &dso_base)) {
return reinterpret_cast<const uint8_t*>(dso_base);
}
UNIMPLEMENTED();
return nullptr;
}
} // namespace dart