LLVM 22.0.0git
XtensaELFObjectWriter.cpp
Go to the documentation of this file.
1//===-- XtensaMCObjectWriter.cpp - Xtensa ELF writer ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6// See https://llvm.org/LICENSE.txt for license information.
7// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8//
9//===----------------------------------------------------------------------===//
10
13#include "llvm/ADT/STLExtras.h"
16#include "llvm/MC/MCExpr.h"
17#include "llvm/MC/MCFixup.h"
19#include "llvm/MC/MCValue.h"
21#include <cassert>
22#include <cstdint>
23
24using namespace llvm;
25
26namespace {
27class XtensaObjectWriter : public MCELFObjectTargetWriter {
28public:
29 XtensaObjectWriter(uint8_t OSABI);
30
31 virtual ~XtensaObjectWriter();
32
33protected:
34 unsigned getRelocType(const MCFixup &, const MCValue &,
35 bool IsPCRel) const override;
36 bool needsRelocateWithSymbol(const MCValue &, unsigned Type) const override;
37};
38} // namespace
39
40XtensaObjectWriter::XtensaObjectWriter(uint8_t OSABI)
42 /*HasRelocationAddend=*/true) {}
43
44XtensaObjectWriter::~XtensaObjectWriter() {}
45
46unsigned XtensaObjectWriter::getRelocType(const MCFixup &Fixup,
47 const MCValue &Target,
48 bool IsPCRel) const {
49 uint8_t Specifier = Target.getSpecifier();
50
51 switch ((unsigned)Fixup.getKind()) {
52 case FK_Data_4:
53 return Specifier == Xtensa::S_TPOFF ? ELF::R_XTENSA_TLS_TPOFF
54 : ELF::R_XTENSA_32;
55 default:
56 return ELF::R_XTENSA_SLOT0_OP;
57 }
58}
59
60std::unique_ptr<MCObjectTargetWriter>
61llvm::createXtensaObjectWriter(uint8_t OSABI, bool IsLittleEndian) {
62 return std::make_unique<XtensaObjectWriter>(OSABI);
63}
64
65bool XtensaObjectWriter::needsRelocateWithSymbol(const MCValue &,
66 unsigned Type) const {
67 return false;
68}
PowerPC TLS Dynamic Call Fixup
This file contains some templates that are useful if you are working with the STL at all.
virtual unsigned getRelocType(const MCFixup &Fixup, const MCValue &Target, bool IsPCRel) const =0
virtual bool needsRelocateWithSymbol(const MCValue &, unsigned Type) const
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:61
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
@ EM_XTENSA
Definition: ELF.h:216
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ FK_Data_4
A four-byte fixup.
Definition: MCFixup.h:36
std::unique_ptr< MCObjectTargetWriter > createXtensaObjectWriter(uint8_t OSABI, bool IsLittleEndian)