Bug 26182 - type equality trouble with Linux kernel
Summary: type equality trouble with Linux kernel
Status: UNCONFIRMED
Alias: None
Product: libabigail
Classification: Unclassified
Component: default (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Dodji Seketeli
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-29 14:53 UTC by Giuliano Procida
Modified: 2020-09-08 17:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
analyse ABI for unmerged declarations (320 bytes, text/x-perl-script)
2020-06-29 14:53 UTC, Giuliano Procida
Details
analyse ABI for unmerged declarations (389 bytes, text/x-perl-script)
2020-09-04 09:18 UTC, Giuliano Procida
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Giuliano Procida 2020-06-29 14:53:11 UTC
Created attachment 12668 [details]
analyse ABI for unmerged declarations

We see some type equality issues when extracting ABI information from Linux kernel build trees.

It's not feasible to attach the huge ABI files, let along whole Linux build trees, so here's an approximate recipe for reproducing the issue.

1. Find (ideally) a Debian amd64 machine.

I suspect the problem is not architecture dependent. I've only tested with amd64 host and both amd64 and aarch64 target architectures.

2. Build a recent version of libabigail in $ABIGAIL.

I built 2b2f073d7afc8adf90d9d7bb5e3793846b4dd5d7. However, I believe the issue to be long-standing.

3. Fetch recent kernel sources.

I grabbed 9ebcfadb0610322ac537dd7aa5d9cbc2b2894c68 a.k.a. v5.8-rc3. However, we've also seen the issue on Android 4.19 branches.

4. Build a minimal kernel in $KERNEL.

make tinyconfig
make menuconfig
to add these:
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_INFO_DWARF4=y
make

5. Extract the ABI.

$ABIGAIL/build/tools/abidw --no-corpus-path --no-comp-dir-path --type-id-style hash --linux-tree $KERNEL --out-file $KERNEL/abi.xml

6. Check the ABI for unmerged declarations and definitions.

I put together a simple script to do this for structs and classes. It's attached.

In my case, it finds 10 identical definitions of mm_struct and 1 extra declaration. There are another 30 problematic types.

(The script also finds 92 declaration-only structs which seems unlikely but not impossible.)
Comment 1 Giuliano Procida 2020-09-04 09:18:10 UTC
Created attachment 12816 [details]
analyse ABI for unmerged declarations

This version does unions as well and gives more informative output.
Comment 2 Giuliano Procida 2020-09-08 17:21:42 UTC
Analysis is bogus because...

ABI extraction by libabigail behaves very differently if `CONFIG_MODULES=n`. This is because libabigail uses the presence of the ksymtab section to determine whether something is a "Linux kernel" or not. If it is, then different type equality rules apply (a bit like C++ ODR).

Right, so what I see is that declarations and definitions separately get collapsed done to one entity in the XML. However, the bit's that's missing may be special treatment to match up declarations and definitions when it's a Linux kernel.