diff options
author | Jose E. Marchesi <jose.marchesi@oracle.com> | 2022-07-22 12:40:50 +0200 |
---|---|---|
committer | Jose E. Marchesi <jose.marchesi@oracle.com> | 2022-08-02 19:25:21 +0200 |
commit | 5df04a7aa837a13b0e14d269c37bd3871d86bf08 (patch) | |
tree | bff5a3fb0832cd3443b0db1d1515a3c77b489e20 /gcc/btfout.cc | |
parent | 6a11f2d974a912aaaedb0ce32cdfde10193003cd (diff) | |
download | gcc-5df04a7aa837a13b0e14d269c37bd3871d86bf08.zip gcc-5df04a7aa837a13b0e14d269c37bd3871d86bf08.tar.gz gcc-5df04a7aa837a13b0e14d269c37bd3871d86bf08.tar.bz2 |
btf: do not use the CHAR `encoding' bit for BTF
Contrary to CTF and our previous expectations, as per [1], turns out
that in BTF:
1) The `encoding' field in integer types shall not be treated as a
bitmap, but as an enumerated, i.e. these bits are exclusive to each
other.
2) The CHAR bit in `encoding' shall _not_ be set when emitting types
for char nor `unsigned char'.
Consequently this patch clears the CHAR bit before emitting the
variable part of BTF integral types. It also updates the testsuite
accordingly, expanding it to check for BOOL bits.
[1] https://lore.kernel.org/bpf/a73586ad-f2dc-0401-1eba-2004357b7edf@fb.com/T/#t
gcc/ChangeLog:
* btfout.cc (output_asm_btf_vlen_bytes): Do not use the CHAR
encoding bit in BTF.
gcc/testsuite/ChangeLog:
* gcc.dg/debug/btf/btf-int-1.c: Do not check for char bits in
bti_encoding and check for bool bits.
Diffstat (limited to 'gcc/btfout.cc')
-rw-r--r-- | gcc/btfout.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 594cba8..997a33f 100644 --- a/gcc/btfout.cc +++ b/gcc/btfout.cc @@ -918,6 +918,10 @@ output_asm_btf_vlen_bytes (ctf_container_ref ctfc, ctf_dtdef_ref dtd) if (dtd->dtd_data.ctti_size < 1) break; + /* In BTF the CHAR `encoding' seems to not be used, so clear it + here. */ + dtd->dtd_u.dtu_enc.cte_format &= ~BTF_INT_CHAR; + encoding = BTF_INT_DATA (dtd->dtd_u.dtu_enc.cte_format, dtd->dtd_u.dtu_enc.cte_offset, dtd->dtd_u.dtu_enc.cte_bits); |