Files
clang-p2996/lld/MachO/Target.cpp
Greg McGary 87104faac4 [lld-macho] Add ARM64 target arch
This is an initial base commit for ARM64 target arch support. I don't represent that it complete or bug-free, but wish to put it out for review now that some basic things like branch target & load/store address relocs are working.

I can add more tests to this base commit, or add them in follow-up commits.

It is not entirely clear whether I use the "ARM64" (Apple) or "AArch64" (non-Apple) naming convention. Guidance is appreciated.

Differential Revision: https://reviews.llvm.org/D88629
2021-02-08 18:14:07 -07:00

48 lines
1.7 KiB
C++

//===- Target.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 "Target.h"
#include "InputSection.h"
#include "Symbols.h"
#include "SyntheticSections.h"
#include "lld/Common/ErrorHandler.h"
using namespace llvm;
using namespace lld;
using namespace lld::macho;
const TargetInfo::RelocAttrs TargetInfo::invalidRelocAttrs{"INVALID",
RelocAttrBits::_0};
bool TargetInfo::validateSymbolRelocation(const Symbol *sym,
const InputSection *isec,
const Reloc &r) {
const RelocAttrs &relocAttrs = getRelocAttrs(r.type);
bool valid = true;
auto message = [relocAttrs, sym, isec, &valid](const Twine &diagnostic) {
valid = false;
return (relocAttrs.name + " relocation " + diagnostic + " for `" +
sym->getName() + "' in " + toString(isec))
.str();
};
if ((relocAttrs.hasAttr(RelocAttrBits::TLV) &&
!relocAttrs.hasAttr(RelocAttrBits::BYTE8)) != sym->isTlv())
error(message(Twine("requires that variable ") +
(sym->isTlv() ? "not " : "") + "be thread-local"));
if (relocAttrs.hasAttr(RelocAttrBits::DYSYM8) && isa<DylibSymbol>(sym) &&
r.length != 3)
error(message("has width " + std::to_string(1 << r.length) +
" bytes, but must be 8 bytes"));
return valid;
}
TargetInfo *macho::target = nullptr;