On 2023/05/30 14:36, lijiang wrote:
On Thu, May 11, 2023 at 12:35 PM HAGIO KAZUHITO(萩尾 一仁)
<k-hagio-ab(a)nec.com>
wrote:
> Signed-off-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
> ---
> symbols.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 78 insertions(+), 3 deletions(-)
>
> diff --git a/symbols.c b/symbols.c
> index db22f3c4e8b3..4c7fe06b3aad 100644
> --- a/symbols.c
> +++ b/symbols.c
> @@ -5370,7 +5370,7 @@ old_module:
> struct syment *
> symbol_search_next(char *s, struct syment *spstart)
> {
> - int i;
> + int i, j;
> struct syment *sp, *sp_end;
> struct load_module *lm;
> int found_start;
> @@ -5390,6 +5390,31 @@ symbol_search_next(char *s, struct syment *spstart)
> }
> }
>
> + if (!MODULE_MEMORY())
> + goto old_module;
> +
> + for (i = 0; i < st->mods_installed; i++) {
> + lm = &st->load_modules[i];
> + for (j = MOD_TEXT; j < MOD_MEM_NUM_TYPES; j++) {
> + if (!lm->symtable[j])
> + continue;
> +
> + sp = lm->symtable[j];
> + sp_end = lm->symend[j];
> + for (; sp < sp_end; sp++) {
> + if (sp == spstart) {
> + found_start = TRUE;
> + continue;
> + } else if (!found_start)
> + continue;
> +
> + if (STREQ(s, sp->name))
> + return sp;
> + }
> + }
> + }
>
For the module memory case, if the given symbol name is not found in the
above for-loop, does it need to return a NULL entry as below?
return((struct syment *)NULL);
Otherwise it will continue to search for the symbol name from the following
old_module code block.
Good catch! Thanks.
> +
> +old_module:
> pseudos = (strstr(s, "_MODULE_START_") || strstr(s,
> "_MODULE_END_"));
> search_init = FALSE;
>
> @@ -6536,7 +6561,7 @@ kernel_symbol_search(char *symbol)
> int
> get_syment_array(char *symbol, struct syment **sp_array, int max)
> {
> - int i, cnt;
> + int i, j, cnt;
> struct syment *sp, *sp_end;
> struct load_module *lm;
>
> @@ -6561,6 +6586,31 @@ get_syment_array(char *symbol, struct syment
> **sp_array, int max)
> }
> }
>
> + if (!MODULE_MEMORY())
> + goto old_module;
> +
> + for (i = 0; i < st->mods_installed; i++) {
> + lm = &st->load_modules[i];
> +
> + for (j = MOD_TEXT; j < MOD_MEM_NUM_TYPES; j++) {
> + if (!lm->symtable[j])
> + continue;
> +
> + sp = lm->symtable[j];
> + sp_end = lm->symend[j];
> + for (; sp < sp_end; sp++) {
> + if (STREQ(symbol, sp->name)) {
> + if (max && (cnt < max))
> + sp_array[cnt] = sp;
> + cnt++;
> + }
> + }
> + }
> + }
> +
> + return cnt;
> +
> +old_module:
> for (i = 0; i < st->mods_installed; i++) {
> lm = &st->load_modules[i];
> sp = lm->mod_symtable;
> @@ -14712,7 +14762,7 @@ is_downsized(char *name)
> struct syment *
> symbol_complete_match(const char *match, struct syment *sp_last)
> {
> - int i;
> + int i, j;
> struct syment *sp, *sp_end, *sp_start;
> struct load_module *lm;
> int search_init;
> @@ -14732,6 +14782,31 @@ symbol_complete_match(const char *match, struct
> syment *sp_last)
> sp_start = NULL;
> }
>
> + if (!MODULE_MEMORY())
> + goto old_module;
> +
> + for (i = 0; i < st->mods_installed; i++) {
> + lm = &st->load_modules[i];
> + for (j = MOD_TEXT; j < MOD_MEM_NUM_TYPES; j++) {
> + sp_end = lm->symend[j];
> + if (!sp_start)
> + sp_start = lm->symtable[j];
> +
> + if (sp_start < lm->symtable[j] || sp_start >
> sp_end)
> + continue;
> +
> + for (sp = sp_start; sp < sp_end; sp++) {
> + if (MODULE_PSEUDO_SYMBOL(sp))
> + continue;
> +
> + if (STRNEQ(sp->name, match))
> + return sp;
> + }
> + sp_start = NULL;
> + }
> + }
>
Ditto.
Ugh, will fix.
Thanks,
Kazu
>
> Thanks
> Lianbo
>
> +
>> +old_module:
>> search_init = FALSE;
>>
>> for (i = 0; i < st->mods_installed; i++) {
>> --
>> 2.31.1
>>