Skip to content

Commit cf30e8e

Browse files
committed
[ELF] Pass Ctx & to Thunk
1 parent 877e49f commit cf30e8e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

lld/ELF/Relocations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ std::pair<Thunk *, bool> ThunkCreator::getThunk(InputSection *isec,
22602260
return std::make_pair(t, false);
22612261

22622262
// No existing compatible Thunk in range, create a new one
2263-
Thunk *t = addThunk(*isec, rel);
2263+
Thunk *t = addThunk(ctx, *isec, rel);
22642264
thunkVec->push_back(t);
22652265
return std::make_pair(t, true);
22662266
}

lld/ELF/Thunks.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ Thunk::Thunk(Symbol &d, int64_t a) : destination(d), addend(a), offset(0) {
12611261

12621262
Thunk::~Thunk() = default;
12631263

1264-
static Thunk *addThunkAArch64(RelType type, Symbol &s, int64_t a) {
1264+
static Thunk *addThunkAArch64(Ctx &ctx, RelType type, Symbol &s, int64_t a) {
12651265
if (type != R_AARCH64_CALL26 && type != R_AARCH64_JUMP26 &&
12661266
type != R_AARCH64_PLT32)
12671267
fatal("unrecognized relocation type");
@@ -1357,8 +1357,8 @@ static Thunk *addThunkV6M(const InputSection &isec, RelType reloc, Symbol &s,
13571357
}
13581358

13591359
// Creates a thunk for Thumb-ARM interworking or branch range extension.
1360-
static Thunk *addThunkArm(const InputSection &isec, RelType reloc, Symbol &s,
1361-
int64_t a) {
1360+
static Thunk *addThunkArm(Ctx &ctx, const InputSection &isec, RelType reloc,
1361+
Symbol &s, int64_t a) {
13621362
// Decide which Thunk is needed based on:
13631363
// Available instruction set
13641364
// - An Arm Thunk can only be used if Arm state is available.
@@ -1430,7 +1430,7 @@ static Thunk *addThunkPPC32(const InputSection &isec, const Relocation &rel,
14301430
return make<PPC32LongThunk>(s, rel.addend);
14311431
}
14321432

1433-
static Thunk *addThunkPPC64(RelType type, Symbol &s, int64_t a) {
1433+
static Thunk *addThunkPPC64(Ctx &ctx, RelType type, Symbol &s, int64_t a) {
14341434
assert((type == R_PPC64_REL14 || type == R_PPC64_REL24 ||
14351435
type == R_PPC64_REL24_NOTOC) &&
14361436
"unexpected relocation type for thunk");
@@ -1460,23 +1460,23 @@ static Thunk *addThunkPPC64(RelType type, Symbol &s, int64_t a) {
14601460
return make<PPC64PDLongBranchThunk>(s, a);
14611461
}
14621462

1463-
Thunk *elf::addThunk(const InputSection &isec, Relocation &rel) {
1463+
Thunk *elf::addThunk(Ctx &ctx, const InputSection &isec, Relocation &rel) {
14641464
Symbol &s = *rel.sym;
14651465
int64_t a = rel.addend;
14661466

14671467
switch (ctx.arg.emachine) {
14681468
case EM_AARCH64:
1469-
return addThunkAArch64(rel.type, s, a);
1469+
return addThunkAArch64(ctx, rel.type, s, a);
14701470
case EM_ARM:
1471-
return addThunkArm(isec, rel.type, s, a);
1471+
return addThunkArm(ctx, isec, rel.type, s, a);
14721472
case EM_AVR:
14731473
return addThunkAVR(rel.type, s, a);
14741474
case EM_MIPS:
14751475
return addThunkMips(rel.type, s);
14761476
case EM_PPC:
14771477
return addThunkPPC32(isec, rel, s);
14781478
case EM_PPC64:
1479-
return addThunkPPC64(rel.type, s, a);
1479+
return addThunkPPC64(ctx, rel.type, s, a);
14801480
default:
14811481
llvm_unreachable("add Thunk only supported for ARM, AVR, Mips and PowerPC");
14821482
}

lld/ELF/Thunks.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "Relocations.h"
1414

1515
namespace lld::elf {
16+
struct Ctx;
1617
class Defined;
1718
class InputFile;
1819
class Symbol;
@@ -67,7 +68,7 @@ class Thunk {
6768

6869
// For a Relocation to symbol S create a Thunk to be added to a synthetic
6970
// ThunkSection.
70-
Thunk *addThunk(const InputSection &isec, Relocation &rel);
71+
Thunk *addThunk(Ctx &, const InputSection &isec, Relocation &rel);
7172

7273
void writePPC32PltCallStub(uint8_t *buf, uint64_t gotPltVA,
7374
const InputFile *file, int64_t addend);

0 commit comments

Comments
 (0)