Skip to content

Commit 270c311

Browse files
jrtc27resistor
authored andcommitted
Revert "cheri_init_globals.h: Explicitly set NULL capabilities"
LLD now writes the NULL-derived capability instead of emitting a capreloc. This code was a bit broken for relative caprelocs, where this is an offset relative to the load base, not the absolute address, and so 0 could legitimately be a valid object. It also failed to add the offset, and doesn't work when PCC bounds are correctly set by LLD as function capabilities can legitimately have their base be the start of the object even when the function is at a non-zero offset (and it is for this reason that Morello disables this case downstream, though handled this case in LLD just as CHERI-MIPS and CHERI-RISC-V used to, so ended up trying to derive an actual capability, with a non-zero address if a PIE or DSO). This reverts commit 18506d3.
1 parent 7829a8b commit 270c311

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

clang/lib/Headers/cheri_init_globals.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ cheri_init_globals_impl(const struct capreloc *start_relocs,
169169
const void *__capability *__capability dest =
170170
(const void *__capability *__capability)cheri_address_or_offset_set(
171171
data_cap, reloc->capability_location + base_addr);
172-
if (reloc->object == 0) {
173-
/* XXXAR: clang fills uninitialized capabilities with 0xcacaca..., so we
174-
* we need to explicitly write NULL here */
175-
*dest = (void *__capability)0;
176-
continue;
177-
}
178172
const void *__capability base_cap;
179173
bool can_set_bounds = true;
180174
if ((reloc->permissions & function_reloc_flag) == function_reloc_flag) {

0 commit comments

Comments
 (0)