This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Remove empty output sections


On Mon, Mar 14, 2005 at 08:10:48AM -0800, H. J. Lu wrote:
> On Mon, Mar 14, 2005 at 07:05:15PM +1030, Alan Modra wrote:
> > On Sun, Mar 13, 2005 at 10:31:41PM -0800, H. J. Lu wrote:
> > > @@ -4883,7 +4893,7 @@ lang_process (void)
> > >      lang_check_section_addresses ();
> > >  
> > >    /* Final stuffs.  */
> > > -
> > > +  lang_mark_used_section ();
> > >    ldemul_finish ();
> > >    lang_finish ();
> > >  }
> > 
> > Isn't this too late to strip sections?  What happens if one of the
> > sections stripped has a dynamic section symbol?
> 
> An empty section has a dynamic section symbol. Do you have a testcase
> for that?

Easy.  This also demonstrates another potential problem with removing
empty sections;  Their alignment can affect layout of other sections.

$ cat > dynsym.s <<EOF
 .section .text2,"ax",@progbits
 .p2align 12

 .text
 nop

 .data
 .long 123
EOF
$ cat > dynsym.lnk <<EOF
SECTIONS
{
  .text : { *(.text) }
  .text2 : { *(.text2) }
  .data : { *(.data) }
  .bss : { *(.bss) }
}
EOF
$ as -o dynsym.o dynsym.s
$ ld -o dynsym -shared -T dynsym.lnk dynsym.o

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]