[GOLD] Handle merged input sections in Output_section::get_input_sections()

Doug Kwan (關振德) dougkwan@google.com
Wed Apr 7 01:02:00 GMT 2010
Hi Ian,

   The compressed ARM kernel image zImage is built using a linker
script, which contains the following:

OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
  /DISCARD/ : {
    *(.ARM.exidx*)
    *(.ARM.extab*)
  }

  . = TEXT_START;
  _text = .;

  .text : {
    _start = .;
    *(.start)
    *(.text)
    *(.text.*)
    *(.fixup)
    *(.gnu.warning)
    *(.rodata)
    *(.rodata.*)
    *(.glue_7)
    *(.glue_7t)
    *(.piggydata)
    . = ALIGN(4);
  }

  _etext = .;
..... [rest of script omitted]

The final image does not contain the ELF header and the entry point is
set to address 0.   The input sections .rodata* are handled by gold as
merged sections.  They are not exported to the script by
Output_section::get_input_sections() and are left at the beginning of
the .text output section when normal input sections are removed.  When
the script re-inserts the input sections again,  the merged input
sections are now input beginning .text, where the entry point is
located.  That causes the output not bootable since the entry point
contains a string instead of the first instruction.

I am thinking about adding an get_input_sections method to the base
class of merged sections.  What do you think?   We may optimize for
speed by not exporting if the output section contains nothing but
merged input section.

-Doug



More information about the Binutils mailing list