Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-02

Strip problems

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

JoshyFun

Hello Lazarus-List,

I'm used to use a:

strip program.exe --strip-all

Before releasing an exe, as it is quite easy operation, but since a few weeks (maybe some months) strip can not remove all "extra" information in the exe file.

I have activated the -g and -gl flags to generate debug information in the exe file, and this is how the exe sections appear:

Show quoted text 14 lines
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:

Show quoted text 12 lines
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:

Show quoted text 8 lines
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.

Best regards, JoshyFun

Reply by email

cobines
to JoshyFun

2010/2/15 JoshyFun :

Show quoted text 61 lines
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

Reply by email

Paul Ishenin
to JoshyFun: I'm used to use a: strip program.exe --strip-all Before releasing an exe, as it is quite…

16.02.2010 3:03, JoshyFun ?????:

Show quoted text 9 lines
Hello Lazarus-List, I'm used to use a: strip program.exe --strip-all Before releasing an exe, as it is quite easy operation, but since a few weeks (maybe some months) strip can not remove all "extra" information in the exe file.

I'd suggest to use -Xg option. You will have no debug symbols in the executable but have them in a separate file for gdb only. This way you can just take your exe for releasing.

I must admit that strip indeed does not work for my executables with dwarf debug info.

Best regards,
Paul Ishenin.

Reply by email

JoshyFun
to cobines: 2010/2/15 JoshyFun : The /XXX section names are used (by Windows only I think) if a…

Hello Lazarus-List,

Tuesday, February 16, 2010, 3:30:08 AM, you wrote:

c> The /XXX section names are used (by Windows only I think) if a section c> name is too long (it's an index to a list of long section names). My

Oh! that's the trick! they are not real names! So using:

strip program.exe --remove-section=.debug_info --remove-section=.debug_abbrev --remove-section=.debug_line --remove-section=.debug_frame

Solves my problem. Thank you!

c> objdump translates them to proper names (I have also /4, /16, etc. in c> the binary file). I have binutils from MinGW project.

I'm using the quite old tdump.exe :) I think its time to create an alias to objdump.exe instead :)

c> Using FPC 2.5.1 rev. 14833.
c> I don't know which binutils you have, but maybe you should update?

GNU strip 2.9.5
Copyright 1997, 1998, 1999 Free Software Foundation, Inc.

The one that comes with fpc 2.2.4 but I had tested a recent one for 64 bits and I think the problem is the same but I'm not sure 100% so I must recheck.

Thank you for the help.

Best regards, JoshyFun

Reply by email

JoshyFun
to Paul Ishenin: 16.02.2010 3:03, JoshyFun ?????: I'd suggest to use -Xg option. You will have no debug…

Hello Lazarus-List,

you wrote
> Before releasing an exe, as it is quite easy operation, but since a > few weeks (maybe some months) strip can not remove all "extra" > information in the exe file.

PI> I'd suggest to use -Xg option. You will have no debug symbols in the PI> executable but have them in a separate file for gdb only. This way you PI> can just take your exe for releasing.

Maybe it's time to do so. I was not using it because it does not work around one year in the past, but now it seems to work.

PI> I must admit that strip indeed does not work for my executables with PI> dwarf debug info.

Try this:

strip program.exe --remove-section=.debug_info --remove-section=.debug_abbrev --remove-section=.debug_line --remove-section=.debug_frame

I can not test now as I come back to stabs because linking time in dwarf is more than double time than stabs and in large executables it is very notizable when you are using "test-error" debug technique :)

Best regards, JoshyFun

Reply by email