//===- Relocations.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "Relocations.h" #include "ConcatOutputSection.h" #include "Symbols.h" #include "SyntheticSections.h" #include "Target.h" #include "lld/Common/ErrorHandler.h" usingnamespacellvm; usingnamespacelld; usingnamespacelld::macho; static_assert …; InputSection *Reloc::getReferentInputSection() const { … } StringRef Reloc::getReferentString() const { … } bool macho::validateSymbolRelocation(const Symbol *sym, const InputSection *isec, const Reloc &r) { … } // Given an offset in the output buffer, figure out which ConcatInputSection (if // any) maps to it. At the same time, update the offset such that it is relative // to the InputSection rather than to the output buffer. // // Obtaining the InputSection allows us to have better error diagnostics. // However, many of our relocation-handling methods do not take the InputSection // as a parameter. Since we are already passing the buffer offsets to our Target // methods, this function allows us to emit better errors without threading an // additional InputSection argument through the call stack. // // This is implemented as a slow linear search through OutputSegments, // OutputSections, and finally the InputSections themselves. However, this // function should be called only on error paths, so some overhead is fine. InputSection *macho::offsetToInputSection(uint64_t *off) { … } void macho::reportRangeError(void *loc, const Reloc &r, const Twine &v, uint8_t bits, int64_t min, uint64_t max) { … } void macho::reportRangeError(void *loc, SymbolDiagnostic d, const Twine &v, uint8_t bits, int64_t min, uint64_t max) { … } const RelocAttrs macho::invalidRelocAttrs{ … };