From 5df04a7aa837a13b0e14d269c37bd3871d86bf08 Mon Sep 17 00:00:00 2001 From: "Jose E. Marchesi" Date: Fri, 22 Jul 2022 12:40:50 +0200 Subject: 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. --- gcc/btfout.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/btfout.cc') 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); -- cgit v1.1