RFC: Remove empty output sections

Alan Modra amodra@bigpond.net.au
Fri Mar 18 03:51:00 GMT 2005


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

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list