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

* [Bug c/112912] How to implement a mangle interface in c for generating cfi type id
  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 ` pinskia at gcc dot gnu.org
  2023-12-08  6:20 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-08  6:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

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

* [Bug c/112912] How to implement a mangle interface in c for generating cfi type id
  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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-08  6:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I don't get why you need to mangle anything here ....

what exactly is being mangled here? The types? or something else?

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

* [Bug sanitizer/112912] How to implement a mangle interface in c for generating cfi type id
  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 ` mark_wang1234 at 163 dot com
  2023-12-08  6:30 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mark_wang1234 at 163 dot com @ 2023-12-08  6:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Wang <mark_wang1234 at 163 dot com> ---
(In reply to Andrew Pinski from comment #1)
> I don't get why you need to mangle anything here ....
> 
> what exactly is being mangled here? The types? or something else?

Sorry I didn't describe it clearly. I just need mangle the function type

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

* [Bug sanitizer/112912] How to implement a mangle interface in c for generating cfi type id
  2023-12-08  6:08 [Bug c/112912] New: How to implement a mangle interface in c mark_wang1234 at 163 dot com
                   ` (2 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-08  6:30 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
since all typenames in C are in the global scope, there is no mangling in
those.
For base types, you could just do the basic mangling; for target specific
mangling, you can call target.mangle_type first. The base types mangling is
easy and you could share it between the C and C++ front-end if needed by
placing it in c-family/*.cc .
Basically the reduced mangling for C is all that is needed.

Also this is not the correct place to ask these kind of questions, the mailing
list is a better place.

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

* [Bug sanitizer/112912] How to implement a mangle interface in c for generating cfi type id
  2023-12-08  6:08 [Bug c/112912] New: How to implement a mangle interface in c mark_wang1234 at 163 dot com
                   ` (3 preceding siblings ...)
  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
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-08  6:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Again bugzilla is not the right place to ask this kind of question, gcc@ is a
better place.

Refactoring and sharing the mangling code definitely can be done. I suspect the
first step is to move away from using obstack though.

But again bugzilla is not the right place to ask this.

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

* [Bug sanitizer/112912] How to implement a mangle interface in c for generating cfi type id
  2023-12-08  6:08 [Bug c/112912] New: How to implement a mangle interface in c mark_wang1234 at 163 dot com
                   ` (4 preceding siblings ...)
  2023-12-08  6:33 ` pinskia at gcc dot gnu.org
@ 2023-12-08  6:51 ` mark_wang1234 at 163 dot com
  5 siblings, 0 replies; 7+ messages in thread
From: mark_wang1234 at 163 dot com @ 2023-12-08  6:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Wang <mark_wang1234 at 163 dot com> ---
(In reply to Andrew Pinski from comment #4)
> Again bugzilla is not the right place to ask this kind of question, gcc@ is
> a better place.
> 
> Refactoring and sharing the mangling code definitely can be done. I suspect
> the first step is to move away from using obstack though.
> 
> But again bugzilla is not the right place to ask this.

Thanks Andrew

I will go to gcc@ to ask similar questions later, thank you again

^ 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).