Crate ver_shim

Crate ver_shim 

Source
Expand description

Runtime access to version data injected via a link section.

This crate provides a way to access git version information that has been injected into the binary via the .ver_shim_data link section.

The section format is:

  • First byte: number of members in the section (for forward compatibility)
  • Next num_members * 2 bytes: array of end offsets (u16, little-endian, relative to header)
  • Remaining bytes: concatenated string data

Header size = 1 + num_members * 2

For member N:

  • start = header_size + end[N-1] if N > 0, else header_size
  • end = header_size + end[N]
  • If start == end, the member is not present.
  • If N >= num_members (from first byte), the member is not present.

Using relative offsets means a zero-initialized buffer reads as “all members absent”. The num_members byte enables forward and backwards compatibility: old sections can be read by new code which has more members added in the future, and new sections can be read by old code as well, as long as we never change the index of any existing member.

Functions§

build_date
Returns the build date, if present.
build_timestamp
Returns the build timestamp, if present.
custom
Returns the custom application-specific string, if present.
git_branch
Returns the git branch name, if present.
git_commit_date
Returns the git commit date, if present.
git_commit_msg
Returns the git commit message, if present.
git_commit_timestamp
Returns the git commit timestamp, if present.
git_describe
Returns the git describe output, if present.
git_sha
Returns the git SHA, if present.