This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [ARM] Avoid dereferencing null pointers
On Wed, 20 Nov 2019 at 23:25, Alan Modra <amodra@gmail.com> wrote:
>
> On Thu, Nov 21, 2019 at 08:31:57AM +1030, Alan Modra wrote:
> > On Thu, Nov 21, 2019 at 08:19:03AM +1030, Alan Modra wrote:
> > > Using this should work:
> > >
> > > if (!is_arm_elf (input_bfd)
> > > || elf_sym_hashes (input_bfd) == 0
> > > || (elf_dyn_lib_class (inputif ((input_bfd->flags & DYNAMIC) != 0
&& (elf_sym_hashes (input_bfd) == NULL
|| (e_bfd) & DYN_AS_NEEDED) != 0)
> > > continue;
> >
> > Actually, that might not be such a good idea. An object without any
> > global symbols will have sym_hashes NULL too.
>
> So, getting back to this after a small interruption,
Thanks, this works for me. I don't know what I didn't see this problem
until now :-(
>
> if (!is_arm_elf (input_bfd))
> continue;
> if ((input_bfd->flags & DYNAMIC) != 0
> && (elf_sym_hashes (input_bfd) == NULL
I'm not sure I understand your comment about an object without any
global symbols: whatever the reason, if sym_hashes is NULL, cmse_scan
will crash, won't it?
Also, I see cmse_scan has an early exit when local_syms is NULL,
wouldn't it be cleaner to check if sym_hashes is NULL is cmse_scan
too?
> || (elf_dyn_lib_class (input_bfd) & DYN_AS_NEEDED) != 0))
> continue;
>
> --
> Alan Modra
> Australia Development Lab, IBM