public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112912] New: How to implement a mangle interface in c
@ 2023-12-08  6:08 mark_wang1234 at 163 dot com
  2023-12-08  6:19 ` [Bug c/112912] How to implement a mangle interface in c for generating cfi type id pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mark_wang1234 at 163 dot com @ 2023-12-08  6:08 UTC (permalink / raw)
  To: gcc-bugs

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.1990@gmail.com/raw
https://lore.kernel.org/lkml/20221219055431.22596-3-ashimida.1990@gmail.com/raw
https://lore.kernel.org/lkml/20221219055431.22596-4-ashimida.1990@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?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-08  6:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-08  6:08 [Bug c/112912] New: How to implement a mangle interface in c mark_wang1234 at 163 dot com
2023-12-08  6:19 ` [Bug c/112912] How to implement a mangle interface in c for generating cfi type id pinskia at gcc dot gnu.org
2023-12-08  6:20 ` pinskia at gcc dot gnu.org
2023-12-08  6:27 ` [Bug sanitizer/112912] " mark_wang1234 at 163 dot com
2023-12-08  6:30 ` pinskia at gcc dot gnu.org
2023-12-08  6:33 ` pinskia at gcc dot gnu.org
2023-12-08  6:51 ` mark_wang1234 at 163 dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).