bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How create small binaries with GNU binutils.


From: Dmitry Bogatov
Subject: Re: How create small binaries with GNU binutils.
Date: Wed, 13 Feb 2019 11:31:45 +0000

[2019-02-07 15:43] Nick Clifton <address@hidden>
>
> part       text/plain                 498
> Hi Dmitry,
>
> >>> Still, even this way, 400 bytes is more then twice as big, compared to
> >>> fasm. Any suggestions, how to shrink binary futher?
>
> > Thank you for suggestion. Tried both options; no difference -- 400
> > bytes.
>
> Ho Hum.  In which case, do you know what is in the extra bytes ?  If you
> link with the -Map=foo.map option you should get a map file which shows 
> you how the output was constructed.  Perhaps this can help you find out
> where the extra bytes are coming from.

Thank you for suggestion, but map did not reveal anything. The only part
(section?) with non zero size is .text of size 0xd (=13). This is
correct, raw instructions are really 13 bytes (according to `objdump -d').

According to `readelf --sections', there is only `.text' and `.shstrtab'
sections.

By the way, `readelf --sections' reports, that there is no sections in
fasm-generated binary. I do not know, how does fasm do it, but probably
is saves on section headers or something like this. Is is possible to
make `ld' do the same?

Also, there is PAX_HEADERS header in binutils-generated binary.

Here is map, maybe you could extract more of it:

  Memory Configuration

  Name             Origin             Length             Attributes
  *default*        0x0000000000000000 0xffffffffffffffff

  Linker script and memory map

  LOAD a01.o
                  [!provide]                        PROVIDE (__executable_start 
= SEGMENT_START ("text-segment", 0x400000))
                  0x00000000004000b0                . = (SEGMENT_START 
("text-segment", 0x400000) + SIZEOF_HEADERS)

  .interp
   *(.interp)

  .note.gnu.build-id
   *(.note.gnu.build-id)

  .hash
   *(.hash)

  .gnu.hash
   *(.gnu.hash)

  .dynsym
   *(.dynsym)

  .dynstr
   *(.dynstr)

  .gnu.version
   *(.gnu.version)

  .gnu.version_d
   *(.gnu.version_d)

  .gnu.version_r
   *(.gnu.version_r)

  .rela.dyn       0x00000000004000b0        0x0
   *(.rela.init)
   *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
   *(.rela.fini)
   *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
   *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
   *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
   *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
   *(.rela.ctors)
   *(.rela.dtors)
   *(.rela.got)
   .rela.got      0x00000000004000b0        0x0 a01.o
   *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
   *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*)
   *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*)
   *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*)
   *(.rela.ifunc)

  .rela.plt       0x00000000004000b0        0x0
   *(.rela.plt)
                  [!provide]                        PROVIDE (__rela_iplt_start 
= .)
   *(.rela.iplt)
   .rela.iplt     0x00000000004000b0        0x0 a01.o
                  [!provide]                        PROVIDE (__rela_iplt_end = 
.)

  .init
   *(SORT_NONE(.init))

  .plt            0x00000000004000b0        0x0
   *(.plt)
   *(.iplt)
   .iplt          0x00000000004000b0        0x0 a01.o

  .plt.got
   *(.plt.got)

  .plt.sec
   *(.plt.sec)

  .text           0x00000000004000b0        0xd
   *(.text.unlikely .text.*_unlikely .text.unlikely.*)
   *(.text.exit .text.exit.*)
   *(.text.startup .text.startup.*)
   *(.text.hot .text.hot.*)
   *(.text .stub .text.* .gnu.linkonce.t.*)
   .text          0x00000000004000b0        0xd a01.o
                  0x00000000004000b0                _start
   *(.gnu.warning)

  .fini
   *(SORT_NONE(.fini))
                  [!provide]                        PROVIDE (__etext = .)
                  [!provide]                        PROVIDE (_etext = .)
                  [!provide]                        PROVIDE (etext = .)

  .rodata
   *(.rodata .rodata.* .gnu.linkonce.r.*)

  .rodata1
   *(.rodata1)

  .eh_frame_hdr
   *(.eh_frame_hdr)
   *(.eh_frame_entry .eh_frame_entry.*)

  .eh_frame
   *(.eh_frame)
   *(.eh_frame.*)

  .gcc_except_table
   *(.gcc_except_table .gcc_except_table.*)

  .gnu_extab
   *(.gnu_extab*)

  .exception_ranges
   *(.exception_ranges .exception_ranges*)
                  0x00000000006000bd                . = DATA_SEGMENT_ALIGN 
(CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE))

  .eh_frame
   *(.eh_frame)
   *(.eh_frame.*)

  .gnu_extab
   *(.gnu_extab)

  .gcc_except_table
   *(.gcc_except_table .gcc_except_table.*)

  .exception_ranges
   *(.exception_ranges .exception_ranges*)

  .tdata
   *(.tdata .tdata.* .gnu.linkonce.td.*)

  .tbss
   *(.tbss .tbss.* .gnu.linkonce.tb.*)
   *(.tcommon)

  .preinit_array  0x00000000006000bd        0x0
                  [!provide]                        PROVIDE 
(__preinit_array_start = .)
   *(.preinit_array)
                  [!provide]                        PROVIDE 
(__preinit_array_end = .)

  .init_array     0x00000000006000bd        0x0
                  [!provide]                        PROVIDE (__init_array_start 
= .)
   *(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))
   *(.init_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) 
.ctors)
                  [!provide]                        PROVIDE (__init_array_end = 
.)

  .fini_array     0x00000000006000bd        0x0
                  [!provide]                        PROVIDE (__fini_array_start 
= .)
   *(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))
   *(.fini_array EXCLUDE_FILE(*crtend?.o *crtend.o *crtbegin?.o *crtbegin.o) 
.dtors)
                  [!provide]                        PROVIDE (__fini_array_end = 
.)

  .ctors
   *crtbegin.o(.ctors)
   *crtbegin?.o(.ctors)
   *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
   *(SORT_BY_NAME(.ctors.*))
   *(.ctors)

  .dtors
   *crtbegin.o(.dtors)
   *crtbegin?.o(.dtors)
   *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
   *(SORT_BY_NAME(.dtors.*))
   *(.dtors)

  .jcr
   *(.jcr)

  .data.rel.ro
   *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
   *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)

  .dynamic
   *(.dynamic)

  .got            0x00000000006000c0        0x0
   *(.got)
   .got           0x00000000006000c0        0x0 a01.o
   *(.igot)
                  0x00000000006000c0                . = DATA_SEGMENT_RELRO_END 
(., (SIZEOF (.got.plt) >= 0x18)?0x18:0x0)

  .got.plt        0x00000000006000c0        0x0
   *(.got.plt)
   .got.plt       0x00000000006000c0        0x0 a01.o
   *(.igot.plt)
   .igot.plt      0x00000000006000c0        0x0 a01.o

  .data           0x00000000006000bd        0x0
   *(.data .data.* .gnu.linkonce.d.*)
   .data          0x00000000006000bd        0x0 a01.o

  .data1
   *(.data1)
                  0x00000000006000bd                _edata = .
                  [!provide]                        PROVIDE (edata = .)
                  0x00000000006000bd                . = .
                  0x00000000006000bd                __bss_start = .

  .bss            0x00000000006000bd        0x0
   *(.dynbss)
   *(.bss .bss.* .gnu.linkonce.b.*)
   .bss           0x00000000006000bd        0x0 a01.o
   *(COMMON)
                  0x00000000006000bd                . = ALIGN ((. != 
0x0)?0x8:0x1)

  .lbss
   *(.dynlbss)
   *(.lbss .lbss.* .gnu.linkonce.lb.*)
   *(LARGE_COMMON)
                  0x00000000006000c0                . = ALIGN (0x8)
                  0x00000000006000c0                . = SEGMENT_START 
("ldata-segment", .)

  .lrodata
   *(.lrodata .lrodata.* .gnu.linkonce.lr.*)

  .ldata          0x0000000000a000c0        0x0
   *(.ldata .ldata.* .gnu.linkonce.l.*)
                  0x0000000000a000c0                . = ALIGN ((. != 
0x0)?0x8:0x1)
                  0x0000000000a000c0                . = ALIGN (0x8)
                  0x0000000000a000c0                _end = .
                  [!provide]                        PROVIDE (end = .)
                  0x0000000000a000c0                . = DATA_SEGMENT_END (.)

  .stab
   *(.stab)

  .stabstr
   *(.stabstr)

  .stab.excl
   *(.stab.excl)

  .stab.exclstr
   *(.stab.exclstr)

  .stab.index
   *(.stab.index)

  .stab.indexstr
   *(.stab.indexstr)

  .comment
   *(.comment)

  .debug
   *(.debug)

  .line
   *(.line)

  .debug_srcinfo
   *(.debug_srcinfo)

  .debug_sfnames
   *(.debug_sfnames)

  .debug_aranges
   *(.debug_aranges)

  .debug_pubnames
   *(.debug_pubnames)

  .debug_info
   *(.debug_info .gnu.linkonce.wi.*)

  .debug_abbrev
   *(.debug_abbrev)

  .debug_line
   *(.debug_line .debug_line.* .debug_line_end)

  .debug_frame
   *(.debug_frame)

  .debug_str
   *(.debug_str)

  .debug_loc
   *(.debug_loc)

  .debug_macinfo
   *(.debug_macinfo)

  .debug_weaknames
   *(.debug_weaknames)

  .debug_funcnames
   *(.debug_funcnames)

  .debug_typenames
   *(.debug_typenames)

  .debug_varnames
   *(.debug_varnames)

  .debug_pubtypes
   *(.debug_pubtypes)

  .debug_ranges
   *(.debug_ranges)

  .debug_macro
   *(.debug_macro)

  .debug_addr
   *(.debug_addr)

  .gnu.attributes
   *(.gnu.attributes)

  /DISCARD/
   *(.note.GNU-stack)
   *(.gnu_debuglink)
   *(.gnu.lto_*)
  OUTPUT(a01 elf64-x86-64)

-- 
        Note, that I send and fetch email in batch, once every 24 hours.
                 If matter is urgent, try https://t.me/kaction
                                                                             --



reply via email to

[Prev in Thread] Current Thread [Next in Thread]