Linux binary size after strip

Javier Cabezas Rodríguez jcabezas@ac.upc.edu
Wed Nov 22 16:36:00 GMT 2006


El mié, 22-11-2006 a las 16:03 +0000, Nick Clifton escribió:
> Hi Javier,
> 
> > Now I have stripped some of these sections, but the size of the binary
> > has not decreased. 
> 
> Possibly the sections have alignment requirements so that after 
> stripping they are still padded out to some fixed size ?

Each section has a 4096 alignment requirement, but they are 4096bytes
sized too, so it should not be a problem. I have attached the "readelf
-Sl" output of each kernel.

1- Original kernel:       2396464 bytes
2- Partitioned kernel: 2144924 bytes
3- Stripped kernel:       2143660 bytes

> Possibly the kernel is already frugal with the symbols and debug 
> information it exports and there is nothing to strip.

The sections I want to strip only contain code (initially located in
the .text section). The debug sections are already stripped in standard
kernels.


-- 
Javier Cabezas Rodríguez
Phd. Student - DAC (UPC)
jcabezas@ac.upc.edu
-------------- next part --------------
There are 143 section headers, starting at offset 0xb4:

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        c0100000 002000 0d6431 00  AX  0   0  0
  [ 2] .text.page.0      PROGBITS        c01d7000 0d9000 001000 00  AX  0   0 4096
  [ 3] .text.page.1      PROGBITS        c01d8000 0da000 001000 00  AX  0   0 4096
  [ 4] .text.page.2      PROGBITS        c01d9000 0db000 001000 00  AX  0   0 4096
  [ 5] .text.page.3      PROGBITS        c01da000 0dc000 001000 00  AX  0   0 4096
  [ 6] .text.page.4      PROGBITS        c01db000 0dd000 001000 00  AX  0   0 4096
  [ 7] .text.page.5      PROGBITS        c01dc000 0de000 001000 00  AX  0   0 4096
  [ 8] .text.page.6      PROGBITS        c01dd000 0df000 001000 00  AX  0   0 4096
  [ 9] .text.page.7      PROGBITS        c01de000 0e0000 001000 00  AX  0   0 4096
  [10] .text.page.8      PROGBITS        c01df000 0e1000 001000 00  AX  0   0 4096
  [11] .text.page.9      PROGBITS        c01e0000 0e2000 001000 00  AX  0   0 4096
  [12] .text.page.10     PROGBITS        c01e1000 0e3000 001000 00  AX  0   0 4096
  [13] .text.page.11     PROGBITS        c01e2000 0e4000 001000 00  AX  0   0 4096
  [14] .text.page.12     PROGBITS        c01e3000 0e5000 001000 00  AX  0   0 4096
  [15] .text.page.13     PROGBITS        c01e4000 0e6000 001000 00  AX  0   0 4096
  [16] .text.page.14     PROGBITS        c01e5000 0e7000 001000 00  AX  0   0 4096
  [17] .text.page.15     PROGBITS        c01e6000 0e8000 001000 00  AX  0   0 4096
  [18] .text.page.16     PROGBITS        c01e7000 0e9000 001000 00  AX  0   0 4096
  [19] .text.page.17     PROGBITS        c01e8000 0ea000 001000 00  AX  0   0 4096
  [20] .text.page.18     PROGBITS        c01e9000 0eb000 001000 00  AX  0   0 4096
  [21] .text.page.19     PROGBITS        c01ea000 0ec000 001000 00  AX  0   0 4096
  [22] .text.page.20     PROGBITS        c01eb000 0ed000 001000 00  AX  0   0 4096
  [23] .text.page.21     PROGBITS        c01ec000 0ee000 001000 00  AX  0   0 4096
  [24] .text.page.22     PROGBITS        c01ed000 0ef000 001000 00  AX  0   0 4096
  [25] .text.page.23     PROGBITS        c01ee000 0f0000 001000 00  AX  0   0 4096
  [26] .text.page.24     PROGBITS        c01ef000 0f1000 001000 00  AX  0   0 4096
  [27] .text.page.25     PROGBITS        c01f0000 0f2000 001000 00  AX  0   0 4096
  [28] .text.page.26     PROGBITS        c01f1000 0f3000 001000 00  AX  0   0 4096
  [29] .text.page.27     PROGBITS        c01f2000 0f4000 001000 00  AX  0   0 4096
  [30] .text.page.28     PROGBITS        c01f3000 0f5000 001000 00  AX  0   0 4096
  [31] .text.page.29     PROGBITS        c01f4000 0f6000 001000 00  AX  0   0 4096
  [32] .text.page.30     PROGBITS        c01f5000 0f7000 001000 00  AX  0   0 4096
  [33] .text.page.31     PROGBITS        c01f6000 0f8000 001000 00  AX  0   0 4096
  [34] .text.page.32     PROGBITS        c01f7000 0f9000 001000 00  AX  0   0 4096
  [35] .text.page.33     PROGBITS        c01f8000 0fa000 001000 00  AX  0   0 4096
  [36] .text.page.34     PROGBITS        c01f9000 0fb000 001000 00  AX  0   0 4096
  [37] .text.page.35     PROGBITS        c01fa000 0fc000 001000 00  AX  0   0 4096
  [38] .text.page.36     PROGBITS        c01fb000 0fd000 001000 00  AX  0   0 4096
  [39] .text.page.37     PROGBITS        c01fc000 0fe000 001000 00  AX  0   0 4096
  [40] .text.page.38     PROGBITS        c01fd000 0ff000 001000 00  AX  0   0 4096
  [41] .text.page.39     PROGBITS        c01fe000 100000 001000 00  AX  0   0 4096
  [42] .text.page.40     PROGBITS        c01ff000 101000 001000 00  AX  0   0 4096
  [43] .text.page.41     PROGBITS        c0200000 102000 001000 00  AX  0   0 4096
  [44] .text.page.42     PROGBITS        c0201000 103000 001000 00  AX  0   0 4096
  [45] .text.page.43     PROGBITS        c0202000 104000 001000 00  AX  0   0 4096
  [46] .text.page.44     PROGBITS        c0203000 105000 001000 00  AX  0   0 4096
  [47] .text.page.45     PROGBITS        c0204000 106000 001000 00  AX  0   0 4096
  [48] .text.page.46     PROGBITS        c0205000 107000 001000 00  AX  0   0 4096
  [49] .text.page.47     PROGBITS        c0206000 108000 001000 00  AX  0   0 4096
  [50] .text.page.48     PROGBITS        c0207000 109000 001000 00  AX  0   0 4096
  [51] .text.page.49     PROGBITS        c0208000 10a000 001000 00  AX  0   0 4096
  [52] .text.page.50     PROGBITS        c0209000 10b000 001000 00  AX  0   0 4096
  [53] .text.page.51     PROGBITS        c020a000 10c000 001000 00  AX  0   0 4096
  [54] .text.page.52     PROGBITS        c020b000 10d000 001000 00  AX  0   0 4096
  [55] .text.page.53     PROGBITS        c020c000 10e000 001000 00  AX  0   0 4096
  [56] .text.page.54     PROGBITS        c020d000 10f000 001000 00  AX  0   0 4096
  [57] .text.page.55     PROGBITS        c020e000 110000 001000 00  AX  0   0 4096
  [58] .text.page.56     PROGBITS        c020f000 111000 001000 00  AX  0   0 4096
  [59] .text.page.57     PROGBITS        c0210000 112000 001000 00  AX  0   0 4096
  [60] .text.page.58     PROGBITS        c0211000 113000 001000 00  AX  0   0 4096
  [61] .text.page.59     PROGBITS        c0212000 114000 001000 00  AX  0   0 4096
  [62] .text.page.60     PROGBITS        c0213000 115000 001000 00  AX  0   0 4096
  [63] .text.page.61     PROGBITS        c0214000 116000 001000 00  AX  0   0 4096
  [64] .text.page.62     PROGBITS        c0215000 117000 001000 00  AX  0   0 4096
  [65] .text.page.63     PROGBITS        c0216000 118000 001000 00  AX  0   0 4096
  [66] .text.page.64     PROGBITS        c0217000 119000 001000 00  AX  0   0 4096
  [67] .text.page.65     PROGBITS        c0218000 11a000 001000 00  AX  0   0 4096
  [68] .text.page.66     PROGBITS        c0219000 11b000 001000 00  AX  0   0 4096
  [69] .text.page.67     PROGBITS        c021a000 11c000 001000 00  AX  0   0 4096
  [70] .text.page.68     PROGBITS        c021b000 11d000 001000 00  AX  0   0 4096
  [71] .text.page.69     PROGBITS        c021c000 11e000 001000 00  AX  0   0 4096
  [72] .text.page.70     PROGBITS        c021d000 11f000 001000 00  AX  0   0 4096
  [73] .text.page.71     PROGBITS        c021e000 120000 001000 00  AX  0   0 4096
  [74] .text.page.72     PROGBITS        c021f000 121000 001000 00  AX  0   0 4096
  [75] .text.page.73     PROGBITS        c0220000 122000 001000 00  AX  0   0 4096
  [76] .text.page.74     PROGBITS        c0221000 123000 001000 00  AX  0   0 4096
  [77] .text.page.75     PROGBITS        c0222000 124000 001000 00  AX  0   0 4096
  [78] .text.page.76     PROGBITS        c0223000 125000 001000 00  AX  0   0 4096
  [79] .text.page.77     PROGBITS        c0224000 126000 001000 00  AX  0   0 4096
  [80] .text.page.78     PROGBITS        c0225000 127000 001000 00  AX  0   0 4096
  [81] .text.page.79     PROGBITS        c0226000 128000 001000 00  AX  0   0 4096
  [82] .text.page.80     PROGBITS        c0227000 129000 001000 00  AX  0   0 4096
  [83] .text.page.81     PROGBITS        c0228000 12a000 001000 00  AX  0   0 4096
  [84] .text.page.82     PROGBITS        c0229000 12b000 001000 00  AX  0   0 4096
  [85] .text.page.83     PROGBITS        c022a000 12c000 001000 00  AX  0   0 4096
  [86] .text.page.84     PROGBITS        c022b000 12d000 001000 00  AX  0   0 4096
  [87] .text.page.85     PROGBITS        c022c000 12e000 001000 00  AX  0   0 4096
  [88] .text.page.86     PROGBITS        c022d000 12f000 001000 00  AX  0   0 4096
  [89] .text.page.87     PROGBITS        c022e000 130000 001000 00  AX  0   0 4096
  [90] .text.page.88     PROGBITS        c022f000 131000 001000 00  AX  0   0 4096
  [91] .text.page.89     PROGBITS        c0230000 132000 001000 00  AX  0   0 4096
  [92] .text.page.90     PROGBITS        c0231000 133000 001000 00  AX  0   0 4096
  [93] .text.page.91     PROGBITS        c0232000 134000 001000 00  AX  0   0 4096
  [94] .text.page.92     PROGBITS        c0233000 135000 001000 00  AX  0   0 4096
  [95] .text.page.93     PROGBITS        c0234000 136000 001000 00  AX  0   0 4096
  [96] .text.page.94     PROGBITS        c0235000 137000 001000 00  AX  0   0 4096
  [97] .text.page.95     PROGBITS        c0236000 138000 001000 00  AX  0   0 4096
  [98] .text.page.96     PROGBITS        c0237000 139000 001000 00  AX  0   0 4096
  [99] .text.page.97     PROGBITS        c0238000 13a000 001000 00  AX  0   0 4096
  [100] .text.page.98     PROGBITS        c0239000 13b000 001000 00  AX  0   0 4096
  [101] .text.page.99     PROGBITS        c023a000 13c000 001000 00  AX  0   0 4096
  [102] .text.page.100    PROGBITS        c023b000 13d000 001000 00  AX  0   0 4096
  [103] .text.page.101    PROGBITS        c023c000 13e000 001000 00  AX  0   0 4096
  [104] .text.page.102    PROGBITS        c023d000 13f000 001000 00  AX  0   0 4096
  [105] .text.page.103    PROGBITS        c023e000 140000 001000 00  AX  0   0 4096
  [106] .text.page.104    PROGBITS        c023f000 141000 001000 00  AX  0   0 4096
  [107] .text.page.105    PROGBITS        c0240000 142000 001000 00  AX  0   0 4096
  [108] .text.page.106    PROGBITS        c0241000 143000 001000 00  AX  0   0 4096
  [109] .text.page.107    PROGBITS        c0242000 144000 001000 00  AX  0   0 4096
  [110] .text.page.108    PROGBITS        c0243000 145000 001000 00  AX  0   0 4096
  [111] .text.page.109    PROGBITS        c0244000 146000 001000 00  AX  0   0 4096
  [112] .text.page.110    PROGBITS        c0245000 147000 001000 00  AX  0   0 4096
  [113] .text.page.111    PROGBITS        c0246000 148000 001000 00  AX  0   0 4096
  [114] .text.page.112    PROGBITS        c0247000 149000 001000 00  AX  0   0 4096
  [115] .text.page.113    PROGBITS        c0248000 14a000 001000 00  AX  0   0 4096
  [116] .text.page.114    PROGBITS        c0249000 14b000 001000 00  AX  0   0 4096
  [117] .text.page.115    PROGBITS        c024a000 14c000 001000 00  AX  0   0 4096
  [118] .text.page.116    PROGBITS        c024b000 14d000 001000 00  AX  0   0 4096
  [119] .text.page.117    PROGBITS        c024c000 14e000 001000 00  AX  0   0 4096
  [120] .text.page.118    PROGBITS        c024d000 14f000 001000 00  AX  0   0 4096
  [121] .text.page.119    PROGBITS        c024e000 150000 001000 00  AX  0   0 4096
  [122] .text.page.120    PROGBITS        c024f000 151000 001000 00  AX  0   0 4096
  [123] .text.page.121    PROGBITS        c0250000 152000 001000 00  AX  0   0 4096
  [124] .text.page.122    PROGBITS        c0251000 153000 001000 00  AX  0   0 4096
  [125] .text.page.123    PROGBITS        c0252000 154000 001000 00  AX  0   0 4096
  [126] .text.page.124    PROGBITS        c0253000 155000 001000 00  AX  0   0 4096
  [127] .text.page.125    PROGBITS        c0254000 156000 001000 00  AX  0   0 4096
  [128] .text.page.126    PROGBITS        c0255000 157000 001000 00  AX  0   0 4096
  [129] .text.page.127    PROGBITS        c0256000 158000 001000 00  AX  0   0 4096
  [130] .text.page.128    PROGBITS        c0257000 159000 001000 00  AX  0   0 4096
  [131] .rodata           PROGBITS        c0258000 15a000 03b707 00   A  0   0 32
  [132] __ex_table        PROGBITS        c0293720 195720 001250 00   A  0   0  4
  [133] .data             PROGBITS        c0294980 196980 047eac 00  WA  0   0 32
  [134] .data.init_task   PROGBITS        c02de000 1df000 002000 00  WA  0   0 32
  [135] .text.init        PROGBITS        c02e0000 1e1000 01ac0d 00  AX  0   0  0
  [136] .data.init        PROGBITS        c02fac20 1fbc20 00492c 00  WA  0   0 32
  [137] .setup.init       PROGBITS        c02ff550 200550 0001e0 00  WA  0   0  4
  [138] .initcall.init    PROGBITS        c02ff730 200730 0000e0 00  WA  0   0  4
  [139] .data.page_aligne PROGBITS        c0300000 201000 000800 00  WA  0   0 32
  [140] .data.cacheline_a PROGBITS        c0300800 201800 009ae0 00  WA  0   0 32
  [141] .bss              NOBITS          c030a2e0 20b2e0 058828 00  WA  0   0 32
  [142] .shstrtab         STRTAB          00000000 20b2e0 0007bc 00      0   0  0
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 EXEC (Executable file)
Entry point 0xc0100000
There are 4 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x002000 0xc0100000 0xc0100000 0xd6431 0xd6431 R E 0x1000
  LOAD           0x0d9000 0xc01d7000 0xc01d7000 0x10582c 0x10582c RWE 0x1000
  LOAD           0x1df000 0xc02de000 0xc02de000 0x21810 0x21810 RWE 0x1000
  LOAD           0x201000 0xc0300000 0xc0300000 0x0a2e0 0x62b08 RW  0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .text 
   01     .text.page.0 .text.page.1 .text.page.2 .text.page.3 .text.page.4 .text.page.5 .text.page.6 .text.page.7 .text.page.8 .text.page.9 .text.page.10 .text.page.11 .text.page.12 .text.page.13 .text.page.14 .text.page.15 .text.page.16 .text.page.17 .text.page.18 .text.page.19 .text.page.20 .text.page.21 .text.page.22 .text.page.23 .text.page.24 .text.page.25 .text.page.26 .text.page.27 .text.page.28 .text.page.29 .text.page.30 .text.page.31 .text.page.32 .text.page.33 .text.page.34 .text.page.35 .text.page.36 .text.page.37 .text.page.38 .text.page.39 .text.page.40 .text.page.41 .text.page.42 .text.page.43 .text.page.44 .text.page.45 .text.page.46 .text.page.47 .text.page.48 .text.page.49 .text.page.50 .text.page.51 .text.page.52 .text.page.53 .text.page.54 .text.page.55 .text.page.56 .text.page.57 .text.page.58 .text.page.59 .text.page.60 .text.page.61 .text.page.62 .text.page.63 .text.page.64 .text.page.65 .text.page.66 .text.page.67 .text.page.68 .text.page.69 .text.page.70 .text.page.71 .text.page.72 .text.page.73 .text.page.74 .text.page.75 .text.page.76 .text.page.77 .text.page.78 .text.page.79 .text.page.80 .text.page.81 .text.page.82 .text.page.83 .text.page.84 .text.page.85 .text.page.86 .text.page.87 .text.page.88 .text.page.89 .text.page.90 .text.page.91 .text.page.92 .text.page.93 .text.page.94 .text.page.95 .text.page.96 .text.page.97 .text.page.98 .text.page.99 .text.page.100 .text.page.101 .text.page.102 .text.page.103 .text.page.104 .text.page.105 .text.page.106 .text.page.107 .text.page.108 .text.page.109 .text.page.110 .text.page.111 .text.page.112 .text.page.113 .text.page.114 .text.page.115 .text.page.116 .text.page.117 .text.page.118 .text.page.119 .text.page.120 .text.page.121 .text.page.122 .text.page.123 .text.page.124 .text.page.125 .text.page.126 .text.page.127 .text.page.128 .rodata __ex_table .data 
   02     .data.init_task .text.init .data.init .setup.init .initcall.init 
   03     .data.page_aligned .data.cacheline_aligned .bss 
-------------- next part --------------
There are 14 section headers, starting at offset 0x20b37c:

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        c0100000 001000 0d6431 00  AX  0   0  1
  [ 2] .rodata           PROGBITS        c0258000 159000 03b707 00   A  0   0 32
  [ 3] __ex_table        PROGBITS        c0293720 194720 001250 00   A  0   0  4
  [ 4] .data             PROGBITS        c0294980 195980 047eac 00  WA  0   0 32
  [ 5] .data.init_task   PROGBITS        c02de000 1df000 002000 00  WA  0   0 32
  [ 6] .text.init        PROGBITS        c02e0000 1e1000 01ac0d 00  AX  0   0  1
  [ 7] .data.init        PROGBITS        c02fac20 1fbc20 00492c 00  WA  0   0 32
  [ 8] .setup.init       PROGBITS        c02ff550 200550 0001e0 00  WA  0   0  4
  [ 9] .initcall.init    PROGBITS        c02ff730 200730 0000e0 00  WA  0   0  4
  [10] .data.page_aligne PROGBITS        c0300000 201000 000800 00  WA  0   0 32
  [11] .data.cacheline_a PROGBITS        c0300800 201800 009ae0 00  WA  0   0 32
  [12] .bss              NOBITS          c030a2e0 20b2e0 058828 00  WA  0   0 32
  [13] .shstrtab         STRTAB          00000000 20b2e0 00009b 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 EXEC (Executable file)
Entry point 0xc0100000
There are 2 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0xc0100000 0xc0100000 0xd6431 0xd6431 R E 0x1000
  LOAD           0x0d8000 0xc0258000 0xc01d7000 0x1332e0 0x1332e0 RWE 0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .text 
   01     .rodata __ex_table .data .data.init_task .text.init .data.init .setup.init .initcall.init .data.page_aligned .data.cacheline_aligned .bss 
-------------- next part --------------
There are 19 section headers, starting at offset 0x248e98:

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        c0100000 001000 171fd8 00  AX  0   0 16
  [ 2] .rodata           PROGBITS        c0271fe0 172fe0 04a8c0 00   A  0   0 32
  [ 3] .kstrtab          PROGBITS        c02bc8a0 1bd8a0 013709 00   A  0   0 32
  [ 4] __ex_table        PROGBITS        c02cffb0 1d0fb0 002d68 00   A  0   0  4
  [ 5] __ksymtab         PROGBITS        c02d2d18 1d3d18 002dc0 00   A  0   0  4
  [ 6] .data             PROGBITS        c02d5ae0 1d6ae0 047ec0 00  WA  0   0 32
  [ 7] .data.init_task   PROGBITS        c031e000 21f000 002000 00  WA  0   0 32
  [ 8] .text.init        PROGBITS        c0320000 221000 017132 00  AX  0   0  4
  [ 9] .data.init        PROGBITS        c0337140 238140 004978 00  WA  0   0 32
  [10] .setup.init       PROGBITS        c033bac0 23cac0 0001e0 00  WA  0   0  4
  [11] .initcall.init    PROGBITS        c033bca0 23cca0 0000e0 00  WA  0   0  4
  [12] .data.page_aligne PROGBITS        c033c000 23d000 000800 00  WA  0   0 32
  [13] .data.cacheline_a PROGBITS        c033c800 23d800 009ae0 00  WA  0   0 32
  [14] .bss              NOBITS          c03462e0 2472e0 058844 00  WA  0   0 32
  [15] .comment          PROGBITS        00000000 2472e0 001aee 00      0   0  1
  [16] .shstrtab         STRTAB          00000000 248dce 0000c7 00      0   0  1
  [17] .symtab           SYMTAB          00000000 249190 11b390 10     18 65419  4
  [18] .strtab           STRTAB          00000000 364520 085590 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 EXEC (Executable file)
Entry point 0xc0105000
There are 1 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x001000 0xc0100000 0xc0100000 0x2462e0 0x29eb24 RWE 0x1000

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .kstrtab __ex_table __ksymtab .data .data.init_task .text.init .data.init .setup.init .initcall.init .data.page_aligned .data.cacheline_aligned .bss
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Esta parte del mensaje est? firmada	digitalmente
URL: <https://sourceware.org/pipermail/binutils/attachments/20061122/4195048c/attachment.sig>


More information about the Binutils mailing list