From: Rusty Russell <rusty@rustcorp.com.au>
To: "Jan Beulich" <JBeulich@novell.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] reduce symbol table for loaded modules
Date: Wed, 1 Jul 2009 15:46:21 +0930 [thread overview]
Message-ID: <200907011546.21597.rusty@rustcorp.com.au> (raw)
In-Reply-To: <4A4A1C6C0200007800008369@vpn.id2.novell.com>
On Tue, 30 Jun 2009 09:38:43 pm Jan Beulich wrote:
> Discard all symbols not interesting for kallsyms use: absolute,
> section, and in the common case (!KALLSYMS_ALL) data ones.
I like the idea, but implementation could probably be polished a little bit.
> +static unsigned int filter_symbols(Elf_Sym *dst,
> + const Elf_Sym *src, unsigned int nsrc,
> + const Elf_Shdr *sechdrs, unsigned int shnum)
How about splitting the test out to an:
bool is_core_symbol(const Elf_Sym *src, const Elf_Shdr *sechdrs, unsigned int shnum)
Then split filter_symbols into num_core_symbols() and copy_core_symbols().
> +static unsigned long layout_symtab(struct module *mod,
How about append_symbols() instead?
> + Elf_Shdr *sechdrs,
> + unsigned int symindex,
> + const Elf_Ehdr *hdr,
> + const char *secstrings)
> +{
> + unsigned long symoffs;
> + Elf_Shdr *symsect = sechdrs + symindex;
> +
Comment would help me here:
/* Put symbol section at end of init part of module. */
> + symsect->sh_flags |= SHF_ALLOC;
> + symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
> + symindex) | INIT_OFFSET_MASK;
> + DEBUGP("\t%s\n", secstrings + symsect->sh_name);
> +
Here too:
/* Append room for core symbols at end of core part. */
> + symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
> + mod->core_size = symoffs
> + + filter_symbols(NULL,
> + (void *)hdr + symsect->sh_offset,
> + symsect->sh_size / sizeof(Elf_Sym),
> + sechdrs, hdr->e_shnum)
> + * sizeof(Elf_Sym);
> +
> + return symoffs;
> +}
> +
> static void add_kallsyms(struct module *mod,
> Elf_Shdr *sechdrs,
> + unsigned int shnum,
> unsigned int symindex,
> unsigned int strindex,
> + unsigned long symoffs,
> const char *secstrings)
> {
> unsigned int i;
> @@ -1857,12 +1914,26 @@ static void add_kallsyms(struct module *
> for (i = 0; i < mod->num_symtab; i++)
> mod->symtab[i].st_info
> = elf_type(&mod->symtab[i], sechdrs, secstrings, mod);
> +
> + mod->core_symtab = mod->module_core + symoffs;
> + mod->core_num_syms = filter_symbols(mod->core_symtab,
> + mod->symtab, mod->num_symtab,
> + sechdrs, shnum);
Hmm, could avoid symoffs if copy_core_symbols worked backwards. Probably
not worthwhile tho.
> trim_init_extable(mod);
> +#ifdef CONFIG_KALLSYMS
> + mod->num_symtab = mod->core_num_syms;
> + mod->symtab = mod->core_symtab;
> +#endif
> module_free(mod, mod->module_init);
> mod->module_init = NULL;
> mod->init_size = 0;
core_num_syms/core_symtab is really a temporary; we should note that in
the module.h header next to those fields.
Thanks!
Rusty.
prev parent reply other threads:[~2009-07-01 6:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-30 12:08 [PATCH 1/2] reduce symbol table for loaded modules Jan Beulich
2009-07-01 6:16 ` Rusty Russell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200907011546.21597.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=JBeulich@novell.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.