diff --git a/sys/kern/link_aout.c b/sys/kern/link_aout.c index 50d1e1c88452..bc461014f41e 100644 --- a/sys/kern/link_aout.c +++ b/sys/kern/link_aout.c @@ -563,19 +563,21 @@ link_aout_search_symbol(linker_file_t lf, caddr_t value, struct nzlist* sp; struct nzlist* ep; struct nzlist* best = 0; + u_long sp_nz_value; for (sp = AOUT_RELOC(af, struct nzlist, LD_SYMBOL(af->dynamic)), ep = (struct nzlist *) ((caddr_t) sp + LD_STABSZ(af->dynamic)); sp < ep; sp++) { if (sp->nz_name == 0) continue; - if (off >= sp->nz_value) { - if (off - sp->nz_value < diff) { - diff = off - sp->nz_value; + sp_nz_value = sp->nz_value + (u_long)af->address; + if (off >= sp_nz_value) { + if (off - sp_nz_value < diff) { + diff = off - sp_nz_value; best = sp; if (diff == 0) break; - } else if (off - sp->nz_value == diff) { + } else if (off - sp_nz_value == diff) { best = sp; } }