Sep 20 – 24, 2021
US/Pacific timezone

Support for the CTF and BTF debug formats in the GNU Toolchain

Sep 20, 2021, 9:45 AM
GNU Tools track/Virtual-Room (LPC Virtual)

GNU Tools track/Virtual-Room

LPC Virtual

GNU Tools Track GNU Tools Track


Indu Bhagat David Faust Wei-min Pan


CTF (Compact C Type Format) is a debugging format whose main (but not only) purpose is to convey type information of C program constructs. BTF is a similar format used in the Linux kernel to support the portable execution of BPF programs. Both formats share a common ancestor and show some remarkable similarities. However they are not the same format, their application goals are different, are developed by different groups, and they use a different binary representation.

We have added support for both formats to the GNU Toolchain. CTF is now fully supported in GCC, linker (with type deduplication), binary utilities (dumping the contents of .ctf sections in human readable format), a GNU poke description for editing encoded CTF, and GDB support. BTF is supported in GCC, mainly to be used by the BPF backend. There is however no support for BTF in Binutils at this point.

In this talk we will show how these new debug formats have been implemented in GCC, highlighting how the implementation relies exclusively on the internal DWARF representation built by the compiler. This effectively makes DWARF the canonical internal representation for debugging info in GCC. This approach has worked well so far and looks very promising.

We will also discuss the support for the CTF debug format in GDB, which includes support for both CTF sections and CTF archives (latter under review.)

I agree to abide by the anti-harassment policy I agree

Primary authors

Indu Bhagat David Faust Wei-min Pan

Presentation materials