This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: RFC: Remove empty output sections
On Tue, Mar 15, 2005 at 08:45:44AM +1030, Alan Modra wrote:
> 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.
>
Here is the output from readelf -Sls after removing empty sections.
Removing an empty section will certainly change the layout of other
sections. I don't think it should be a problem. I believe that
anything depending on alignment of an empty section is broken.
3 local entries in .dynsym have UND index since they are removed. It
is hard to remove them since it is done too late. I don't think it
should cause any probleme though.
H.J.
-----
There are 11 section headers, starting at offset 0x2164:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 00000000 001000 000001 00 AX 0 0 4
[ 2] .dynsym DYNSYM 00001000 002000 000070 10 A 3 4 4
[ 3] .dynstr STRTAB 00001070 002070 00000a 00 A 0 0 1
[ 4] .hash HASH 0000107c 00207c 000030 04 A 2 0 4
[ 5] .data PROGBITS 000010ac 0020ac 000004 00 WA 0 0 4
[ 6] .dynamic DYNAMIC 000010b0 0020b0 000058 08 WA 3 0 4
[ 7] .got.plt PROGBITS 00001108 002108 00000c 04 WA 0 0 4
[ 8] .shstrtab STRTAB 00000000 002114 00004f 00 0 0 1
[ 9] .symtab SYMTAB 00000000 00231c 0000d0 10 10 12 4
[10] .strtab STRTAB 00000000 0023ec 000020 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Elf file type is DYN (Shared object file)
Entry point 0x0
There are 2 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x001000 0x00000000 0x00000000 0x01114 0x01114 RWE 0x1000
DYNAMIC 0x0020b0 0x000010b0 0x000010b0 0x00058 0x00058 RW 0x4
Section to Segment mapping:
Segment Sections...
00 .text .dynsym .dynstr .hash .data .dynamic .got.plt
01 .dynamic
Symbol table '.dynsym' contains 7 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1
2: 00000000 0 NOTYPE LOCAL DEFAULT UND
3: 000010ac 0 SECTION LOCAL DEFAULT 5
4: 00000000 0 NOTYPE LOCAL DEFAULT UND
5: 00000000 0 NOTYPE LOCAL DEFAULT UND
6: 000010b0 0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC
Symbol table '.symtab' contains 13 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 SECTION LOCAL DEFAULT 1
2: 00001000 0 SECTION LOCAL DEFAULT 2
3: 00001070 0 SECTION LOCAL DEFAULT 3
4: 0000107c 0 SECTION LOCAL DEFAULT 4
5: 000010ac 0 SECTION LOCAL DEFAULT 5
6: 000010b0 0 SECTION LOCAL DEFAULT 6
7: 00001108 0 SECTION LOCAL DEFAULT 7
8: 00000000 0 SECTION LOCAL DEFAULT 8
9: 00000000 0 SECTION LOCAL DEFAULT 9
10: 00000000 0 SECTION LOCAL DEFAULT 10
11: 00001108 0 OBJECT LOCAL HIDDEN ABS _GLOBAL_OFFSET_TABLE_
12: 000010b0 0 OBJECT GLOBAL DEFAULT ABS _DYNAMIC