Skip to content

Commit fe32806

Browse files
committed
ELFObjectWriter: Remove the MCContext argument from getRelocType
Additionally, swap MCFixup/MCValue order to match addReloc/recordRelocation.
1 parent e933948 commit fe32806

File tree

21 files changed

+68
-89
lines changed

21 files changed

+68
-89
lines changed

llvm/include/llvm/MC/MCELFObjectWriter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter {
8585
}
8686
}
8787

88-
virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
89-
const MCFixup &Fixup, bool IsPCRel) const = 0;
88+
virtual unsigned getRelocType(const MCFixup &Fixup, const MCValue &Target,
89+
bool IsPCRel) const = 0;
9090

9191
virtual bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
9292
unsigned Type) const;

llvm/lib/MC/ELFObjectWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ void ELFObjectWriter::recordRelocation(const MCFragment &F,
13771377
if (mc::isRelocRelocation(Fixup.getKind()))
13781378
Type = Fixup.getKind() - FirstLiteralRelocationKind;
13791379
else
1380-
Type = TargetObjectWriter->getRelocType(Ctx, Target, Fixup, IsPCRel);
1380+
Type = TargetObjectWriter->getRelocType(Fixup, Target, IsPCRel);
13811381

13821382
bool UseSectionSym =
13831383
SymA && SymA->getBinding() == ELF::STB_LOCAL && !SymA->isUndefined();

llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class AArch64ELFObjectWriter : public MCELFObjectTargetWriter {
3636
~AArch64ELFObjectWriter() override = default;
3737

3838
protected:
39-
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
40-
const MCFixup &Fixup, bool IsPCRel) const override;
39+
unsigned getRelocType(const MCFixup &, const MCValue &,
40+
bool IsPCRel) const override;
4141
bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
4242
unsigned Type) const override;
4343
bool isNonILP32reloc(const MCFixup &Fixup,
@@ -83,9 +83,8 @@ bool AArch64ELFObjectWriter::isNonILP32reloc(
8383
return false;
8484
}
8585

86-
unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
86+
unsigned AArch64ELFObjectWriter::getRelocType(const MCFixup &Fixup,
8787
const MCValue &Target,
88-
const MCFixup &Fixup,
8988
bool IsPCRel) const {
9089
unsigned Kind = Fixup.getTargetKind();
9190
AArch64MCExpr::Specifier RefKind =

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class AMDGPUELFObjectWriter : public MCELFObjectTargetWriter {
2222
AMDGPUELFObjectWriter(bool Is64Bit, uint8_t OSABI, bool HasRelocationAddend);
2323

2424
protected:
25-
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
26-
const MCFixup &Fixup, bool IsPCRel) const override;
25+
unsigned getRelocType(const MCFixup &, const MCValue &,
26+
bool IsPCRel) const override;
2727
};
2828

2929

@@ -34,9 +34,8 @@ AMDGPUELFObjectWriter::AMDGPUELFObjectWriter(bool Is64Bit, uint8_t OSABI,
3434
: MCELFObjectTargetWriter(Is64Bit, OSABI, ELF::EM_AMDGPU,
3535
HasRelocationAddend) {}
3636

37-
unsigned AMDGPUELFObjectWriter::getRelocType(MCContext &Ctx,
37+
unsigned AMDGPUELFObjectWriter::getRelocType(const MCFixup &Fixup,
3838
const MCValue &Target,
39-
const MCFixup &Fixup,
4039
bool IsPCRel) const {
4140
if (const auto *SymA = Target.getAddSym()) {
4241
// SCRATCH_RSRC_DWORD[01] is a special global variable that represents

llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,13 @@ namespace {
2828
class ARMELFObjectWriter : public MCELFObjectTargetWriter {
2929
enum { DefaultEABIVersion = 0x05000000U };
3030

31-
unsigned getRelocTypeInner(const MCValue &Target, const MCFixup &Fixup,
32-
bool IsPCRel) const;
33-
3431
public:
3532
ARMELFObjectWriter(uint8_t OSABI);
3633

3734
~ARMELFObjectWriter() override = default;
3835

39-
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
40-
const MCFixup &Fixup, bool IsPCRel) const override;
36+
unsigned getRelocType(const MCFixup &, const MCValue &,
37+
bool IsPCRel) const override;
4138

4239
bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
4340
unsigned Type) const override;
@@ -69,15 +66,9 @@ bool ARMELFObjectWriter::needsRelocateWithSymbol(const MCValue &,
6966
// Need to examine the Fixup when determining whether to
7067
// emit the relocation as an explicit symbol or as a section relative
7168
// offset
72-
unsigned ARMELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
73-
const MCFixup &Fixup,
69+
unsigned ARMELFObjectWriter::getRelocType(const MCFixup &Fixup,
70+
const MCValue &Target,
7471
bool IsPCRel) const {
75-
return getRelocTypeInner(Target, Fixup, IsPCRel);
76-
}
77-
78-
unsigned ARMELFObjectWriter::getRelocTypeInner(const MCValue &Target,
79-
const MCFixup &Fixup,
80-
bool IsPCRel) const {
8172
unsigned Kind = Fixup.getTargetKind();
8273
uint8_t Specifier = Target.getSpecifier();
8374
auto CheckFDPIC = [&](uint32_t Type) {

llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class AVRELFObjectWriter : public MCELFObjectTargetWriter {
2727

2828
virtual ~AVRELFObjectWriter() = default;
2929

30-
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
31-
const MCFixup &Fixup, bool IsPCRel) const override;
30+
unsigned getRelocType(const MCFixup &, const MCValue &,
31+
bool IsPCRel) const override;
3232
};
3333

3434
AVRELFObjectWriter::AVRELFObjectWriter(uint8_t OSABI)
3535
: MCELFObjectTargetWriter(false, OSABI, ELF::EM_AVR, true) {}
3636

37-
unsigned AVRELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
38-
const MCFixup &Fixup,
37+
unsigned AVRELFObjectWriter::getRelocType(const MCFixup &Fixup,
38+
const MCValue &Target,
3939
bool IsPCRel) const {
4040
auto Modifier = AVRMCExpr::Specifier(Target.getSpecifier());
4141
switch ((unsigned)Fixup.getKind()) {

llvm/lib/Target/BPF/MCTargetDesc/BPFELFObjectWriter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class BPFELFObjectWriter : public MCELFObjectTargetWriter {
2525
~BPFELFObjectWriter() override = default;
2626

2727
protected:
28-
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
29-
const MCFixup &Fixup, bool IsPCRel) const override;
28+
unsigned getRelocType(const MCFixup &, const MCValue &,
29+
bool IsPCRel) const override;
3030
};
3131

3232
} // end anonymous namespace
@@ -35,8 +35,8 @@ BPFELFObjectWriter::BPFELFObjectWriter(uint8_t OSABI)
3535
: MCELFObjectTargetWriter(/*Is64Bit*/ true, OSABI, ELF::EM_BPF,
3636
/*HasRelocationAddend*/ false) {}
3737

38-
unsigned BPFELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
39-
const MCFixup &Fixup,
38+
unsigned BPFELFObjectWriter::getRelocType(const MCFixup &Fixup,
39+
const MCValue &Target,
4040
bool IsPCRel) const {
4141
// determine the type of the relocation
4242
switch (Fixup.getKind()) {

llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@ class CSKYELFObjectWriter : public MCELFObjectTargetWriter {
2727
: MCELFObjectTargetWriter(false, OSABI, ELF::EM_CSKY, true){};
2828
~CSKYELFObjectWriter() {}
2929

30-
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
31-
const MCFixup &Fixup, bool IsPCRel) const override;
30+
unsigned getRelocType(const MCFixup &, const MCValue &,
31+
bool IsPCRel) const override;
3232
bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
3333
unsigned Type) const override;
3434
};
3535

3636
} // namespace
3737

38-
unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
38+
unsigned CSKYELFObjectWriter::getRelocType(const MCFixup &Fixup,
3939
const MCValue &Target,
40-
const MCFixup &Fixup,
4140
bool IsPCRel) const {
4241
const MCExpr *Expr = Fixup.getValue();
4342
// Determine the type of the relocation

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonELFObjectWriter.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class HexagonELFObjectWriter : public MCELFObjectTargetWriter {
2828
public:
2929
HexagonELFObjectWriter(uint8_t OSABI, StringRef C);
3030

31-
unsigned getRelocType(MCContext &Ctx, MCValue const &Target,
32-
MCFixup const &Fixup, bool IsPCRel) const override;
31+
unsigned getRelocType(const MCFixup &, const MCValue &,
32+
bool IsPCRel) const override;
3333
};
3434
}
3535

@@ -38,9 +38,8 @@ HexagonELFObjectWriter::HexagonELFObjectWriter(uint8_t OSABI, StringRef C)
3838
/*HasRelocationAddend*/ true),
3939
CPU(C) {}
4040

41-
unsigned HexagonELFObjectWriter::getRelocType(MCContext &Ctx,
42-
MCValue const &Target,
43-
MCFixup const &Fixup,
41+
unsigned HexagonELFObjectWriter::getRelocType(const MCFixup &Fixup,
42+
const MCValue &Target,
4443
bool IsPCRel) const {
4544
auto Variant = HexagonMCExpr::VariantKind(Target.getSpecifier());
4645
switch (Variant) {

llvm/lib/Target/Lanai/MCTargetDesc/LanaiELFObjectWriter.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class LanaiELFObjectWriter : public MCELFObjectTargetWriter {
2424
~LanaiELFObjectWriter() override = default;
2525

2626
protected:
27-
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
28-
const MCFixup &Fixup, bool IsPCRel) const override;
27+
unsigned getRelocType(const MCFixup &, const MCValue &,
28+
bool IsPCRel) const override;
2929
bool needsRelocateWithSymbol(const MCValue &Val, const MCSymbol &Sym,
3030
unsigned Type) const override;
3131
};
@@ -36,10 +36,8 @@ LanaiELFObjectWriter::LanaiELFObjectWriter(uint8_t OSABI)
3636
: MCELFObjectTargetWriter(/*Is64Bit_=*/false, OSABI, ELF::EM_LANAI,
3737
/*HasRelocationAddend_=*/true) {}
3838

39-
unsigned LanaiELFObjectWriter::getRelocType(MCContext & /*Ctx*/,
40-
const MCValue & /*Target*/,
41-
const MCFixup &Fixup,
42-
bool /*IsPCRel*/) const {
39+
unsigned LanaiELFObjectWriter::getRelocType(const MCFixup &Fixup,
40+
const MCValue &, bool) const {
4341
unsigned Type;
4442
unsigned Kind = static_cast<unsigned>(Fixup.getKind());
4543
switch (Kind) {

0 commit comments

Comments
 (0)