This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [RFA:] Ignore --gc-sections if non-ELF objects are involved
On Tue, Mar 26, 2002 at 11:53:07AM +0100, Hans-Peter Nilsson wrote:
> > Date: Tue, 26 Mar 2002 11:15:12 +1030
> > From: Alan Modra <amodra@bigpond.net.au>
>
> (I hope this answers Catherine's concerns too.)
>
> > On Tue, Mar 26, 2002 at 12:15:50AM +0100, Hans-Peter Nilsson wrote:
> > > The test currently SEGV:s.
> >
> > Why?
>
> Sorry, I thought that was obvious, at least from the test-case.
> I see my report was too terse. The test-case links an a.out
> object with an ELF object, producing ELF. This works when GC
> isn't involved.
That much was obvious.
> Right, it's a "don't do that then" but SEGV is
> inappropriate anyway. The SEGV:s happens in
> elflink.h:elf_gc_mark, on:
But where the segv occurred wasn't so obvious.
> group_sec = elf_section_data (sec)->next_in_group;
This says to me that we need to protect the recursive call to
elf_gc_mark to ensure that rsec is ELF. Does it make sense to
continue GC with non-ELF sections involved? Maybe. The non-ELF
sections won't be dropped, but relocs referencing ELF sections
from the non-ELF BFD won't stop ELF sections from being dropped.
So that could be dangerous. A more typical case might be ELF
+ a binary input BFD. That shouldn't stop GC operating correctly.
I'm applying the following, and I think a variation of your patch
that warns on finding non-ELF input BFDs _with relocs_, but doesn't
stop GC, is the best solution.
* elflink.h (elf_gc_mark): Don't recurse into non-ELF sections.
Index: bfd/elflink.h
===================================================================
RCS file: /cvs/src/src/bfd/elflink.h,v
retrieving revision 1.152
diff -u -p -r1.152 elflink.h
--- elflink.h 2002/03/19 20:21:54 1.152
+++ elflink.h 2002/03/26 11:44:56
@@ -7570,11 +7570,15 @@ elf_gc_mark (info, sec, gc_mark_hook)
}
if (rsec && !rsec->gc_mark)
- if (!elf_gc_mark (info, rsec, gc_mark_hook))
- {
- ret = false;
- goto out2;
- }
+ {
+ if (bfd_get_flavour (rsec->owner) != bfd_target_elf_flavour)
+ rsec->gc_mark = 1;
+ else if (!elf_gc_mark (info, rsec, gc_mark_hook))
+ {
+ ret = false;
+ goto out2;
+ }
+ }
}
out2:
--
Alan Modra
IBM OzLabs - Linux Technology Centre