aboutsummaryrefslogtreecommitdiff
path: root/src/common/linux/synth_elf.cc
diff options
context:
space:
mode:
authorted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2011-08-30 15:21:07 +0000
committerted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2011-08-30 15:21:07 +0000
commit8ade75f9558e31d25aec862a552fe78f9ba98c82 (patch)
treee96afdd18e5626fdc05a1e4cfabc1e40a1376ff2 /src/common/linux/synth_elf.cc
parentFix libcurl include in http_upload (trivial, no bug) (diff)
downloadbreakpad-8ade75f9558e31d25aec862a552fe78f9ba98c82.tar.xz
issue 243 - Linux dumper should use build id produced by ld --build-id if available
R=thestig at http://breakpad.appspot.com/185001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@830 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/linux/synth_elf.cc')
-rw-r--r--src/common/linux/synth_elf.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/common/linux/synth_elf.cc b/src/common/linux/synth_elf.cc
index 8f8aad32..3e10b691 100644
--- a/src/common/linux/synth_elf.cc
+++ b/src/common/linux/synth_elf.cc
@@ -3,10 +3,15 @@
#include <assert.h>
#include <elf.h>
#include <stdio.h>
+#include <string.h>
namespace google_breakpad {
namespace synth_elf {
+#ifndef NT_GNU_BUILD_ID
+#define NT_GNU_BUILD_ID 3
+#endif
+
ELF::ELF(uint16_t machine,
uint8_t file_class,
Endianness endianness)
@@ -169,6 +174,31 @@ void SymbolTable::AddSymbol(const string& name, uint64_t value,
D64(size);
}
+BuildIDNote::BuildIDNote(const uint8_t* id_bytes,
+ size_t id_size,
+ Endianness endianness) : Section(endianness) {
+ const char kNoteName[] = "GNU";
+ // Elf32_Nhdr and Elf64_Nhdr are exactly the same.
+ Elf32_Nhdr note_header;
+ memset(&note_header, 0, sizeof(note_header));
+ note_header.n_namesz = sizeof(kNoteName);
+ note_header.n_descsz = id_size;
+ note_header.n_type = NT_GNU_BUILD_ID;
+
+ Append(reinterpret_cast<const uint8_t*>(&note_header),
+ sizeof(note_header));
+ AppendCString(kNoteName);
+ Append(id_bytes, id_size);
+}
+
+// static
+void BuildIDNote::AppendSection(ELF& elf,
+ const uint8_t* id_bytes,
+ size_t id_size) {
+ const char kBuildIDSectionName[] = ".note.gnu.build-id";
+ BuildIDNote note(id_bytes, id_size, elf.endianness());
+ elf.AddSection(kBuildIDSectionName, note, SHT_NOTE);
+}
+
} // namespace synth_elf
} // namespace google_breakpad
-