RFC: Remove empty output sections
H. J. Lu
hjl@lucon.org
Fri Mar 18 07:07:00 GMT 2005
On Fri, Mar 18, 2005 at 12:33:10PM +1030, Alan Modra wrote:
> On Thu, Mar 17, 2005 at 05:49:29PM -0800, H. J. Lu wrote:
> > On Fri, Mar 18, 2005 at 12:06:51PM +1030, Alan Modra wrote:
> > > Hi HJ,
> > > It seems your change to remove zero-size output sections is
> > > responsible for segfaults when generating map files. For example,
> > > taking something from the ld testsuite with -Map added:
> > >
> > > $ gcc -L/home/alan/build/ppc/bin/./ld -B/home/alan/build/ppc/bin/ld/tmpdir/ld/ -L/usr/local/powerpc-linux/lib -L/usr/local/lib -L/lib -L/usr/lib -o tmpdir/libsize_bar.so --shared tmpdir/size_bar.o -Wl,-Map,xxx.map
> > > collect2: ld terminated with signal 11 [Segmentation fault]
> > >
> > > On powerpc-linux this particular .so has an empty .bss, and the linker
> > > script has an ALIGN inside the .bss output section. Processing ALIGN_K
> > > in ldexp.c refeferences the bfd_section, which is now NULL. I expect
> > > other linker expressions will similarly segfault if their associated
> > > output section is removed before the linker map is printed. Would you
> > > take a look, please?
> > >
> > > A solution that might work is to simply not clear os->bfd_section in
> > > gld${EMULATION_NAME}_finish.
> >
> > Can you send me a testcase?
>
> $ echo > empty.s
> $ ../gas/as-new -o empty.o empty.s
> $ ./ld-new -shared -Map empty.map -o empty.so empty.o
> Segmentation fault
>
How about this patch?
H.J.
----
2005-03-17 H.J. Lu <hongjiu.lu@intel.com>
* emultempl/elf32.em (gld${EMULATION_NAME}_finish): Set
bfd_section to bfd_abs_section_ptr when removing unused empty
output sections for non-relocatable link.
--- ld/emultempl/elf32.em.abs 2005-03-16 21:20:12.000000000 -0800
+++ ld/emultempl/elf32.em 2005-03-17 18:56:46.662523655 -0800
@@ -1459,7 +1459,7 @@ gld${EMULATION_NAME}_finish (void)
{
asection **p;
- os->bfd_section = NULL;
+ os->bfd_section = bfd_abs_section_ptr;
for (p = &output_bfd->sections; *p; p = &(*p)->next)
if (*p == s)
More information about the Binutils
mailing list