LLVM 19.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
12#include "llvm/ADT/STLExtras.h"
15#include "llvm/MC/MCExpr.h"
16#include "llvm/MC/MCFixup.h"
18#include "llvm/MC/MCValue.h"
20#include <cassert>
21#include <cstdint>
22
23using namespace llvm;
24
25namespace {
26class XtensaObjectWriter : public MCELFObjectTargetWriter {
27public:
28 XtensaObjectWriter(uint8_t OSABI);
29
30 virtual ~XtensaObjectWriter();
31
32protected:
33 unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
34 const MCFixup &Fixup, bool IsPCRel) const override;
35 bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
36 unsigned Type) const override;
37};
38} // namespace
39
40XtensaObjectWriter::XtensaObjectWriter(uint8_t OSABI)
42 /*HasRelocationAddend=*/true) {}
43
44XtensaObjectWriter::~XtensaObjectWriter() {}
45
46unsigned XtensaObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
47 const MCFixup &Fixup,
48 bool IsPCRel) const {
49
50 switch ((unsigned)Fixup.getKind()) {
51 case FK_Data_4:
52 return ELF::R_XTENSA_32;
53 default:
54 return ELF::R_XTENSA_SLOT0_OP;
55 }
56}
57
58std::unique_ptr<MCObjectTargetWriter>
59llvm::createXtensaObjectWriter(uint8_t OSABI, bool IsLittleEndian) {
60 return std::make_unique<XtensaObjectWriter>(OSABI);
61}
62
63bool XtensaObjectWriter::needsRelocateWithSymbol(const MCValue &,
64 const MCSymbol &,
65 unsigned Type) const {
66 return false;
67}
basic Basic Alias true
Symbol * Sym
Definition: ELF_riscv.cpp:479
PowerPC TLS Dynamic Call Fixup
This file contains some templates that are useful if you are working with the STL at all.
Context object for machine code objects.
Definition: MCContext.h:76
virtual bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym, unsigned Type) const
virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const =0
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
This represents an "assembler immediate".
Definition: MCValue.h:36
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:211
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ FK_Data_4
A four-byte fixup.
Definition: MCFixup.h:25
std::unique_ptr< MCObjectTargetWriter > createXtensaObjectWriter(uint8_t OSABI, bool IsLittleEndian)