Skip to content

Commit 0f171db

Browse files
jrtc27resistor
authored andcommitted
[NFC][ELF][CHERI] Swap CapRelocsMode enum for bool
All we care about is whether we're using caprelocs or relative relocations. Note the option name remains the same as it's implemented downstream in Morello LLD and actually passed by CheriBSD.
1 parent af5264f commit 0f171db

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

lld/ELF/Arch/Cheri.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ void addCapabilityRelocation(
952952
// For local symbols we can also emit the untagged capability bits and
953953
// instruct csu/rtld to run CBuildCap
954954
if ((!sym || !sym->isPreemptible) && !needTrampoline) {
955-
assert(ctx.arg.localCapRelocsMode == CapRelocsMode::Legacy &&
955+
assert(!ctx.arg.useRelativeCheriRelocs &&
956956
"relative ELF capability relocations not currently implemented");
957957
ctx.in.capRelocs->addCapReloc({sec, offset}, {symOrSec, 0u}, addend);
958958
return;

lld/ELF/Config.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ enum class BuildIdKind { None, Fast, Md5, Sha1, Hexstring, Uuid };
100100
// For --call-graph-profile-sort={none,hfsort,cdsort}.
101101
enum class CGProfileSortKind { None, Hfsort, Cdsort };
102102

103-
enum class CapRelocsMode { Legacy, ElfReloc };
104-
105103
enum class CapTableScopePolicy { All, File, Function };
106104

107105
// For --discard-{all,locals,none}.
@@ -459,8 +457,7 @@ struct Config {
459457
UnresolvedPolicy unresolvedSymbolsInShlib;
460458
Target2Policy target2;
461459
GcsPolicy zGcs;
462-
// Method used for capability relocations for non-preemptible symbols
463-
CapRelocsMode localCapRelocsMode;
460+
bool useRelativeCheriRelocs;
464461
CapTableScopePolicy capTableScope;
465462

466463
bool power10Stubs;

lld/ELF/Driver.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ static void checkOptions(Ctx &ctx) {
481481
ErrAlways(ctx) << "-r and -z nosectionheader may not be used together";
482482
}
483483

484-
if (ctx.arg.localCapRelocsMode == CapRelocsMode::ElfReloc)
484+
if (ctx.arg.useRelativeCheriRelocs)
485485
error("local-cap-relocs=elf is not implemented yet");
486486

487487
if (ctx.arg.executeOnly) {
@@ -863,19 +863,6 @@ static CapTableScopePolicy getCapTableScope(opt::InputArgList &args) {
863863
llvm_unreachable("Invalid arg");
864864
}
865865

866-
static CapRelocsMode getLocalCapRelocsMode(opt::InputArgList &args) {
867-
auto *arg =
868-
args.getLastArg(OPT_local_caprelocs_legacy, OPT_local_caprelocs_elf);
869-
if (!arg) // TODO: change default to ElfReloc
870-
return CapRelocsMode::Legacy;
871-
if (arg->getOption().getID() == OPT_local_caprelocs_legacy) {
872-
return CapRelocsMode::Legacy;
873-
} else if (arg->getOption().getID() == OPT_local_caprelocs_elf) {
874-
return CapRelocsMode::ElfReloc;
875-
}
876-
llvm_unreachable("Invalid arg");
877-
}
878-
879866
static StringRef getDynamicLinker(Ctx &ctx, opt::InputArgList &args) {
880867
auto *arg = args.getLastArg(OPT_dynamic_linker, OPT_no_dynamic_linker);
881868
if (!arg)
@@ -1485,7 +1472,9 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
14851472
ctx.arg.ignoreFunctionAddressEquality =
14861473
args.hasArg(OPT_ignore_function_address_equality);
14871474
ctx.arg.init = args.getLastArgValue(OPT_init, "_init");
1488-
ctx.arg.localCapRelocsMode = getLocalCapRelocsMode(args);
1475+
// TODO: change default to true
1476+
ctx.arg.useRelativeCheriRelocs =
1477+
args.hasFlag(OPT_local_caprelocs_elf, OPT_local_caprelocs_legacy, false);
14891478
ctx.arg.ltoAAPipeline = args.getLastArgValue(OPT_lto_aa_pipeline);
14901479
ctx.arg.ltoCSProfileGenerate = args.hasArg(OPT_lto_cs_profile_generate);
14911480
ctx.arg.ltoCSProfileFile = args.getLastArgValue(OPT_lto_cs_profile_file);

0 commit comments

Comments
 (0)