[Lazarus] Strip problems

cobines cobines at gmail.com
Tue Feb 16 03:30:08 CET 2010


2010/2/15 JoshyFun <joshyfun at gmail.com>:
> I have activated the -g and -gl flags to generate debug information in
> the exe file, and this is how the exe sections appear:
>
>>Object table:
>>#   Name      VirtSize    RVA     PhysSize  Phys off  Flags
>>--  --------  --------  --------  --------  --------  --------
>>01  .text     00116B90  00001000  00116B90  00000400  60500020 [CER]
>>02  .data     0004B8D8  00118000  0004B8D8  00117000  C0500040 [IRW]
>>03  .bss      00007054  00164000  00000000  00000000  C0500080 [URW]
>>04  .idata    00002A08  0016C000  00002A08  00162A00  C0300040 [IRW]
>>05  .rsrc     00001F78  0016F000  00001F78  00165600  C0500040 [IRW]
>>06  /4        00304232  00171000  00304232  00167600  02100000 [D]
>>07  /16       0021E233  00476000  0021E233  0046BA00  02100000 [D]
>>08  /30       0005A3B4  00695000  0005A3B4  00689E00  02100000 [D]
>>09  /42       0002CDBC  006F0000  0002CDBC  006E4200  02300000 [D]
>>0a  .stab     0014DAA4  0071D000  0014DAA4  00711000  02300000 [D]
>>0b  .stabstr  00852873  0086B000  00852873  0085EC00  02100000 [D]
>
> Which is more or less the expected, except that I do not know what are
> the /4, /16, /30 and /42 sections. The exe size is around 18 MB.
>
> If I run the strip-all command I get:
>
>>Object table:
>>#   Name      VirtSize    RVA     PhysSize  Phys off  Flags
>>--  --------  --------  --------  --------  --------  --------
>>01  .text     00116B90  00001000  00116C00  00000400  60000020 [CER]
>>02  .data     0004B8D8  00118000  0004BA00  00117000  C0000040 [IRW]
>>03  .bss      00007054  00164000  00000000  00000000  C0000080 [URW]
>>04  .idata    00002A08  0016C000  00002C00  00162A00  C0000040 [IRW]
>>05  .rsrc     00001F78  0016F000  00002000  00165600  50000040 [ISR]
>>06  /4        00304232  00171000  00304400  00167600  C0000020 [CRW]
>>07  /16       0021E233  00476000  0021E400  0046BA00  C0000020 [CRW]
>>08  /30       0005A3B4  00695000  0005A400  00689E00  C0000020 [CRW]
>>09  /42       0002CDBC  006F0000  0002CE00  006E4200  C0000020 [CRW]
>
> And sections starting with "/" are not being removed and the exe size
> is around 7 MB.
>
> Now unchecking the -g and -gl flags I get:
>
>>Object table:
>>#   Name      VirtSize    RVA     PhysSize  Phys off  Flags
>>--  --------  --------  --------  --------  --------  --------
>>01  .text     001153B0  00001000  001153B0  00000400  60500020 [CER]
>>02  .data     0004B848  00117000  0004B848  00115800  C0500040 [IRW]
>>03  .bss      00005404  00163000  00000000  00000000  C0500080 [URW]
>>04  .idata    000029F0  00169000  000029F0  00161200  C0300040 [IRW]
>>05  .rsrc     00001F78  0016C000  00001F78  00163C00  C0500040 [IRW]
>
> Which is the expected result and exe size around 1.7 MB.
>
> I had tried to issue a:
>
> strip program.exe --remove-section=/4 without success. Does this means
> that the strip is not usable anymore or that sections should not be
> there or have different flags ?
>
> I'm using fpc SVN, Lazarus SVN and WinXP SP3.
>
> Thank you.


The /XXX section names are used (by Windows only I think) if a section
name is too long (it's an index to a list of long section names). My
objdump translates them to proper names (I have also /4, /16, etc. in
the binary file). I have binutils from MinGW project.


# objdump -v

GNU objdump (GNU Binutils) 2.20
Copyright 2009 Free Software Foundation, Inc.


# objdump -h file.exe

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00333e10  00401000  00401000  00000400  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         0014a0c8  00735000  00735000  00334400  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          0000bde4  00880000  00880000  00000000  2**4
                  ALLOC
  3 .idata        0000380c  0088c000  0088c000  0047e600  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  4 .rsrc         0000a3dc  00890000  00890000  00482000  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  5 .debug_info   01051dcf  0089b000  0089b000  0048c400  2**0
                  CONTENTS, READONLY, DEBUGGING
  6 .debug_abbrev 00cb753d  018ed000  018ed000  014de200  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_line   00035cc9  025a5000  025a5000  02195800  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_frame  0001fb1c  025db000  025db000  021cb600  2**2
                  CONTENTS, READONLY, DEBUGGING
  9 .stab         003f34b0  025fb000  025fb000  021eb200  2**2
                  CONTENTS, READONLY, DEBUGGING
 10 .stabstr      010112ea  029ef000  029ef000  025de800  2**0
                  CONTENTS, READONLY, DEBUGGING


# strip file.exe
# objdump -h file.exe

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00333e10  00401000  00401000  00000400  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         0014a0c8  00735000  00735000  00334400  2**4
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          0000bde4  00880000  00880000  00000000  2**4
                  ALLOC
  3 .idata        0000380c  0088c000  0088c000  0047e600  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  4 .rsrc         0000a3dc  00890000  00890000  00482000  2**4
                  CONTENTS, ALLOC, LOAD, DATA

Using FPC 2.5.1 rev. 14833.

I don't know which binutils you have, but maybe you should update?

--
cobines




More information about the Lazarus mailing list