Re: [GCC16,RFC,V2 02/14] aarch64: add new define_insn for subg

2025-04-22 Thread Indu Bhagat
On 4/22/25 11:00 AM, Indu Bhagat wrote: On 4/15/25 8:35 AM, Richard Sandiford wrote: Hi, Indu Bhagat writes: subg (Subtract with Tag) is an Armv8.5-A memory tagging (MTE) instruction.  It can be used to subtract an immediate value scaled by the tag granule from the address in the source

Re: [GCC16,RFC,V2 04/14] aarch64: add new definition for post-index st2g

2025-04-22 Thread Indu Bhagat
On 4/15/25 11:52 AM, Richard Sandiford wrote: Indu Bhagat writes: Using post-index st2g is a faster way of memory tagging/untagging. Because a post-index 'st2g tag, [addr], #32' is equivalent to: stg tag, addr, #0 stg tag, addr, #16 add addr, addr, #32 TBD: -

Re: [GCC16,RFC,V2 03/14] aarch64: add new insn definition for st2g

2025-04-22 Thread Indu Bhagat
On 4/15/25 9:21 AM, Richard Sandiford wrote: Indu Bhagat writes: Store Allocation Tags (st2g) is an Armv8.5-A memory tagging (MTE) instruction. It stores an allocation tag to two tag granules of memory. TBD: - Not too sure what is the best way to generate the st2g yet; A subsequent

Re: [GCC16,RFC,V2 02/14] aarch64: add new define_insn for subg

2025-04-22 Thread Indu Bhagat
On 4/15/25 8:35 AM, Richard Sandiford wrote: Hi, Indu Bhagat writes: subg (Subtract with Tag) is an Armv8.5-A memory tagging (MTE) instruction. It can be used to subtract an immediate value scaled by the tag granule from the address in the source register. gcc/ChangeLog: * config

Re: [GCC16,RFC,V2 00/14] Add -fsanitize=memtag

2025-04-11 Thread Indu Bhagat
On 4/11/25 11:30 AM, Indu Bhagat wrote: Hi, For MTE stack tagging support in the GNU toolchain, one of the key pieces is the memtag sanitizer in GCC. The current series is V2 of the previously sent RFC series https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668017.html. This is now

[GCC16, RFC, V2 09/14] hwasan: add support for generating MTE instructions for memory tagging

2025-04-11 Thread Indu Bhagat
Memory tagging is used for detecting memory safety bugs. On AArch64, the memory tagging extension (MTE) helps in reducing the overheads of memory tagging: - CPU: MTE instructions for efficiently tagging and untagging memory. - Memory: New memory type, Normal Tagged Memory, added to the Arm Ar

[GCC16, RFC, V2 13/14] gcc: aarch64: memtag: update link spec to pass arguments to linker

2025-04-11 Thread Indu Bhagat
In context of stack tagging, the AArch64 Memtag ABI Extension to ELF specifies the usage of two dynamic tags for the dynamic loader to do the necessary tasks: - If DT_AARCH64_MEMTAG_MODE is present, the dynamic loader should (in a platform-specific specific way) enable MTE for the process.

[GCC16, RFC, V2 14/14] aarch64: testsuite: emit CFI directive when stack frames use MTE tagging

2025-04-11 Thread Indu Bhagat
Emit .cfi_mte_memtag_frame after .cfi_startproc for each function where the stack memory uses MTE protection. TBD: - Need to double check if checking on frame_size is the right thing to do. clang generates cfi_mte_tagged_frame directive irrespective of whether the function ended up taggi

[GCC16, RFC, V2 10/14] asan: memtag: enable pass_asan for memtag sanitizer

2025-04-11 Thread Indu Bhagat
Check for SANITIZER_MEMTAG in the gate function for pass_asan gimple pass; enable it. TBD: - This commit was initially carved out in order to ensure each patch works in isolation. Need to revisit and double check this. gcc/ChangeLog: * asan.cc (memtag_sanitize_p): Fix definition.

[GCC16,RFC,V2 08/14] aarch64: memtag: implement target hooks

2025-04-11 Thread Indu Bhagat
MEMTAG sanitizer, which is based on the HWASAN sanitizer, will invoke the target-specific hooks to create a random tag, add tag to memory address, and finally tag and untag memory. Implement the target hooks to emit MTE instructions if MEMTAG sanitizer is in effect. Continue to use the default ta

[GCC16,RFC,V2 03/14] aarch64: add new insn definition for st2g

2025-04-11 Thread Indu Bhagat
Store Allocation Tags (st2g) is an Armv8.5-A memory tagging (MTE) instruction. It stores an allocation tag to two tag granules of memory. TBD: - Not too sure what is the best way to generate the st2g yet; A subsequent patch will emit them in one of the target hooks. gcc/ChangeLog:

[GCC16, RFC, V2 12/14] memtag: doc: add new option -fsanitize-memtag-mode=

2025-04-11 Thread Indu Bhagat
Add new command line option -fsanitize-memtag-mode with three possible values: - sync (default) - async - asymm This allows the user to select the fault conveyance model when using MTE instructions for their applications. This option is not (sanity checked) processed in GCC at all currently.

[GCC16,RFC,V2 06/14] opts: doc: aarch64: add new memtag sanitizer

2025-04-11 Thread Indu Bhagat
Add new command line option -fsanitize=memtag with the following new params: --param memtag-instrument-stack [0,1] (default 1) to use MTE insns for enabling dynamic checking of stack variables. --param memtag-instrument-alloca [0,1] (default 1) to use MTE insns for enabling dynamic checking of st

[GCC16, RFC, V2 01/14] opts: use unsigned HOST_WIDE_INT for sanitizer flags

2025-04-11 Thread Indu Bhagat
Currently, the data type of sanitizer flags is unsigned int, with SANITIZE_SHADOW_CALL_STACK (1UL << 31) being highest individual enumerator for enum sanitize_code. Use 'unsigned HOST_WIDE_INT' data type to allow for more distinct instrumentation modes be added when needed. FIXME: 1. Is using d_u

[GCC16,RFC,V2 11/14] memtag: testsuite: add new tests

2025-04-11 Thread Indu Bhagat
Add basic tests for MEMTAG sanitizer. MEMTAG sanitizer uses target hooks to emit AArch64 specific MTE instructions. Add new target-specific tests. The currently generated code currently has the following known limitations: 1. For basic-1.c testcase, currently we generate: subgx0, x0

[GCC16, RFC, V2 07/14] targhooks: add new target hook TARGET_MEMTAG_TAG_MEMORY

2025-04-11 Thread Indu Bhagat
Add a new target hook TARGET_MEMTAG_TAG_MEMORY to tag (and untag) memory. The default implementation is empty. Hardware-assisted sanitizers on architectures providing instructions to tag/untag memory can then make use of this target hook. On AArch64, e.g., the MEMTAG sanitizer will use this hook

[GCC16,RFC,V2 04/14] aarch64: add new definition for post-index st2g

2025-04-11 Thread Indu Bhagat
Using post-index st2g is a faster way of memory tagging/untagging. Because a post-index 'st2g tag, [addr], #32' is equivalent to: stg tag, addr, #0 stg tag, addr, #16 add addr, addr, #32 TBD: - Currently generated by in the aarch64 backend. Not sure if this is the right way to do i

[GCC16,RFC,V2 00/14] Add -fsanitize=memtag

2025-04-11 Thread Indu Bhagat
)" https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst [5] "MTE – discussion on Exception unwinding ABI" https://discourse.llvm.org/t/mte-discussion-on-exception-unwinding-abi/55226RFC Thanks, Indu Bhagat (14): opts: use unsigned HOST_WIDE_INT for sanitizer flags

[GCC16,RFC,V2 05/14] aarch64: add new definition for post-index stg

2025-04-11 Thread Indu Bhagat
Using post-index stg is a faster way of memory tagging/untagging. TBD: - Currently generated by in the aarch64 backend. Not sure if this is the right way to do it. - Also not clear how to weave in the generation of stzg. ChangeLog: * gcc/config/aarch64/aarch64.md --- [New in RF

[GCC16,RFC,V2 02/14] aarch64: add new define_insn for subg

2025-04-11 Thread Indu Bhagat
subg (Subtract with Tag) is an Armv8.5-A memory tagging (MTE) instruction. It can be used to subtract an immediate value scaled by the tag granule from the address in the source register. gcc/ChangeLog: * config/aarch64/aarch64.md (subg): New definition. --- gcc/config/aarch64/aarch64.m

Re: [PATCH v2 3/5][STAGE1] ctf: translate annotation DIEs to internal ctf

2025-02-24 Thread Indu Bhagat
On 2/6/25 11:54 AM, David Faust wrote: Translate DW_TAG_GNU_annotation DIEs created for C attributes btf_decl_tag and btf_type_tag into an in-memory representation in the CTF/BTF container. They will be output in BTF as BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records. The new CTF kinds used to

Re: [PATCH v2 4/5][STAGE1] btf: generate and output DECL_TAG and TYPE_TAG records

2025-02-24 Thread Indu Bhagat
On 2/6/25 11:54 AM, David Faust wrote: Support the btf_decl_tag and btf_type_tag attributes in BTF by creating and emitting BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records, respectively, for them. Some care is required when -gprune-btf is in effect to avoid emitting decl or type tags for declara

Re: [PATCH v2 5/5][STAGE1] doc: document btf_type_tag and btf_decl_tag attributes

2025-02-24 Thread Indu Bhagat
On 2/6/25 11:54 AM, David Faust wrote: gcc/ * doc/extend.texi (Common Variable Attributes): Document btf_decl_tag attribute. (Common Type Attributes): Document btf_type_tag attribute. --- gcc/doc/extend.texi | 68 + 1 file cha

Generating dynamic tags for applications using MTE tagged stack

2024-11-28 Thread Indu Bhagat
Hi, I need some feedback/discussion on GCC/Binutils command line options around MTE tagged stack usage. See "Proposed GCC/Binutils implementation for the user space ABI for MTE stack" below in the email for the high-level design. Thanks Indu - MTE Background -- Memory Ta

Re: [RFC 3/9] aarch64: add new insn definition for st2g

2024-11-15 Thread Indu Bhagat
On 11/13/24 3:02 PM, Richard Sandiford wrote: Indu Bhagat writes: Store Allocation Tags (st2g) is an Armv8.5-A memory tagging (MTE) instruction. It stores an allocation tag to two tag granules of memory. TBD: - Not too sure what is the best way to generate the st2g yet; A subsequent

Re: [PATCH 3/5] ctf: translate annotation DIEs to internal ctf

2024-11-13 Thread Indu Bhagat
On 10/30/24 11:31 AM, David Faust wrote: Translate DW_TAG_GNU_annotation DIEs created for C attributes btf_decl_tag and btf_type_tag into an in-memory representation in the CTF/BTF container. They will be output in BTF as BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records. The new CTF kinds used t

Re: [PATCH 4/5] btf: generate and output DECL_TAG and TYPE_TAG records

2024-11-13 Thread Indu Bhagat
On 10/30/24 11:31 AM, David Faust wrote: Support the btf_decl_tag and btf_type_tag attributes in BTF by creating and emitting BTF_KIND_DECL_TAG and BTF_KIND_TYPE_TAG records, respectively, for them. Some care is required when -gprune-btf is in effect to avoid emitting decl or type tags for decla

Re: [PATCH 5/5] doc: document btf_type_tag and btf_decl_tag attributes

2024-11-13 Thread Indu Bhagat
On 10/30/24 11:31 AM, David Faust wrote: gcc/ * doc/extend.texi (Common Variable Attributes): Document new btf_decl_tag attribute. (Common Type Attributes): Document new btf_type_tag attribute. --- gcc/doc/extend.texi | 68 +

[RFC 4/9] opts: doc: aarch64: add new memtag sanitizer

2024-11-07 Thread Indu Bhagat
Add new command line option -fsanitize=memtag with the following new params: --param memtag-instrument-stack [0,1] (default 1) to use MTE insns for enabling dynamic checking of stack variables. --param memtag-instrument-alloca [0,1] (default 1) to use MTE insns for enabling dynamic checking of st

[RFC 0/9] Add -fsanitize=memtag

2024-11-07 Thread Indu Bhagat
nables.html [4] "DWARF for the Arm® 64-bit Architecture (AArch64)" https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst [5] "MTE – discussion on Exception unwinding ABI" https://discourse.llvm.org/t/mte-discussion-on-exception-unwinding-abi/55226RFC Thanks, I

[RFC 5/9] targhooks: add new target hook TARGET_MEMTAG_TAG_MEMORY

2024-11-07 Thread Indu Bhagat
Add a new target hook TARGET_MEMTAG_TAG_MEMORY to tag (and untag) memory. The default implementation is empty. Hardware-assisted sanitizers on architectures providing instructions to tag/untag memory can then make use of this target hook. On AArch64, e.g., the MEMTAG sanitizer will use this hook

[RFC 1/9] opts: use unsigned HOST_WIDE_INT for sanitizer flags

2024-11-07 Thread Indu Bhagat
Currently, the data type of sanitizer flags is unsigned int, with SANITIZE_SHADOW_CALL_STACK (1UL << 31) being highest individual enumerator for enum sanitize_code. Use 'unsigned HOST_WIDE_INT' data type to allow for more distinct instrumentation modes be added when needed. FIXME: 1. Is using d_u

[RFC 8/9] asan: memtag: enable pass_asan for memtag sanitizer

2024-11-07 Thread Indu Bhagat
Check for SANITIZER_MEMTAG in the gate function for pass_asan gimple pass; enable it. TBD: - This commit was initially carved out in order to ensure each patch works in isolation. Need to revisit and double check this. gcc/ChangeLog: * asan.cc (memtag_sanitize_p): Fix definition.

[RFC 9/9] memtag: testsuite: add new tests

2024-11-07 Thread Indu Bhagat
Add basic tests for MEMTAG sanitizer. MEMTAG sanitizer uses target hooks to emit AArch64 specific MTE instructions. Add new target-specific tests. The currently generated code has quite a few limitations: 1. For basic-1.c testcase, currently we generate: subgx0, x0, #16, #0

[RFC 6/9] aarch64: memtag: implement target hooks

2024-11-07 Thread Indu Bhagat
MEMTAG sanitizer, which is based on the HWASAN sanitizer, will invoke the target-specific hooks to create a random tag, add tag to memory address, and finally tag and untag memory. Implement the target hooks to emit MTE instructions if MEMTAG sanitizer is in effect. Continue to use the default ta

[RFC 3/9] aarch64: add new insn definition for st2g

2024-11-07 Thread Indu Bhagat
Store Allocation Tags (st2g) is an Armv8.5-A memory tagging (MTE) instruction. It stores an allocation tag to two tag granules of memory. TBD: - Not too sure what is the best way to generate the st2g yet; A subsequent patch will emit them in one of the target hooks. - the current define_in

[RFC 2/9] aarch64: add new define_insn for subg

2024-11-07 Thread Indu Bhagat
subg (Subtract with Tag) is an Armv8.5-A memory tagging (MTE) instruction. It can be used to subtract an immediate value scaled by the tag granule from the address in the source register. gcc/ChangeLog: * config/aarch64/aarch64.md (subg): New definition. --- gcc/config/aarch64/aarch64.m

[RFC 7/9] hwasan: add support for generating MTE instructions for memory tagging

2024-11-07 Thread Indu Bhagat
Memory tagging is used for detecting memory safety bugs. On AArch64, the memory tagging extension (MTE) helps in reducing the overheads of memory tagging: - CPU: MTE instructions for efficiently tagging and untagging memory. - Memory: New memory type, Normal Tagged Memory, added to the Arm Ar

Re: [PATCH v4 4/6] btf: add -gprune-btf option

2024-06-24 Thread Indu Bhagat
On 6/24/24 09:11, David Faust wrote: Ping. Richard: I changed the option name as you asked but forgot to CC you on the updated patch. Is the new option OK? Indu: You had some minor comments on the prior version which I have addressed, not sure whether you meant the rest of the patch was OK or

Re: [PATCH v3 6/6] opts: allow any combination of DWARF, CTF, BTF

2024-06-05 Thread Indu Bhagat
On 5/30/24 14:32, David Faust wrote: Previously it was not supported to generate both CTF and BTF debug info in the same compiler run, as both formats made incompatible changes to the same internal data structures. With the structural change in the prior patches, in particular the guarantee that

Re: [PATCH v3 5/6] bpf,btf: enable BTF pruning by default for BPF

2024-06-05 Thread Indu Bhagat
On 5/30/24 14:32, David Faust wrote: This patch enables -fprune-btf by default in the BPF backend when generating BTF information, and fixes BPF CO-RE generation when using -fprune-btf. When generating BPF CO-RE information, we must ensure that types used in CO-RE relocations always have suffici

Re: [PATCH v3 4/6] btf: add -fprune-btf option

2024-06-05 Thread Indu Bhagat
On 5/30/24 14:32, David Faust wrote: This patch adds a new option, -fprune-btf, to control BTF debug info generation. As the name implies, this option enables a kind of "pruning" of the BTF information before it is emitted. When enabled, rather than emitting all type information translated from

Re: [PATCH v3 3/6] btf: refactor and simplify implementation

2024-06-05 Thread Indu Bhagat
On 5/30/24 14:32, David Faust wrote: This patch heavily refactors btfout.cc to take advantage of the structural changes in the prior commits. Now that inter-type references are internally stored as simply pointers, all the painful, brittle, confusing infrastructure that was used in the process o

Re: [PATCH v3 2/6] ctf: use pointers instead of IDs internally

2024-06-05 Thread Indu Bhagat
On 5/30/24 14:32, David Faust wrote: This patch replaces all inter-type references in the ctfc internal data structures with pointers, rather than the references-by-ID which were used previously. A couple of small updates in the BPF backend are included to make it compatible with the change. Th

Re: [PATCH v3 1/6] ctf, btf: restructure CTF/BTF emission

2024-06-05 Thread Indu Bhagat
On 5/30/24 14:32, David Faust wrote: This commit makes some structural changes to the CTF/BTF debug info emission. In particular: a) CTF is new always fully generated and emitted before any BTF-related procedures are run. This means that BTF-related functions can change, even irrev

Re: [PATCH v2 6/6] bpf,btf: enable BTF pruning by default for BPF

2024-05-03 Thread Indu Bhagat
On 5/2/24 10:11, David Faust wrote: This patch enables -fprune-btf by default in the BPF backend when generating BTF information, and fixes BPF CO-RE generation when using -fprune-btf. When generating BPF CO-RE information, we must ensure that types used in CO-RE relocations always have sufficie

Re: [PATCH v2 5/6] btf: add -fprune-btf option

2024-05-03 Thread Indu Bhagat
On 5/2/24 10:11, David Faust wrote: This patch adds a new option, -fprune-btf, to control BTF debug info generation. As the name implies, this option enables a kind of "pruning" of the BTF information before it is emitted. When enabled, rather than emitting all type information translated from

Re: [PATCH v2 4/6] btf: refactor and simplify implementation

2024-05-03 Thread Indu Bhagat
On 5/2/24 10:11, David Faust wrote: This patch heavily refactors btfout.cc to take advantage of the structural changes in the prior commits. Now that inter-type references are internally stored as simply pointers, all the painful, brittle, confusing infrastructure that was used in the process of

Re: [PATCH v2 3/6] ctf: use pointers instead of IDs internally

2024-05-03 Thread Indu Bhagat
On 5/2/24 10:11, David Faust wrote: This patch replaces all inter-type references in the ctfc internal data structures with pointers, rather than the references-by-ID which were used previously. A couple of small updates in the BPF backend are included to make it compatible with the change. Thi

Re: [PATCH v2 1/6] ctf, btf: restructure CTF/BTF emission

2024-05-03 Thread Indu Bhagat
On 5/2/24 10:11, David Faust wrote: This commit makes some structural changes to the CTF/BTF debug info emission. In particular: a) CTF is new always fully generated and emitted before any BTF-related procedures are run. This means that BTF-related functions can change, even irreve

Re: [PATCH] btf: fix a possibly misleading asm debug comment

2024-04-11 Thread Indu Bhagat
On 4/11/24 14:02, David Faust wrote: This patch fixes a small error that could occur in the debug comment when emitting a type reference with btf_asm_type_ref. While working on a previous patch, I noticed the following in the asm output for the test btf-bitfields-4.c: ... .long

Re: [PATCH v2] btf: emit non-representable bitfield as void

2024-04-11 Thread Indu Bhagat
On 4/11/24 14:01, David Faust wrote: [Changes from v1: use btf_dmd_representable_bitfield_p in btf_asm_sou_member, instead of a slightly incorrect equivalent check.] This patch fixes an issue with mangled BTF that could occur when a struct type contains a bitfield member which cannot be repres

Re: [PATCH] btf: emit non-representable bitfield as void

2024-04-11 Thread Indu Bhagat
On 4/11/24 11:53, David Faust wrote: This patch fixes an issue with mangled BTF that could occur when a struct type contains a bitfield member which cannot be represented in BTF. It is undefined what should happen in such cases, but we can at least do something reasonable. Commit 936dd627cd

[PATCH 1/2] ctf: fix PR debug/112878

2024-04-10 Thread Indu Bhagat
PR debug/112878: ICE: in ctf_add_slice, at ctfc.cc:499 with _BitInt > 255 in a struct and -gctf1 The CTF generation in GCC does not have a mechanism to roll-back an already added type. In this testcase presented in the PR, we hit a representation limit in CTF slices (for a member of a struct) an

[PATCH 0/2] Fix PR debug/112878 and a BTF issue

2024-04-10 Thread Indu Bhagat
Hi, The patch series includes two patches: first one is a fix for PR debug/112878 and the second one is for an existing BTF generation issue. Testing Notes: - Regression tested on x86_64-linux-gnu - Tested btf.exp, ctf.exp, bpf.exp for --target=bpf-unknown-none Thanks, Indu Bhagat (2): ctf

[PATCH 2/2] btf: do not skip members of data type with type id BTF_VOID_TYPEID

2024-04-10 Thread Indu Bhagat
Testing the previous fix in gen_ctf_sou_type () reveals an issue in BTF generation, however: BTF emission was currently decrementing the vlen (indicating the number of members) to skip members of type CTF_K_UNKNOWN altogether, but still emitting the BTF for the corresponding member (in output_asm_b

Re: [PATCH] btf: improve btf-datasec-3.c test [PR 114642]

2024-04-09 Thread Indu Bhagat
On 4/8/24 2:01 PM, David Faust wrote: This test failed on powerpc --target_board=unix'{-m32}' because two variables were not placed in sections where the test silently (and incorrectly) assumed they would be. The important thing for the test is only that BTF_KIND_DATASEC entries are NOT generate

Re: [PATCH] btf: emit symbol refs in DATASEC entries only for BPF [PR114608]

2024-04-08 Thread Indu Bhagat
On 4/8/24 12:26, David Faust wrote: The behavior introduced in fa60ac54964 btf: Emit labels in DATASEC bts_offset entries. is only fully correct when compiling for the BPF target with BPF CO-RE enabled. In other cases, depending on optimizations, it can result in an incorrect symbol referenc

[PATCH, V3] ctf: fix incorrect CTF for multi-dimensional array types

2024-03-05 Thread Indu Bhagat
dimensions. The CTF processing was so far working through them in the opposite (incorrect) order. While fixing the issue, refactor the code a bit for readability. co-authored-By: Indu Bhagat gcc/ PR debug/114186 * dwarf2ctf.cc (gen_ctf_array_type): Invoke the ctf_add_array

[PATCH,V2] ctf: fix incorrect CTF for multi-dimensional array types

2024-03-04 Thread Indu Bhagat
opposite (incorrect) order. While fixing the issue, refactor the code a bit for readability. co-authored-By: Indu Bhagat gcc/ PR debug/114186 * dwarf2ctf.cc (gen_ctf_array_type): Invoke the ctf_add_array () in the correct order of the dimensions

Re: [PATCH] testsuite: ctf: make array in ctf-file-scope-1 fixed length

2024-03-01 Thread Indu Bhagat
On 3/1/24 11:01, David Faust wrote: The array member of struct SFOO in the ctf-file-scope-1 caused the test to fail for the BPF target, since BPF does not support dynamic stack allocation. The array does not need to variable length for the sake of the test, so make it fixed length instead to allo

Re: [PATCH] btf: change encoding of forward-declared enums [PR111735]

2023-12-19 Thread Indu Bhagat
On 12/12/23 14:35, David Faust wrote: The BTF specification does not formally define a representation for forward-declared enum types such as: enum Foo; Forward-declarations for struct and union types are represented by BTF_KIND_FWD, which has a 1-bit flag distinguishing the two. The de-fac

Re: [[PATCH][GCC13] 0/2] Fix combined tree build of GCC 13 with Binutils 2.41

2023-12-05 Thread Indu Bhagat
On 12/5/23 13:45, Jakub Jelinek wrote: On Tue, Dec 05, 2023 at 01:36:30PM -0800, Indu Bhagat wrote: To resolve the issue of combined Binutils (2.41) + GCC (13) failing to install (https://sourceware.org/bugzilla/show_bug.cgi?id=31108), we will need some backports. This specific issue is with

[[PATCH][GCC13] 2/2] toplevel: Makefile.def: add install-strip dependency on libsframe

2023-12-05 Thread Indu Bhagat
As noted in PR libsframe/30014 - FTBFS: install-strip fails because bfdlib relinks and fails to find libsframe, the install time dependencies of libbfd need to be updated. ChangeLog: * Makefile.def: Reflect that libsframe needs to installed before libbfd. Reorder a bit to better

[[PATCH][GCC13] 1/2] bfd: linker: merge .sframe sections

2023-12-05 Thread Indu Bhagat
The linker merges all the input .sframe sections. When merging, the linker verifies that all the input .sframe sections have the same abi/arch. The linker uses libsframe library to perform key actions on the .sframe sections - decode, read, and create output data. This implies buildsystem change

[[PATCH][GCC13] 0/2] Fix combined tree build of GCC 13 with Binutils 2.41

2023-12-05 Thread Indu Bhagat
-* dependencies in the top-level makefiles. I think it makes sense to bring both of the following two commits (from the trunk) to the GCC13 branch: commit eff0e7a4ae31d1e4e64ae37bbc10d073d8579255 Author: Indu Bhagat Date: Wed Jan 18 23:17:49 2023 -0800 toplevel: Makefile.def

Re: [PATCH] btf: avoid wrong DATASEC entries for extern vars [PR112849]

2023-12-05 Thread Indu Bhagat
On 12/4/23 15:47, David Faust wrote: The process of creating BTF_KIND_DATASEC records involves iterating through variable declarations, determining which section they will be placed in, and creating an entry in the appropriate DATASEC record accordingly. For variables without e.g. an explicit __

[PATCH] btf: fix PR debug/112656

2023-11-30 Thread Indu Bhagat
PR debug/112656 - btf: function prototypes generated with name With this patch, all BTF_KIND_FUNC_PROTO will appear anonymous in the generated BTF section. As noted in the discussion in the bugzilla, the number of BTF_KIND_FUNC_PROTO types output varies across targets (BPF with -mco-re vs non-BPF

[PATCH] btf: fix PR debug/112768

2023-11-30 Thread Indu Bhagat
PR debug/112768 - btf: fix asm comment output for BTF_KIND_FUNC* kinds The patch adds a small function to abstract out the detail and return the name of the type. The patch also fixes the issue of BTF_KIND_FUNC appearing in the comments with a 'null' string. For btf-function-6.c testcase, after

Re: [PATCH 2/2] btf: improve -dA comments for testsuite

2023-05-30 Thread Indu Bhagat via Gcc-patches
On 5/30/23 11:27, David Faust wrote: [Changes from v1: - Fix typos. - Split unrelated change into separate commit. - Improve asm comment for enum constants, update btf-enum-1 test. - Improve asm comment for DATASEC records, update btf-datasec-2 test.] Many BTF type kinds refer to other t

Re: [PATCH 1/2] btf: be clear when record size/type is not used

2023-05-30 Thread Indu Bhagat via Gcc-patches
On 5/30/23 11:27, David Faust wrote: [Changes from v1: split this change into own commit.] All BTF type records have a 4-byte field used to encode a size or link to another type, depending on the type kind. But BTF_KIND_ARRAY and BTF_KIND_FWD do not use this field at all, and should write zero.

Re: [PATCH] btf: improve -dA comments for testsuite

2023-05-30 Thread Indu Bhagat via Gcc-patches
On 5/30/23 09:08, David Faust wrote: @@ -793,7 +917,8 @@ btf_asm_enum_const (unsigned int size, ctf_dmdef_t * dmd) /* Asm'out a function parameter description following a BTF_KIND_FUNC_PROTO. */ static void -btf_asm_func_arg (ctf_func_arg_t * farg, size_t stroffset) +btf_asm_func_arg

Re: [PATCH] btf: improve -dA comments for testsuite

2023-05-30 Thread Indu Bhagat via Gcc-patches
On 5/25/23 9:37 AM, David Faust via Gcc-patches wrote: Many BTF type kinds refer to other types via index to the final types list. However, the order of the final types list is not guaranteed to remain the same for the same source program between different runs of the compiler, making it difficul

[Committed] MAINTAINERS: Add myself as CTF and BTF reviewer

2023-04-06 Thread Indu Bhagat via Gcc-patches
/MAINTAINERS @@ -271,6 +271,7 @@ check in changes outside of the parts of the compiler they maintain. arc port Claudiu Zissulescu callgraph Martin Jambor C front endMarek Polacek +CTF, BTF Indu Bhagat CTF

Re: [PATCH v2 0/3] btf: fix BTF for extern items [PR106773]

2022-12-13 Thread Indu Bhagat via Gcc-patches
On 12/13/22 10:44, David Faust wrote: [Changes from v1: - Remove #defines for LINKAGE_* values, instead mirror enums from linux/btf.h to include/btf.h and use those. - Fix BTF generation for extern variable with both non-defining and defining decls in the same CU. Add a test for this.

Re: [PATCH 1/3] btf: add 'extern' linkage for variables [PR106773]

2022-12-12 Thread Indu Bhagat via Gcc-patches
On 12/12/22 12:47, David Faust wrote: On 12/8/22 22:55, Indu Bhagat wrote: Hi David, On 12/7/22 12:57, David Faust wrote: Add support for the 'extern' linkage value for BTF_KIND_VAR records, which is used for variables declared as extern in the source file. PR target/1

Re: [PATCH 3/3] btf: correct generation for extern funcs [PR106773]

2022-12-12 Thread Indu Bhagat via Gcc-patches
On 12/12/22 12:31, David Faust wrote: On 12/8/22 23:36, Indu Bhagat wrote: On 12/7/22 12:57, David Faust wrote: The eBPF loader expects to find entries for functions declared as extern in the corresponding BTF_KIND_DATASEC record, but we were not generating these entries. This patch adds

Re: [PATCH 2/3] btf: fix 'extern const void' variables [PR106773]

2022-12-12 Thread Indu Bhagat via Gcc-patches
On 12/12/22 12:59, David Faust wrote: On 12/8/22 23:34, Indu Bhagat wrote: Looks OK to me overall. Minor comments below. Thanks On 12/7/22 12:57, David Faust wrote: The eBPF loader expects to find BTF_KIND_VAR records for references to extern const void symbols. We were mistakenly

Re: [PATCH 3/3] btf: correct generation for extern funcs [PR106773]

2022-12-08 Thread Indu Bhagat via Gcc-patches
On 12/7/22 12:57, David Faust wrote: The eBPF loader expects to find entries for functions declared as extern in the corresponding BTF_KIND_DATASEC record, but we were not generating these entries. This patch adds support for the 'extern' linkage of function types in BTF, and creates entries for

Re: [PATCH 2/3] btf: fix 'extern const void' variables [PR106773]

2022-12-08 Thread Indu Bhagat via Gcc-patches
Looks OK to me overall. Minor comments below. Thanks On 12/7/22 12:57, David Faust wrote: The eBPF loader expects to find BTF_KIND_VAR records for references to extern const void symbols. We were mistakenly identifing these as unsupported types, and as a result skipping emitting VAR records for

Re: [PATCH 1/3] btf: add 'extern' linkage for variables [PR106773]

2022-12-08 Thread Indu Bhagat via Gcc-patches
Hi David, On 12/7/22 12:57, David Faust wrote: Add support for the 'extern' linkage value for BTF_KIND_VAR records, which is used for variables declared as extern in the source file. PR target/106773 gcc/ * btfout.cc (BTF_LINKAGE_STATIC): New define. (BTF_LINKAGE_GLOBA

Re: [PATCH v4] btf: Add support to BTF_KIND_ENUM64 type

2022-10-31 Thread Indu Bhagat via Gcc-patches
On 10/21/22 2:28 AM, Indu Bhagat via Gcc-patches wrote: On 10/19/22 19:05, Guillermo E. Martinez wrote: Hello, The following is patch v4 to update BTF/CTF backend supporting BTF_KIND_ENUM64 type. Changes from v3:    + Remove `ctf_enum_binfo' structure.    + Remove -m{little,big}-endian

Re: [PATCH v4] btf: Add support to BTF_KIND_ENUM64 type

2022-10-21 Thread Indu Bhagat via Gcc-patches
On 10/19/22 19:05, Guillermo E. Martinez wrote: Hello, The following is patch v4 to update BTF/CTF backend supporting BTF_KIND_ENUM64 type. Changes from v3: + Remove `ctf_enum_binfo' structure. + Remove -m{little,big}-endian from dg-options in testcase. Comments will be welcomed and appr

Re: [PATCH v3] btf: Add support to BTF_KIND_ENUM64 type

2022-10-18 Thread Indu Bhagat via Gcc-patches
Hi Guillermo, On 10/14/22 8:55 PM, Guillermo E. Martinez wrote: Hello, The following is patch v3 to update BTF/CTF backend supporting BTF_KIND_ENUM64 type. Changes from v2: + Add a new `dtd_enum_unsigned' field in `ctf_dtdef' to indicate signedness of the enum type. + Fix endianness

Re: [PATCH v2] btf: Add support to BTF_KIND_ENUM64 type

2022-10-11 Thread Indu Bhagat via Gcc-patches
Hi Guillermo, On 10/3/22 7:39 AM, Guillermo E. Martinez via Gcc-patches wrote: diff --git a/gcc/ctfc.cc b/gcc/ctfc.cc index 9773358a475..253c36b6a0a 100644 --- a/gcc/ctfc.cc +++ b/gcc/ctfc.cc @@ -604,6 +604,7 @@ ctf_add_enum (ctf_container_ref ctfc, uint32_t flag, const char * name,     gcc_as

Re: [PATCH v2] btf: Add support to BTF_KIND_ENUM64 type

2022-09-29 Thread Indu Bhagat via Gcc-patches
On 9/28/22 2:15 PM, Guillermo E. Martinez via Gcc-patches wrote: Hello GCC team, The following is patch v2 to update BTF/CTF backend supporting BTF_KIND_ENUM64 type. Changes from v1: + Fix typo in commit message. + Fix changelog entries. Comments will be welcomed and appreciated!, Kind

Re: [PATCH] btf: do not skip emitting void variables [PR106773]

2022-09-04 Thread Indu Bhagat via Gcc-patches
On 9/1/22 12:53, David Faust wrote: The eBPF loader expects to find BTF_KIND_VAR records for references to extern const void symbols. We were mistakenly identifing these as unsupported types, and as a result skipping emitting VAR records for them. Tested on bpf-unknown-none and x86_64, no known

Re: [PATCH] btf: do not use the CHAR `encoding' bit for BTF

2022-07-26 Thread Indu Bhagat via Gcc-patches
On 7/22/22 4:23 AM, Jose E. Marchesi via Gcc-patches wrote: 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)

Re: [PATCH V2] btf: emit linkage information in BTF_KIND_FUNC entries

2022-07-12 Thread Indu Bhagat via Gcc-patches
On 7/12/22 8:13 AM, Jose E. Marchesi via Gcc-patches wrote: The kernel bpftool expects BTF_KIND_FUNC entries in BTF to include an annotation reflecting the linkage of functions (static, global). For whatever reason they abuse the `vlen' field of the BTF_KIND_FUNC entry instead of adding a varia

Re: [PATCH] btf: emit linkage information in BTF_KIND_FUNC entries

2022-07-11 Thread Indu Bhagat via Gcc-patches
On 7/8/22 11:30 AM, Jose E. Marchesi via Gcc-patches wrote: The kernel bpftool expects BTF_KIND_FUNC entries in BTF to include an annotation reflecting the linkage of functions (static, global). For whatever reason they (ab)use the `vlen' field of the BTF_KIND_FUNC entry instead of adding a va

Re: [PATCH 0/3] Fix PR debug/105089

2022-04-07 Thread Indu Bhagat via Gcc-patches
ping On 3/30/22 4:31 PM, Indu Bhagat wrote: Hello, This patch set fixes PR debug/105089. [PS: The first patch in the series "ctfc: get rid of the static variable in ctf_list_add_ctf_vars" is unrelated to the PR and is combined here only for ease of review.] As noted in the PR de

[PATCH 2/3] CTF for extern variable fix [PR105089]

2022-03-30 Thread Indu Bhagat via Gcc-patches
usual, if deemed unused. 2022-03-30 Indu Bhagat gcc/ChangeLog: PR debug/105089 * ctfc.cc (ctf_dvd_ignore_insert): New function. (ctf_dvd_ignore_lookup): Likewise. (ctf_add_variable): Keep track of non-defining decl DIEs. (new_ctf_container): Initialize

[PATCH 3/3] Refactor and update CTF testcases [PR105089]

2022-03-30 Thread Indu Bhagat via Gcc-patches
-3.c now has added checks that only one CTF variable record is expected. 2022-03-30 Indu Bhagat gcc/testsuite/ChangeLog: PR debug/105089 * gcc.dg/debug/ctf/ctf-array-2.c: Refactor testcase. Move some checks ... * gcc.dg/debug/ctf/ctf-array-5.c: ... to here.

[PATCH 1/3] ctfc: get rid of the static variable in ctf_list_add_ctf_vars ()

2022-03-30 Thread Indu Bhagat via Gcc-patches
2022-03-28 Indu Bhagat gcc/ChangeLog: * ctfc.h (struct ctf_container): Introduce a new member. * ctfout.cc (ctf_list_add_ctf_vars): Use it instead of static variable. --- gcc/ctfc.h| 2 ++ gcc/ctfout.cc | 4 +--- 2 files changed, 3 insertions(+), 3 deletions

[PATCH 0/3] Fix PR debug/105089

2022-03-30 Thread Indu Bhagat via Gcc-patches
t the type of the defining declaration. Testing Notes: -- bootstrapped and reg tested on x86_64 and aarch64 -- built binutils package with -gctf (with CTF-capable linker) on x86_64, no CTF errors reported. Thanks, Indu Bhagat (3): ctfc: get rid of the static variable in ctf_list_add_ctf_var

[COMMITTED] ctfout: use ctfc_get_num_ctf_vars instead

2022-03-28 Thread Indu Bhagat via Gcc-patches
[Committed as obvious.] A minor cosmetic fix. 2022-03-28 Indu Bhagat gcc/ChangeLog: * ctfout.cc (ctf_preprocess): Use ctfc_get_num_ctf_vars instead. (output_ctf_vars): Likewise. --- gcc/ctfout.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc

Re: [PATCH] Testsuite: Add btf-dataset option for RISC-V.

2022-01-03 Thread Indu Bhagat via Gcc-patches
On 12/30/21 8:59 AM, Palmer Dabbelt wrote: On Thu, 30 Dec 2021 08:28:34 PST (-0800), gcc-patches@gcc.gnu.org wrote: On 12/29/2021 8:02 PM, jiawei wrote: Add -msmall-data-limit option to put global and static data into right section and generate 'btt_info' on RISC-V target. BTF (BPF Type Form

[COMMITTED] ctfc: remove redundant comma in enumerator list

2021-10-13 Thread Indu Bhagat via Gcc-patches
This also helps get rid of warning ctfc.h:215:18: warning: comma at end of enumerator list [-Wpedantic] CTF_DTU_D_SLICE, gcc/ChangeLog: * ctfc.h (enum ctf_dtu_d_union_enum): Remove redundant comma. --- gcc/ctfc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc

[PATCH] ctfc: Free CTF type and CTF variable objects in ctfc_delete_container ()

2021-10-05 Thread Indu Bhagat via Gcc-patches
Hello, This patch fixes an outstanding issue with memory cleanup in the CTF container. Earlier the two hash tables in the CTF container were not cleaned up in ctfc_delete_container (). With this patch, we first free up the CTF type and CTF variable entries in the hash_table slots, followed by emp

Re: [PATCH] ctf: Do not warn for CTF not supported for GNU GIMPLE

2021-09-29 Thread Indu Bhagat via Gcc-patches
On 9/29/21 12:14 AM, Richard Biener wrote: On Tue, Sep 28, 2021 at 8:52 PM Indu Bhagat via Gcc-patches wrote: CTF is supported for C only. Currently, a warning is emitted if the -gctf command line option is specified for a non-C frontend. This warning is also used by the GCC testsuite

  1   2   3   >