This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch/rfc] Fix minor difference in section naming between gold and ld.
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: binutils at sourceware dot org
- Date: Tue, 17 Mar 2009 10:12:06 -0700 (PDT)
- Subject: [patch/rfc] Fix minor difference in section naming between gold and ld.
Greetings,
objdump -sj .note.gnu.build-id elf-file
produces the dump of build-id for ld-linked elf images, but not for
gold-linked ones:
echo "void foo() { }" | gcc -c -fPIC -xc - -o foo.o
ld -shared --build-id -o foo.so foo.o
objdump -sj .note.gnu.build-id foo.so
foo.so: file format elf64-x86-64
Contents of section .note.gnu.build-id:
0158 04000000 14000000 03000000 474e5500 ............GNU.
0168 a89f0845 5797e030 75394411 342c6456 ...EW..0u9D.4,dV
0178 654faf59 eO.Y
gold-x86_64/ld -shared --build-id -o foo.so foo.o
objdump -sj .note.gnu.build-id foo.so
foo.so: file format elf64-x86-64
Attached patch (approved off-list by Ian Lance Taylor) fixes this.
Tested on Linux/x86_64.
OK to commit?
Thanks,
--
Paul Pluzhnikov
2009-03-16 Paul Pluzhnikov <ppluzhnikov@google.com>
* layout.h (Layout::create_note): Add section_name parameter.
* layout.cc (Layout::create_note): Likewise.
(Layout::create_build_id, Layout::create_gold_note): Fix callers.
Index: layout.cc
===================================================================
RCS file: /cvs/src/src/gold/layout.cc,v
retrieving revision 1.119
diff -u -p -u -r1.119 layout.cc
--- layout.cc 1 Mar 2009 22:22:02 -0000 1.119
+++ layout.cc 17 Mar 2009 17:03:49 -0000
@@ -1327,7 +1327,8 @@ Layout::finalize(const Input_objects* in
// *TRAILING_PADDING to the number of trailing zero bytes required.
Output_section*
-Layout::create_note(const char* name, int note_type, size_t descsz,
+Layout::create_note(const char* name, int note_type,
+ const char* section_name, size_t descsz,
bool allocate, size_t* trailing_padding)
{
// Authorities all agree that the values in a .note field should
@@ -1394,7 +1395,7 @@ Layout::create_note(const char* name, in
memcpy(buffer + 3 * (size / 8), name, namesz);
- const char* note_name = this->namepool_.add(".note", false, NULL);
+ const char *note_name = this->namepool_.add(section_name, false, NULL);
elfcpp::Elf_Xword flags = 0;
if (allocate)
flags = elfcpp::SHF_ALLOC;
@@ -1424,7 +1425,8 @@ Layout::create_gold_note()
size_t trailing_padding;
Output_section *os = this->create_note("GNU", elfcpp::NT_GNU_GOLD_VERSION,
- desc.size(), false, &trailing_padding);
+ ".note.gnu.gold-version", desc.size(),
+ false, &trailing_padding);
Output_section_data* posd = new Output_data_const(desc, 4);
os->add_output_section_data(posd);
@@ -1556,7 +1558,8 @@ Layout::create_build_id()
// Create the note.
size_t trailing_padding;
Output_section* os = this->create_note("GNU", elfcpp::NT_GNU_BUILD_ID,
- descsz, true, &trailing_padding);
+ ".note.gnu.build-id", descsz, true,
+ &trailing_padding);
if (!desc.empty())
{
Index: layout.h
===================================================================
RCS file: /cvs/src/src/gold/layout.h,v
retrieving revision 1.61
diff -u -p -u -r1.61 layout.h
--- layout.h 1 Mar 2009 22:22:02 -0000 1.61
+++ layout.h 17 Mar 2009 17:03:49 -0000
@@ -456,12 +456,12 @@ class Layout
};
typedef std::vector<Group_signature> Group_signatures;
- // Create a .note section, filling in the header.
+ // Create a note section, filling in the header.
Output_section*
- create_note(const char* name, int note_type, size_t descsz,
- bool allocate, size_t* trailing_padding);
+ create_note(const char* name, int note_type, const char *section_name,
+ size_t descsz, bool allocate, size_t* trailing_padding);
- // Create a .note section for gold.
+ // Create a note section for gold version.
void
create_gold_note();