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.
--
Crash-utility mailing list
Crash-utility@redhat.com
https://www.redhat.com/mailman/listinfo/crash-utility
07-05-2012, 10:25 PM
Dave Anderson
crash read symbols bug
----- Original Message -----
> > sp-1 will be NULL if sp pointer the first element in symbol
> > table, so
> > (sp-1)->value w! ill cause segment fault.
> > S! o 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 hope you could give me some advices.
>
> Looks good to me, although I would prefer "if (sp == st->symtable)" to make
> it a bit clearer.
But wait a minute -- how did you get past the address value check at the
top of value_search_base_kernel():