From 4620cb693182cc7c5309458d81646c72d8123219 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 22 May 2023 12:44:52 -0400 Subject: [PATCH] elf: Define Go Build ID constants --- crates/examples/src/readobj/elf.rs | 2 ++ src/elf.rs | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/crates/examples/src/readobj/elf.rs b/crates/examples/src/readobj/elf.rs index bf9976d8..1bec17ac 100644 --- a/crates/examples/src/readobj/elf.rs +++ b/crates/examples/src/readobj/elf.rs @@ -562,6 +562,7 @@ fn print_notes( ELF_NOTE_CORE | ELF_NOTE_LINUX => FLAGS_NT_CORE, ELF_NOTE_SOLARIS => FLAGS_NT_SOLARIS, ELF_NOTE_GNU => FLAGS_NT_GNU, + ELF_NOTE_GO => FLAGS_NT_GO, _ => { // TODO: NT_VERSION &[] @@ -3234,6 +3235,7 @@ const FLAGS_NT_GNU: &[Flag] = &flags!( NT_GNU_GOLD_VERSION, NT_GNU_PROPERTY_TYPE_0, ); +const FLAGS_NT_GO: &[Flag] = &flags!(NT_GO_BUILD_ID); const FLAGS_GNU_PROPERTY: &[Flag] = &flags!( GNU_PROPERTY_STACK_SIZE, GNU_PROPERTY_NO_COPY_ON_PROTECTED, diff --git a/src/elf.rs b/src/elf.rs index 45e9785e..da68ec2d 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -1835,6 +1835,10 @@ pub const NT_SOLARIS_PAGESIZE_HINT: u32 = 1; /// GNU entries in the note section have this name. pub const ELF_NOTE_GNU: &[u8] = b"GNU"; +/// Go entries in the note section have this name. +// See https://go-review.googlesource.com/9520 and https://go-review.googlesource.com/10704. +pub const ELF_NOTE_GO: &[u8] = b"Go"; + // Note types for `ELF_NOTE_GNU`. /// ABI information. @@ -1870,6 +1874,12 @@ pub const NT_GNU_HWCAP: u32 = 2; /// The descriptor consists of any nonzero number of bytes. pub const NT_GNU_BUILD_ID: u32 = 3; +/// Build ID bits as generated by Go's gc compiler. +/// +/// The descriptor consists of any nonzero number of bytes. +// See https://go-review.googlesource.com/10707. +pub const NT_GO_BUILD_ID: u32 = 4; + /// Version note generated by GNU gold containing a version string. pub const NT_GNU_GOLD_VERSION: u32 = 4;