This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: RFC: Add bfd_get_section_ident
"H. J. Lu" <hjl@lucon.org> writes:
> Here is the start. I can make other changes to make
>
> # objdump -j section
>
> work with multiple sections with the same name.
bfd_get_section_ident() is a space leak. It should use bfd_alloc(),
not bfd_malloc(). If allocation fails, I think it should return NULL,
not silently return the wrong value. (This is more or less the
conversation we just had a couple of weeks ago.)
Now, that said, do we really need two new fields in asection? That
can be pretty costly in the linker, with regard to memory space.
> +void
> +_bfd_elf_setup_group_pointers (bfd *abfd)
> +{
> + unsigned int i;
> + unsigned int num_group = elf_tdata (abfd)->num_group;
> +
> + if (num_group == (unsigned) -1)
> + return;
> +
> + for (i = 0; i < num_group; i++)
> + {
> + Elf_Internal_Shdr *shdr = elf_tdata (abfd)->group_sect_ptr[i];
> + Elf_Internal_Group *idx = (Elf_Internal_Group *) shdr->contents;
> + unsigned int n_elt = shdr->sh_size / 4;
> +
> + while (--n_elt != 0)
> + (++idx)->shdr->bfd_section->group = shdr->bfd_section;
> + }
> +}
Is the assignment to n_elt correct in always dividing by 4?
I'd like to hear whether anybody else has comments.
Ian