| commit | 82face929aea9de06e945ac5707172404b999d5a | [log] [tgz] |
|---|---|---|
| author | Aleksei Vetrov <vvvvvv@google.com> | Fri Jun 16 16:28:03 2023 +0100 |
| committer | Matthias Maennich <maennich@google.com> | Thu Jun 22 22:16:01 2023 +0100 |
| tree | 1cd335a986e731df89c756d5799b07202ea106ea | |
| parent | cdb2ff6ca3b3cf9dc60618dbc58f965be0bd071a [diff] |
DWARF processor: add scoped name for functions Functions are sometimes defined twice: the first inside the class, where it serves as declaration of method or static field and the second outside of the class where there is definition. The second refers to the first through DW_AT_specification. This change propagetes scoped name from entry with name to entry with specification. First part is `GetNameWithContext` which extracts name and/or specification for entry. If entry has name directly (not through specification), it is wrapped into the current scope and stored in the `scoped_names_` collection. `GetNameWithContext` is called for every subroutine entry in DWARF. Second part is using `NameWithContext` for assigning scoped name to the symbol. It is done in `GetScopedNameForSymbol`. Either we already have scoped name, which is immediately returned, or we have specification, which is registered as "unresolved" in `unresolved_symbol_specifications_`. After DWARF processing pass, all unresolved pairs "symbol-specification" are resolved through the `scoped_names_` in `ResolveSymbolSpecifications`. Using sort and linear pass is more efficient than resolving through `std::unordered_map`, because "keys" (`Dwarf_Off`) are already almost sorted, because processor goes through DWARF entries sequentially. `std::sort` is needed to guarantee this invariant. After this changes scope processing takes less than 100ms from 14.7s of a kernel processing. PiperOrigin-RevId: 540886421 Change-Id: Ie834c37c43f0ae4974ee827aa32b09ab233c1ce5
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 libxml2 for XML parsing, on libelf to find .BTF sections and on Linux UAPI headers for BTF types.
To build from source, you will need a few dependencies:
| Debian | RedHat |
|---|---|
| libelf-dev | elfutils-devel |
| libxml2-dev | libxml2-devel |
| linux-libc-dev | kernel-headers |
Instructions are included for local and Docker builds.
You can build as follows:
$ make
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
If you want to bind your development code to the container:
$ docker run -it $PWD:/src -it stg
The source code is added to /src, so when your code is bound you can edit on your host and re-compile in the container.
Note that the Dockerfile can provide a development environment (non multi-stage build with the source code) or a production image (a multi-stage build with only the final binary). By default we provide the first, and you can uncomment the final lines of the file for the latter.
See CONTRIBUTING.md for details.