Skip to content

Commit 95819a2

Browse files
refactor(symres): drop the dead ResolverCacheEntry.load_base field
cache_entry->load_base was written in three places (cache open, FindFde, Resolve) and never read -- every path recomputes the precise bias into a local. The per-resolve store was a dead store mull flagged (cxx_assign_const) that no test can kill because nothing observes the field. Remove the field, its find_or_open parameter, and the three writes; the white-box Mut.c test that passed an incidental load_base arg is updated. With this, the SymbolResolver mutation suite intersection converges to 0 true survivors.
1 parent eaa0013 commit 95819a2

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

Include/Misra/Sys/SymbolResolver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ typedef struct ResolvedSymbol {
7474

7575
typedef struct ResolverCacheEntry {
7676
Zstr path; // borrowed from ProcMaps.raw
77-
u64 load_base;
7877
Elf elf;
7978
// Sidecar debug file found via .gnu_debuglink or .note.gnu.build-id.
8079
// Populated lazily for stripped binaries that have an installed

Source/Misra/Sys/SymbolResolver.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static bool try_open_sidecar(Zstr main_path, const Elf *main, Elf *out, Allocato
140140
// Cache management
141141
// ---------------------------------------------------------------------------
142142

143-
static ResolverCacheEntry *resolver_cache_find_or_open(SymbolResolver *self, Zstr path, u64 load_base) {
143+
static ResolverCacheEntry *resolver_cache_find_or_open(SymbolResolver *self, Zstr path) {
144144
for (u64 i = 0; i < VecLen(&self->cache); ++i) {
145145
ResolverCacheEntry *e = VecPtrAt(&self->cache, i);
146146
if (e->path == path) {
@@ -156,8 +156,7 @@ static ResolverCacheEntry *resolver_cache_find_or_open(SymbolResolver *self, Zst
156156

157157
ResolverCacheEntry entry;
158158
MemSet(&entry, 0, sizeof(entry));
159-
entry.path = path;
160-
entry.load_base = load_base;
159+
entry.path = path;
161160
if (!ElfOpen(&entry.elf, path, self->allocator)) {
162161
return NULL;
163162
}
@@ -269,12 +268,11 @@ bool SymbolResolverFindFde(
269268
if (!entry || !entry->path || entry->path[0] == '\0')
270269
return false;
271270

272-
ResolverCacheEntry *cache_entry = resolver_cache_find_or_open(self, entry->path, entry->start - entry->file_offset);
271+
ResolverCacheEntry *cache_entry = resolver_cache_find_or_open(self, entry->path);
273272
if (!cache_entry)
274273
return false;
275274
// p_vaddr-space bias (not the file-offset shortcut) -- see resolver_load_bias.
276-
u64 load_base = resolver_load_bias(&cache_entry->elf, entry->start, entry->file_offset, addr);
277-
cache_entry->load_base = load_base;
275+
u64 load_base = resolver_load_bias(&cache_entry->elf, entry->start, entry->file_offset, addr);
278276

279277
if (!cache_entry->cfi_built) {
280278
cache_entry->cfi_built = true;
@@ -354,15 +352,14 @@ bool SymbolResolverResolve(SymbolResolver *self, void *runtime_addr, ResolvedSym
354352
return false;
355353
}
356354

357-
ResolverCacheEntry *cache_entry = resolver_cache_find_or_open(self, entry->path, entry->start - entry->file_offset);
355+
ResolverCacheEntry *cache_entry = resolver_cache_find_or_open(self, entry->path);
358356
if (!cache_entry) {
359357
return false;
360358
}
361359
// Correct load bias in p_vaddr space (see resolver_load_bias). Covers
362360
// PIE / shared objects; for ET_EXEC the first PT_LOAD's p_vaddr already
363361
// equals the mapping start, so the absolute base still falls out.
364-
u64 load_base = resolver_load_bias(&cache_entry->elf, entry->start, entry->file_offset, addr);
365-
cache_entry->load_base = load_base;
362+
u64 load_base = resolver_load_bias(&cache_entry->elf, entry->start, entry->file_offset, addr);
366363

367364
out->module_path = entry->path;
368365
out->module_base = load_base;

Tests/Std/SymbolResolver.Mut.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ bool test_srmut_cache_zstrcompare_fallback_hits(void) {
7676
bool ok = (p1 != p2); // genuinely distinct pointers
7777

7878
// Miss -> opens + inserts entry with path == p1.
79-
ResolverCacheEntry *e1 = resolver_cache_find_or_open(&res, p1, 0x1000);
79+
ResolverCacheEntry *e1 = resolver_cache_find_or_open(&res, p1);
8080
ok = ok && e1 != NULL;
8181
ok = ok && VecLen(&res.cache) == 1;
8282

8383
// Lookup with the OTHER buffer: pointer differs from p1, so only the
8484
// ZstrCompare fallback can recognise it as the same module.
85-
ResolverCacheEntry *e2 = resolver_cache_find_or_open(&res, p2, 0x2000);
85+
ResolverCacheEntry *e2 = resolver_cache_find_or_open(&res, p2);
8686
ok = ok && e2 == e1; // same cached entry reused
8787
ok = ok && VecLen(&res.cache) == 1; // no duplicate open
8888

@@ -118,8 +118,7 @@ bool test_srmut_deinit_frees_sidecar(void) {
118118

119119
ResolverCacheEntry entry;
120120
MemSet(&entry, 0, sizeof(entry));
121-
entry.path = file;
122-
entry.load_base = 0x1000;
121+
entry.path = file;
123122

124123
bool ok = ElfOpen(&entry.elf, file, ALLOCATOR_OF(&alloc));
125124
if (ok)

0 commit comments

Comments
 (0)