https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112912

            Bug ID: 112912
           Summary: How to implement a mangle interface in c
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mark_wang1234 at 163 dot com
  Target Milestone: ---

Clang implements kcfi for low-level system software to support forward-edge
cfi. clang kcfi uses the mangled-name defined in Itanium c++ ABI as input to
generate cfi type id, and uses the xxhash algorithm to generate cfi type id.

Dan Li implemented a forward-edge cfi scheme for gcc, but the algorithm for
generating cfi type id in this scheme is different from clang kcfi. He designed
a general cfi type id algorithm (incompatible with clang kcfi). I am Dan Li’s
colleague, and I will continue to complete this work later.

The following is the patch implemented by Dan Li to support forward-edge cfi in
gcc:
https://lore.kernel.org/lkml/20221219055431.22596-2-ashimida.1...@gmail.com/raw
https://lore.kernel.org/lkml/20221219055431.22596-3-ashimida.1...@gmail.com/raw
https://lore.kernel.org/lkml/20221219055431.22596-4-ashimida.1...@gmail.com/raw

I would like to implement a clang kcfi compatible CFI type id generation method
based on his work:

1. For c++, use the existing mangle_typeinfo_string_for_type interface to
generate the input string of the xxhash algorithm;

2. For c, refer to the implementation of gcc/cp/mangle.cc and implement the
mangle_typeinfo_string_for_type interface in the gcc/c/ directory;

Currently my solution has encountered the following two problems:

1. Can I implement a simple mangle interface in the gcc/c directory for
generating cfi type id? Or should a unified mangle interface be provided for c
and c++? Or do you have any other suggestions?

2. I want to call interfaces defined in different front-end languages under the
interface defined by targetm. How should I implement this?

Reply via email to