From 749189b245dfb96139202c89d1727b3ce47d984c Mon Sep 17 00:00:00 2001 From: Toshikazu Nakayama Date: Thu, 11 Nov 2010 14:11:30 +0900 Subject: [PATCH 5/5] fixed remained problems. To check whether symbol is module percpu or not, rename pad2 with flags and set MODULE_SYMBOL when loaded module's symbols are installed. lm->mod_load_symtable only used malloc() for syment, changed calloc() to be set fields with 0. Fix mistake about gnu_request's buffer (and remove comment). Signed-off-by: Toshikazu Nakayama --- defs.h | 4 +++- symbols.c | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/defs.h b/defs.h index 4b77475..d22dd74 100755 --- a/defs.h +++ b/defs.h @@ -1912,6 +1912,8 @@ struct alias_data { /* command alias storage */ #endif /* !GDB_COMMON */ +#define MODULE_SYMBOL (1<<0) +#define IS_MODULE_SYMBOL(SYM) (SYM->flags & MODULE_SYMBOL) struct syment { ulong value; char *name; @@ -1920,7 +1922,7 @@ struct syment { char type; unsigned char cnt; unsigned char pad1; - unsigned char pad2; + unsigned char flags; }; #define NAMESPACE_INIT (1) diff --git a/symbols.c b/symbols.c index 73325ed..82b9023 100755 --- a/symbols.c +++ b/symbols.c @@ -5724,6 +5724,8 @@ static struct load_module *get_mod_percpu_sym_owner(struct syment *sp) int i; struct load_module *lm; + if (!IS_MODULE_SYMBOL(sp)) + return NULL; /* * Find out percpu symbol owner module. * If found out, sp is module's percpu symbol. @@ -8867,15 +8869,15 @@ add_symbol_file(struct load_module *lm) } #ifdef GDB_7_0 -static long add_symbol_file_percpu(struct load_module *lm, char *buf, - long buflen) +static long add_symbol_file_percpu(struct load_module *lm, + struct gnu_request *req, long buflen) { char pbuf[BUFSIZE]; int i; char *secname; long len; - len = strlen(buf); + len = strlen(req->buf); for (i = 0; i < lm->mod_sections; i++) { secname = lm->mod_section_data[i].name; if ((lm->mod_section_data[i].flags & SEC_FOUND) && @@ -8883,10 +8885,10 @@ static long add_symbol_file_percpu(struct load_module *lm, char *buf, STREQ(secname, ".data..percpu"))) { sprintf(pbuf, " -s %s 0x%lx", secname, lm->mod_percpu); while ((len + strlen(pbuf)) >= buflen) { - RESIZEBUF(buf, buflen, buflen * 2); + RESIZEBUF(req->buf, buflen, buflen * 2); buflen *= 2; } - strcat(buf, pbuf); + strcat(req->buf, pbuf); len += strlen(pbuf); } } @@ -9112,8 +9114,7 @@ add_symbol_file_kallsyms(struct load_module *lm, struct gnu_request *req) return FALSE; } - /* too ugly but gdb registration request must be one-shot. */ - buflen = add_symbol_file_percpu(lm, req->buf, buflen); + buflen = add_symbol_file_percpu(lm, req, buflen); lm->mod_flags |= MOD_NOPATCH; req->command = GNU_ADD_SYMBOL_FILE; @@ -9256,7 +9257,7 @@ store_load_module_symbols(bfd *bfd, int dynamic, void *minisyms, if (!lm->mod_load_symtable) { if ((lm->mod_load_symtable = (struct syment *) - malloc(symalloc * sizeof(struct syment))) == NULL) + calloc(symalloc, sizeof(struct syment))) == NULL) error(FATAL, "module syment space malloc: %s\n", strerror(errno)); @@ -9414,6 +9415,7 @@ store_load_module_symbols(bfd *bfd, int dynamic, void *minisyms, syminfo.type)) { sp->value = syminfo.value; sp->type = syminfo.type; + sp->flags |= MODULE_SYMBOL; namespace_ctl(NAMESPACE_INSTALL, &lm->mod_load_namespace, sp, name); -- 1.7.3.2.164.g6f10c