This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold] creating linker generated output section and segment


Hi, I'm working on add a new target to gold linker where the abi
requires the linker to generate a custom section (a custom strtab) and
mapped to a output segment for simulator use. i.e. This section does
not need data from input objects.

I'm current doing this in the target's do_finialize_sections() like this:

 // create custom output section and segment
  Stringpool *mystrtab = new Stringpool();
  mystrtab->add("mystr1", false, NULL);
  mystrtab->add("mystr2", false, NULL);
  mystrtab->set_string_offsets();

// using target's do_make_output_section here which simply does new
Output_section
// as layout's make_output_section is private
  Output_section* mystrtab_os = this->make_output_section(".mystrtab",
                                                elfcpp::SHT_STRTAB,
elfcpp::SHF_ALLOC);

  Output_data_strtab* mystrtab_data = new Output_data_strtab(mystrtab);
  mystrtab_os->add_output_section_data(mystrtab_data);

  //do I need to add the section to section_list and how? Below does not work.
  //layout->section_list().push_back(mystrtab_os);

  Output_segment* mystrtab_seg =
    layout->make_output_segment(elfcpp::PT_LOPROC+0x1234, 0);
  mystrtab_seg->add_output_section_to_nonload(mystrtab_os, elfcpp::PF_R);

This is currently not working yet with an runtime assert of Output
section address not valid.
But I want to make sure I'm on the right track first so I want to ask
if this the right way to add linker generated sections and segment?

Any comment appreciated. Thanks!

Kai


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]