Dear ,
I ported crash tool to Loongson platform which is a Mips-like CPU
developed by Institute of Computing Technology,Chinese Academic of science.
In my work process,I found a bug in crash when run on Loongson
platform.but the bug doesn't happen in x86 platform. Funcation name
is value_search_base_kernel in symbols.c ,line 4302,version
is crash-6.0.8. code segments as follow:
for ( ; sp < st->symend; sp++) {
if (value == sp->value) {
if (offset)
*offset = 0;
return((struct syment *)sp);
}
if (sp->value > value) {
if (offset)
*offset = value - ((sp-1)->value);
return((struct syment *)(sp-1));
}
}
sp-1 will be NULL if sp pointer the first element in symbol table, so
(sp-1)->value will cause segment fault.
So I modify the code segment as follow:
if (sp->value > value) {
if (sp - st->symtable == 0) return NULL;
if (offset)
*offset = value - ((sp-1)->value);
return((struct syment *)(sp-1));
}
Is that OK?
I wish you all the best.