gold patch committed: Make notes work better with linker scripts

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

gold patch committed: Make notes work better with linker scripts

Ian Lance Taylor
When creating a special note section in gold, gold was always creating
a new output section.  That is not the right thing to do when using a
linker script which includes *(.note*) as an input spec.  This patch
changes the note code to use the section specified in the linker
script when appropriate.

This case came up when using gold to build the x86_64 Linux kernel.
Unfortunately there is still another case which is failing, an
assertion failure when linking .vmlinux.  I have not yet looked into
that problem.

Ian


2009-06-23  Ian Lance Taylor  <[hidden email]>

        PR 10156
        * layout.cc (Layout::create_note): Use choose_output_section
        rather than make_output_section.



Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.129
diff -p -u -r1.129 layout.cc
--- layout.cc 24 Jun 2009 00:38:00 -0000 1.129
+++ layout.cc 24 Jun 2009 04:32:27 -0000
@@ -1361,10 +1361,11 @@ Layout::finalize(const Input_objects* in
 }
 
 // Create a note header following the format defined in the ELF ABI.
-// NAME is the name, NOTE_TYPE is the type, DESCSZ is the size of the
-// descriptor.  ALLOCATE is true if the section should be allocated in
-// memory.  This returns the new note section.  It sets
-// *TRAILING_PADDING to the number of trailing zero bytes required.
+// NAME is the name, NOTE_TYPE is the type, SECTION_NAME is the name
+// of the section to create, DESCSZ is the size of the descriptor.
+// ALLOCATE is true if the section should be allocated in memory.
+// This returns the new note section.  It sets *TRAILING_PADDING to
+// the number of trailing zero bytes required.
 
 Output_section*
 Layout::create_note(const char* name, int note_type,
@@ -1435,13 +1436,12 @@ Layout::create_note(const char* name, in
 
   memcpy(buffer + 3 * (size / 8), name, namesz);
 
-  const char *note_name = this->namepool_.add(section_name, false, NULL);
   elfcpp::Elf_Xword flags = 0;
   if (allocate)
     flags = elfcpp::SHF_ALLOC;
-  Output_section* os = this->make_output_section(note_name,
- elfcpp::SHT_NOTE,
- flags);
+  Output_section* os = this->choose_output_section(NULL, section_name,
+   elfcpp::SHT_NOTE,
+   flags, false);
   Output_section_data* posd = new Output_data_const_buffer(buffer, notehdrsz,
    size / 8,
    "** note header");