Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gitBOM support via environment variable GITBOM_BUILD_MODE #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yonhan3
Copy link

@yonhan3 yonhan3 commented Oct 24, 2022

Signed-off-by: Yongkui Han [email protected]

@yonhan3
Copy link
Author

yonhan3 commented Oct 24, 2022

This commit adds gitBOM support for binutils' 4 tools: objcopy, strip, ar, ranlib.
It also updates the readelf tool to support the new .note.gitbom ELF section.
This aligns with GCC's gitBOM support.

  1. support of below environmental variables to turn on gitBOM feature:
    GITBOM_BUILD_MODE=sha1,sha256,create_adg,record_hash
    GITBOM_ADG_DIR=/any/directory

Refer to omnibor/spec#22 for details on the proposal.

  1. support of the same symlink farm feature as Bomsh, to persist the artifact-id to ADG-doc mappings in the file system.
    all the symlinks are created in $GITBOM_ADG_DIR/symlinks/ directory.

  2. when creating ADG doc, for single input-file case, reuse the same ADG doc of input file if the input file already has associated ADG doc.
    if input doc has no ADG doc, then create a new ADG doc, and create the symlink for the output file.
    all the ADG docs are created in $GITBOM_ADG_DIR/objects/ directory.

  3. when record_hash is enabled, it records the hashes of output/inpute files in the $GITBOM_ADG_DIR/metadata/binutils/*.gitbom_raw_logfile,
    in the same format as Bomsh's /tmp/bomsh_hook_raw_logfile file, so Bomsh scripts can process these *.gitbom_raw_logfile directly.

  4. binutils does not support the embed_bomid feature as in GCC/clang compilers.

  5. The combinations of sha1-only, sha256-only, or sha1+sha256 are all supported.

  6. "readelf -n hello" can now correctly display .note.gitbom ELF note section.

  7. "unset GITBOM_BUILD_MODE" or "GITBOM_BUILD_MODE=" will turn off gitBOM support.

Here is the "readelf -n hello" output:

root@60cb7fac1537:/home/gcc-dir/gcc-gitbom/build/mytestdir# /home/binutils-gitbom-dir/binutils-gitbom/binutils-2.39/binutils/readelf -n hello

Displaying notes found in: .note.ABI-tag
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 3.2.0

Displaying notes found in: .note.gitbom
  Owner                Data size        Description
  GITBOM               0x00000014       NT_GITBOM (SHA1 GITOID)
    SHA1 GitOID: 616620ebaeb580c14e0138456a961ebed2df41a2
  GITBOM               0x00000020       NT_GITBOM (SHA256 GITOID)
    SHA256 GitOID: c76284ff3b421d38a69c6e050ff6bcda2700af0713b0f2c5103d94464baa6152
root@60cb7fac1537:/home/gcc-dir/gcc-gitbom/build/mytestdir#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant