Skip to content

Commit 4f6a35a

Browse files
jrtc27resistor
authored andcommitted
[ELF][CHERI] Delete various unnecessary error messages and asserts
Some of these error messages should really have been asserts. Many of these are now so clearly impossible due to the surrounding code that they serve no point, and in general this is way more paranoid than LLD typically is, in ways that make it harder to actually follow the code. Delete this clutter.
1 parent 4b82cef commit 4f6a35a

File tree

1 file changed

+1
-28
lines changed

1 file changed

+1
-28
lines changed

lld/ELF/Arch/Cheri.cpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -958,39 +958,12 @@ void addCapabilityRelocation(
958958
return;
959959
}
960960

961-
assert(sym && "ELF relocs should not be used against sections");
962-
assert((sym->isPreemptible || needTrampoline) &&
963-
"ELF relocs should not be used for non-preemptible symbols");
964-
assert((!sym->isLocal() || needTrampoline) &&
965-
"ELF relocs should not be used for local symbols");
966-
if (!lld::elf::hasDynamicLinker(ctx)) {
967-
error("attempting to emit a R_CAPABILITY relocation against " +
968-
(sym->getName().empty() ? "local symbol"
969-
: "symbol " + toStr(ctx, *sym)) +
970-
" in binary without a dynamic linker; try removing -Wl,-" +
971-
(sym->isPreemptible ? "preemptible" : "local") + "-caprelocs=elf" +
972-
referencedBy());
973-
return;
974-
}
975-
assert(ctx.hasDynsym && "Should have been checked in Driver.cpp");
976961
// We don't use a R_MIPS_CHERI_CAPABILITY relocation for the input but
977962
// instead need to use an absolute pointer size relocation to write
978963
// the offset addend
979964
if (!dynRelSec)
980965
dynRelSec = ctx.mainPart->relaDyn.get();
981-
// in the case that -local-caprelocs=elf is passed we need to ensure that
982-
// the target symbol is included in the dynamic symbol table
983-
if (!ctx.mainPart->dynSymTab) {
984-
error("R_CHERI_CAPABILITY relocations need a dynamic symbol table");
985-
return;
986-
}
987-
if (!isSymIncludedInDynsym(ctx, *sym)) {
988-
if (!needTrampoline) {
989-
error("added a R_CHERI_CAPABILITY relocation but symbol not included "
990-
"in dynamic symbol: " +
991-
verboseToString(ctx, sym));
992-
return;
993-
}
966+
if (needTrampoline && !isSymIncludedInDynsym(ctx, *sym)) {
994967
// Hack: Add a new global symbol with a unique name so that we can use
995968
// a dynamic relocation against it.
996969
// TODO: should it be possible to add STB_LOCAL symbols to .dynsymtab?

0 commit comments

Comments
 (0)