--build-id use of elf_obj_tdata

Alan Modra amodra@gmail.com
Mon Feb 18 23:31:00 GMT 2013


On Mon, Feb 18, 2013 at 04:18:58PM +0100, Jan Kratochvil wrote:
> >    if (!bfd_check_format (abfd, bfd_object)
> >        || bfd_get_flavour (abfd) != bfd_target_elf_flavour
> > -      || elf_tdata (abfd)->build_id == NULL)
> > +      || elf_tdata (abfd)->build_id == NULL
> > +      || elf_tdata (abfd)->build_id->u.i.size == 0)
> 
> Just here I do not see why the new condition 'u.i.size == 0' is needed, even
> if (improbably) the build-id section is empty GDB can handle such 0-length
> struct elf_build_id fine.

See elf-bfd struct elf_build_id_info.  Zero u.i.size says you have the
union u.o field valid.  (I use u.i.size aka u.o.zero instead of
another field to specify the type of union.)  It's true that for gdb
you are always operating on input bfds, so the test is redundant.
Leaving the test as is, removing it, or replacing with an assert are
all valid options.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list