@@ -426,6 +426,13 @@ class BinaryContext {
426426 Address);
427427 }
428428
429+ bool isInRange (StringRef NameStart, StringRef NameEnd,
430+ uint64_t Address) const {
431+ ErrorOr<uint64_t > Start = getSymbolValue (NameStart);
432+ ErrorOr<uint64_t > End = getSymbolValue (NameEnd);
433+ return Start && End && *Start <= Address && Address < *End;
434+ }
435+
429436 // / Return size of an entry for the given jump table \p Type.
430437 uint64_t getJumpTableEntrySize (JumpTable::JumpTableType Type) const {
431438 return Type == JumpTable::JTT_PIC ? 4 : AsmInfo->getCodePointerSize ();
@@ -538,6 +545,11 @@ class BinaryContext {
538545 // / binary and functions created by BOLT.
539546 std::vector<BinaryFunction *> getAllBinaryFunctions ();
540547
548+ void undefineInstLabel (const MCInst &Inst) {
549+ if (MCSymbol *const Label = MIB->getInstLabel (Inst))
550+ UndefinedSymbols.insert (Label);
551+ }
552+
541553 // / Construct a jump table for \p Function at \p Address or return an existing
542554 // / one at that location.
543555 // /
@@ -606,6 +618,9 @@ class BinaryContext {
606618 // / Addresses reserved for kernel on x86_64 start at this location.
607619 static constexpr uint64_t KernelStartX86_64 = 0xFFFF'FFFF'8000'0000 ;
608620
621+ // / Addresses reserved for kernel on aarch64 start at this location.
622+ static constexpr uint64_t KernelStartAArch64 = 0xFFFF'0000'0000'0000 ;
623+
609624 // / Map address to a constant island owner (constant data in code section)
610625 std::map<uint64_t , BinaryFunction *> AddressToConstantIslandMap;
611626
@@ -749,6 +764,8 @@ class BinaryContext {
749764 // / Area in the input binary reserved for BOLT.
750765 AddressRange BOLTReserved;
751766
767+ AddressRange BOLTReservedRW;
768+
752769 // / Address of the code/function that is executed before any other code in
753770 // / the binary.
754771 std::optional<uint64_t > StartFunctionAddress;
@@ -884,7 +901,11 @@ class BinaryContext {
884901 // / Return a value of the global \p Symbol or an error if the value
885902 // / was not set.
886903 ErrorOr<uint64_t > getSymbolValue (const MCSymbol &Symbol) const {
887- const BinaryData *BD = getBinaryDataByName (Symbol.getName ());
904+ return getSymbolValue (Symbol.getName ());
905+ }
906+
907+ ErrorOr<uint64_t > getSymbolValue (StringRef Name) const {
908+ const BinaryData *BD = getBinaryDataByName (Name);
888909 if (!BD)
889910 return std::make_error_code (std::errc::bad_address);
890911 return BD->getAddress ();
@@ -1202,6 +1223,13 @@ class BinaryContext {
12021223 return const_cast <BinaryContext *>(this )->getSectionForAddress (Address);
12031224 }
12041225
1226+ ErrorOr<BinarySection &> getSectionForOutputAddress (uint64_t Address);
1227+ ErrorOr<const BinarySection &>
1228+ getSectionForOutputAddress (uint64_t Address) const {
1229+ return const_cast <BinaryContext *>(this )->getSectionForOutputAddress (
1230+ Address);
1231+ }
1232+
12051233 // / Return internal section representation for a section in a file.
12061234 BinarySection *getSectionForSectionRef (SectionRef Section) const {
12071235 return SectionRefToBinarySection.lookup (Section);
0 commit comments