buildid

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

ELF Build ID Extractor

This project provides a Go package for extracting the build ID from ELF binaries on Linux systems.

Description

The buildid package allows you to retrieve the build ID from an ELF binary file. It supports extracting the build ID using the following methods:

  1. Reading the .note.go.buildid section for Go binaries.
  2. Reading the .note.gnu.build-id section for binaries with GNU build ID.
  3. Hashing the .text section if no build ID is found.

Usage

import "github.com/offlinehacker/buildid"

buildID, err := buildid.FromPath("path/to/binary")
if err != nil {
    // Handle the error
}

fmt.Println("Build ID:", buildID)

Platform Support

Please note that this package is intended for use on Linux systems only, as it relies on the ELF binary format.

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for more information.

Contributing

Contributions to this project are welcome. If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the project's GitHub repository.

Acknowledgments

This project is based on code from parca-agent

Documentation

Overview

Package buildid provides functionality to extract the build ID from ELF binaries on Linux systems.

The build ID is a unique identifier embedded in an ELF binary that helps identify the specific build of the binary.

Example usage:

package main

import (
	"fmt"
	"path/to/buildid"
)

func main() {
	buildID, err := buildid.FromPath("path/to/binary")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	fmt.Println("Build ID:", buildID)
}

Note: This package is intended for use on Linux systems only, as it relies on the ELF binary format.

For more information and detailed documentation, please refer to the package's README file and source code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromELF

func FromELF(ef *elf.File) (string, error)

FromELF returns the build ID for an ELF binary.

This method takes `elf.File` as an input and will attempt to extract buildid using different methods:

  • Reading the ".note.go.buildid" section for Go binaries.
  • Reading the ".note.gnu.build-id" section for binaries with GNU build ID.
  • Hashing the ".text" section if no build ID is found.

func FromPath

func FromPath(path string) (string, error)

FromPath attempts to extract builid from provided path to the binary.

See `FromELF` for more information.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL