Skip to content

Commit b86ac3b

Browse files
jrtc27resistor
authored andcommitted
[NFC][ELF][CHERI] Rename cheriCap(Call)Rel to symbolicCap(Call)Rel
This makes it clearer they're equivalent to symbolicRel.
1 parent a2e508e commit b86ac3b

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

lld/ELF/Arch/Cheri.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,8 @@ uint64_t MipsCheriCapTableSection::assignIndices(uint64_t startIndex,
690690
// relocation instead which allows the runtime linker to create non-unique
691691
// plt stubs.
692692
RelType elfCapabilityReloc = it.second.usedInCallExpr
693-
? *ctx.target->cheriCapCallRel
694-
: *ctx.target->cheriCapRel;
693+
? *ctx.target->symbolicCapCallRel
694+
: *ctx.target->symbolicCapRel;
695695
// All capability call relocations should end up in the pltrel section
696696
// rather than the normal relocation section to make processing of PLT
697697
// relocations in RTLD more efficient.
@@ -903,7 +903,7 @@ static bool needsCheriMipsTrampoline(Ctx &ctx, RelType type,
903903
if (ctx.arg.emachine != EM_MIPS)
904904
return false;
905905

906-
if (!sym.isFunc() || type == *ctx.target->cheriCapCallRel)
906+
if (!sym.isFunc() || type == *ctx.target->symbolicCapCallRel)
907907
return false;
908908

909909
// In static binaries we do not need PLT stubs for function pointers since

lld/ELF/Arch/Mips.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ template <class ELFT> MIPS<ELFT>::MIPS(Ctx &ctx) : TargetInfo(ctx) {
4848
pltHeaderSize = 32;
4949
copyRel = R_MIPS_COPY;
5050
pltRel = R_MIPS_JUMP_SLOT;
51-
cheriCapRel = R_MIPS_CHERI_CAPABILITY;
52-
cheriCapCallRel = R_MIPS_CHERI_CAPABILITY_CALL;
51+
symbolicCapRel = R_MIPS_CHERI_CAPABILITY;
52+
symbolicCapCallRel = R_MIPS_CHERI_CAPABILITY_CALL;
5353
needsThunks = true;
5454

5555
// Set `sigrie 1` as a trap instruction.
@@ -237,7 +237,7 @@ RelExpr MIPS<ELFT>::getRelExpr(RelType type, const Symbol &s,
237237
}
238238

239239
template <class ELFT> RelType MIPS<ELFT>::getDynRel(RelType type) const {
240-
if (type == symbolicRel || type == cheriCapRel)
240+
if (type == symbolicRel || type == symbolicCapRel)
241241
return type;
242242
return R_MIPS_NONE;
243243
}

lld/ELF/Arch/RISCV.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ RISCV::RISCV(Ctx &ctx) : TargetInfo(ctx) {
127127
pltRel = R_RISCV_JUMP_SLOT;
128128
relativeRel = R_RISCV_RELATIVE;
129129
iRelativeRel = R_RISCV_IRELATIVE;
130-
cheriCapRel = R_RISCV_CHERI_CAPABILITY;
130+
symbolicCapRel = R_RISCV_CHERI_CAPABILITY;
131131
if (ctx.arg.is64) {
132132
symbolicRel = R_RISCV_64;
133133
tlsModuleIndexRel = R_RISCV_TLS_DTPMOD64;
@@ -140,7 +140,7 @@ RISCV::RISCV(Ctx &ctx) : TargetInfo(ctx) {
140140
tlsGotRel = R_RISCV_TLS_TPREL32;
141141
}
142142
if (ctx.arg.isCheriAbi)
143-
gotRel = *cheriCapRel;
143+
gotRel = *symbolicCapRel;
144144
else
145145
gotRel = symbolicRel;
146146
tlsDescRel = R_RISCV_TLSDESC;
@@ -308,7 +308,7 @@ void RISCV::writePlt(uint8_t *buf, const Symbol &sym,
308308
}
309309

310310
RelType RISCV::getDynRel(RelType type) const {
311-
return type == symbolicRel || type == cheriCapRel
311+
return type == symbolicRel || type == symbolicCapRel
312312
? type
313313
: static_cast<RelType>(R_RISCV_NONE);
314314
}

lld/ELF/Relocations.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -950,12 +950,12 @@ static void addPltEntry(Ctx &ctx, PltSection &plt, GotPltSection &gotPlt,
950950
if (!sym.isPreemptible) {
951951
addRelativeCapabilityRelocation(ctx, gotPlt, sym.getGotPltOffset(ctx),
952952
&sym, 0, R_ABS_CAP,
953-
*ctx.target->cheriCapRel);
953+
*ctx.target->symbolicCapRel);
954954
return;
955955
}
956956

957957
addRelativeCapabilityRelocation(ctx, gotPlt, sym.getGotPltOffset(ctx), &plt,
958-
0, R_ABS_CAP, *ctx.target->cheriCapRel);
958+
0, R_ABS_CAP, *ctx.target->symbolicCapRel);
959959
}
960960

961961
rel.addReloc({type, &gotPlt, sym.getGotPltOffset(ctx),
@@ -978,7 +978,9 @@ void elf::addGotEntry(Ctx &ctx, Symbol &sym) {
978978
}
979979

980980
RelType type =
981-
ctx.arg.isCheriAbi ? *ctx.target->cheriCapRel : ctx.target->symbolicRel;
981+
982+
ctx.arg.isCheriAbi ? *ctx.target->symbolicCapRel
983+
: ctx.target->symbolicRel;
982984

983985
// Otherwise, the value is either a link-time constant or the load base
984986
// plus a constant. For CHERI it always requires run-time initialisation,
@@ -1244,7 +1246,8 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
12441246
if (canWrite) {
12451247
RelType rel = ctx.target->getDynRel(type);
12461248
if (oneof<R_GOT, RE_LOONGARCH_GOT>(expr) ||
1247-
((rel == ctx.target->symbolicRel || rel == ctx.target->cheriCapRel) &&
1249+
((rel == ctx.target->symbolicRel ||
1250+
rel == ctx.target->symbolicCapRel) &&
12481251
!sym.isPreemptible)) {
12491252
addRelativeReloc<true>(ctx, *sec, offset, sym, addend, expr, type);
12501253
return;

lld/ELF/SyntheticSections.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,8 +1749,8 @@ RelocationBaseSection::RelocationBaseSection(Ctx &ctx, StringRef name,
17491749
void RelocationBaseSection::addSymbolReloc(
17501750
RelType dynType, InputSectionBase &isec, uint64_t offsetInSec, Symbol &sym,
17511751
int64_t addend, std::optional<RelType> addendRelType) {
1752-
bool isCap = dynType == ctx.target->cheriCapRel ||
1753-
dynType == ctx.target->cheriCapCallRel;
1752+
bool isCap = dynType == ctx.target->symbolicCapRel ||
1753+
dynType == ctx.target->symbolicCapCallRel;
17541754
if (isCap && sym.isFunc() && addend != 0) {
17551755
auto diag = Warn(ctx);
17561756
diag << "capability relocation with non-zero addend (0x"

lld/ELF/Target.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ class TargetInfo {
138138
RelType tlsOffsetRel = 0;
139139
std::optional<RelType> absPointerRel; // TODO: remove the optional
140140
std::optional<RelType> sizeRel;
141-
std::optional<RelType> cheriCapRel;
142-
std::optional<RelType> cheriCapCallRel;
141+
std::optional<RelType> symbolicCapRel;
142+
std::optional<RelType> symbolicCapCallRel;
143143
unsigned gotEntrySize = ctx.arg.wordsize;
144144
unsigned pltEntrySize = 0;
145145
unsigned pltHeaderSize = 0;

0 commit comments

Comments
 (0)