| 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | #ifndef RUNTIME_VM_BSS_RELOCS_H_ |
| 6 | #define RUNTIME_VM_BSS_RELOCS_H_ |
| 7 | |
| 8 | #include "platform/allocation.h" |
| 9 | |
| 10 | namespace dart { |
| 11 | class Thread; |
| 12 | |
| 13 | class BSS : public AllStatic { |
| 14 | public: |
| 15 | // Entries found in both the VM and isolate BSS come first. Each has its own |
| 16 | // portion of the BSS segment, so just the indices are shared, not the values |
| 17 | // stored at the index. |
| 18 | enum class Relocation : intptr_t { |
| 19 | InstructionsRelocatedAddress, |
| 20 | // End of shared entries. |
| 21 | DRT_GetThreadForNativeCallback, |
| 22 | // End of isolate-only entries. |
| 23 | }; |
| 24 | |
| 25 | static constexpr intptr_t kVmEntryCount = |
| 26 | static_cast<intptr_t>(Relocation::InstructionsRelocatedAddress) + 1; |
| 27 | |
| 28 | static constexpr intptr_t kIsolateEntryCount = |
| 29 | static_cast<intptr_t>(Relocation::DRT_GetThreadForNativeCallback) + 1; |
| 30 | |
| 31 | static constexpr intptr_t RelocationIndex(Relocation reloc) { |
| 32 | return static_cast<intptr_t>(reloc); |
| 33 | } |
| 34 | |
| 35 | static void Initialize(Thread* current, uword* bss, bool vm); |
| 36 | |
| 37 | // Currently only used externally by LoadedElf::ResolveSymbols() to set the |
| 38 | // relocated address without changing the embedder interface. |
| 39 | static void InitializeBSSEntry(BSS::Relocation relocation, |
| 40 | uword new_value, |
| 41 | uword* bss_start); |
| 42 | }; |
| 43 | |
| 44 | } // namespace dart |
| 45 | |
| 46 | #endif // RUNTIME_VM_BSS_RELOCS_H_ |
| 47 | |