[RFC/PATCH] reduce load time for modules with lots of relocs

Stephen Rothwell sfr at canb.auug.org.au
Tue Nov 6 15:29:57 EST 2007


On Mon, 5 Nov 2007 20:33:55 -0600 Nathan Lynch <ntl at pobox.com> wrote:
>
>  static unsigned int count_relocs(const Elf32_Rela *rela, unsigned int num)
>  {
> -	unsigned int i, j, ret = 0;
> +	unsigned int i, sorted_count = 0;
> +	Elf32_Word last_info;
> +	Elf32_Sword last_addend;
> +	Elf32_Rela **sortbuf = NULL;

You don't need to initialise sortbuf and f you make it a "const
Elf32_Rela **" ...

> +	sortbuf = vmalloc(num * sizeof(*sortbuf));
> +	if (!sortbuf)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < num; i++)
> +		sortbuf[i] = (Elf32_Rela *)&rela[i];

You shouldn't need that cast.

> -static unsigned int count_relocs(const Elf64_Rela *rela, unsigned int num)
> +static int count_relocs(const Elf64_Rela *rela, unsigned int num)
>  {
>  	unsigned int i, j, ret = 0;
> +	Elf64_Xword last_info;
> +	Elf64_Sxword last_addend;
> +	Elf64_Rela **sortbuf = NULL;

Same here.

-- 
Cheers,
Stephen Rothwell                    sfr at canb.auug.org.au
http://www.canb.auug.org.au/~sfr/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20071106/f4a24991/attachment.pgp>


More information about the Linuxppc-dev mailing list