adding Dockerfile, Makefile, and documentation

There is currently no instruction or build file to make it easy
to develop STG tools. This changeset adds a basic Makefile, automated
container build, and associated documentation as the start of work
to help with that. Note that it is not intended to be a final
solution, but to empower interested developers to build STG tools.
Note that the Dockerfile uses a Fedora base, and this is done for
the libabigail build, which would take quite a bit of extra work
to figure out on a debian slim base. This Dockerfile base can be
updated to debian-slim (a more stable container) when the
libabigail dependency is removed.

Signed-off-by: Vanessa Sochat <vsochat@gmail.com>
Change-Id: Ifa6528cc738e7a694a3b4470894ab9d3484d8394
3 files changed
tree: 558600c61c4df005e9724101d225f37063931597
  1. fuzz/
  2. abigail_reader.cc
  3. abigail_reader.h
  4. Android.bp
  5. btf_reader.cc
  6. btf_reader.h
  7. btfinfo.cc
  8. CONTRIBUTING.md
  9. crc.h
  10. Dockerfile
  11. error.h
  12. error_test.cc
  13. id.h
  14. LICENSE
  15. Makefile
  16. METADATA
  17. MODULE_LICENSE_LLVM
  18. order.h
  19. order_test.cc
  20. OWNERS
  21. README.md
  22. reporting.cc
  23. reporting.h
  24. scc.h
  25. scc_test.cc
  26. stg.cc
  27. stg.h
  28. stgdiff.cc
README.md

Symbol-Type Graph (STG)

The STG (symbol-type graph) is an ABI representation and this project contains tools for the creation and comparison of such representations. At present parsers exist for libabigail's ABI XML (C types only) and BTF. The ABI diff tool, stgdiff, supports multiple reporting options. This software currently depends on libabigail for ELF symbol functionality, on libxml2 for XML parsing and on Linux UAPI headers for BTF types.

How to build the project

Local Build

To build from source, you will need several dependencies on your host, mentioned in the Dockerfile. Importantly, you will need a cloned and compiled libabigail, which can be done as follows:

git clone git://sourceware.org/git/libabigail.git cd libabigail

Note that if you want to checkout a particular tag, you can do git tag and then git checkout <tag> to ensure you aren't working with a moving target. Next, prepare your build directory, and build:

mkdir -p build autoreconf -i cd build VISIBILITY_FLAGS=default
../configure --prefix=/opt/libabigail make -j $(nproc) all make install

In the above, setting the visibility flags variable is important as will not work without it - symbols that need to be found in the final compiled library will be hidden, and the build of STG tools will fail due to missing symbols:

undefined reference to
`abigail::symtab_reader::symtab::make_filter() const' undefined
reference to `abigail::elf_helpers::find_section(Elf*, ...  collect2:
error: ld returned 1 exit status make: *** [Makefile:17: stgdiff]
Error 1

Specifically the symtab reader is an internal header and internal source file, and the interface is not exposed. You can read more about visibility in libabigail here. Note that this particular issue has been reported to the libabigail maintainers, specifically a suggestion that these functions should not be private by default.

You can then provide the libabigail source path to the Makefile as follows. Let's say you installed libabigail to the path /abigail, you might run:

LIBABIGAIL_SRC=/abigail make -j $(nproc)

And that‘s it! If you want a portable environment ready to go, it’s recommended to build the container.

Docker

A Dockerfile is provided to build a container with libabigail to easily compile the STG tools:

$ docker build -t stg .

And then enter the container:

$ docker run -it stg

Libabigail (a current dependency) is on the path, and the code for the repository should be in the present working directory. You can build as follows:

$ make

Note that libabigail has source code and a build under /code, and this path is default in the Makefile. If you want to bind your development code to the container:

$ docker run -v $PWD:/src -it stg

And then you can make changes on the host and build / test in the container.

Contributions

See CONTRIBUTING.md for details.