public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mark_wang1234 at 163 dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/112912] New: How to implement a mangle interface in c
Date: Fri, 08 Dec 2023 06:08:02 +0000	[thread overview]
Message-ID: <bug-112912-4@http.gcc.gnu.org/bugzilla/> (raw)

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?

             reply	other threads:[~2023-12-08  6:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  6:08 mark_wang1234 at 163 dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-112912-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).