public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
@ 2023-11-16 10:16 ro at gcc dot gnu.org
  2023-11-16 10:17 ` [Bug sanitizer/112562] " ro at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ro at gcc dot gnu.org @ 2023-11-16 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112562
           Summary: [14 regression] asan_interceptors_memintrinsics.cpp
                    doesn't assemble with Solaris/x86 as
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---
              Host: i386-pc-solaris2.11
            Target: i386-pc-solaris2.11
             Build: i386-pc-solaris2.11

The recent libsanitizer import broke bootstrap with the Solaris/x86 as:

Assembler: asan_interceptors_memintrinsics.cpp
        "/var/tmp//ccY0YNed.s", line 9 : Illegal register: "%function"
        "/var/tmp//ccY0YNed.s", line 9 : Syntax error
        Near line: ".type  __interceptor_trampoline_memset, %function"
        "/var/tmp//ccY0YNed.s", line 20 : Illegal register: "%function"
        "/var/tmp//ccY0YNed.s", line 20 : Syntax error
        Near line: ".type  __interceptor_trampoline_memmove, %function"
        "/var/tmp//ccY0YNed.s", line 31 : Illegal register: "%function"
        "/var/tmp//ccY0YNed.s", line 31 : Syntax error
        Near line: ".type  __interceptor_trampoline_memcpy, %function"

Unlike gas, as doesn't understand %function.  gcc (and clang) always emit
@function instead.

This is from libsanitizer/interception/interception.h (DECLARE_WRAPPER) and
libsanitizer/sanitizer_common/sanitizer_asm.h (ASM_TYPE_FUNCTION) which
apparently should be kept in sync.

When I look at gcc/config, the only targets that don't use the elfos.h default
of '@' for TYPE_OPERAND_FMT are aarch64-elf, arm-elf, and sparc-svr4.

I wonder how best to handle this: given that clang doesn't care about the
native assemblers, it might be necessary to keep a patch gcc-local.

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
@ 2023-11-16 10:17 ` ro at gcc dot gnu.org
  2023-11-16 10:25 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ro at gcc dot gnu.org @ 2023-11-16 10:17 UTC (permalink / raw)
  To: gcc-bugs

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

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
  2023-11-16 10:17 ` [Bug sanitizer/112562] " ro at gcc dot gnu.org
@ 2023-11-16 10:25 ` jakub at gcc dot gnu.org
  2023-11-16 10:38 ` ro at CeBiTec dot Uni-Bielefeld.DE
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-11-16 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
find -type f | xargs grep %function
./interception/interception.h:       ".type  "
SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", %function\n"         \
./builtins/assembly.h:#define SYMBOL_IS_FUNC(name) .type name,%function
./sanitizer_common/sanitizer_asm.h:# define ASM_TYPE_FUNCTION(symbol) .type
symbol, %function
./hwasan/hwasan_tag_mismatch_aarch64.S:.type __hwasan_tag_mismatch, %function
./hwasan/hwasan_tag_mismatch_aarch64.S:.type __hwasan_tag_mismatch_v2,
%function

I'm open to a local patch.
Shall we use @ except on aarch64/arm (sparc-svr4 not being supported in
libsanitizer I think), something else?
Though, builtins/assembly.h already has SYMBOL_IS_FUNC macro which ought to
DTRT, except that it is for *.S files and not for inline asm where things
should be stringified.

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
  2023-11-16 10:17 ` [Bug sanitizer/112562] " ro at gcc dot gnu.org
  2023-11-16 10:25 ` jakub at gcc dot gnu.org
@ 2023-11-16 10:38 ` ro at CeBiTec dot Uni-Bielefeld.DE
  2023-11-16 12:48 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ro at CeBiTec dot Uni-Bielefeld.DE @ 2023-11-16 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> ---
> --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> find -type f | xargs grep %function
> ./interception/interception.h:       ".type  "
> SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", %function\n"         \
> ./builtins/assembly.h:#define SYMBOL_IS_FUNC(name) .type name,%function
> ./sanitizer_common/sanitizer_asm.h:# define ASM_TYPE_FUNCTION(symbol) .type
> symbol, %function
> ./hwasan/hwasan_tag_mismatch_aarch64.S:.type __hwasan_tag_mismatch, %function
> ./hwasan/hwasan_tag_mismatch_aarch64.S:.type __hwasan_tag_mismatch_v2,
> %function

I think we can ignore all of builtins/assembly.h and hwasan: neither is
supported on Solaris/x86 or sparc.

> I'm open to a local patch.
> Shall we use @ except on aarch64/arm (sparc-svr4 not being supported in
> libsanitizer I think), something else?

I guess that's the easiest way out: we'd probably have to duplicate the
condition in interception/interception.h and
sanitizer_common/sanitizer_asm.h, unless we can find a way to share the
@function/%function definition between both.

gcc/config/sparc/svr4.h is used by sparc-linux, which is supported by
libsanitizer (both upstream and gcc).

> Though, builtins/assembly.h already has SYMBOL_IS_FUNC macro which ought to
> DTRT, except that it is for *.S files and not for inline asm where things
> should be stringified.

It's only included in
sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S and
several hwasan files, so I guess it can stay as is.

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-11-16 10:38 ` ro at CeBiTec dot Uni-Bielefeld.DE
@ 2023-11-16 12:48 ` rguenth at gcc dot gnu.org
  2023-11-20 18:18 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-11-16 12:48 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |build
           Priority|P3                          |P1

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-11-16 12:48 ` rguenth at gcc dot gnu.org
@ 2023-11-20 18:18 ` jakub at gcc dot gnu.org
  2023-11-21  9:02 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-11-20 18:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So does this fix it?

2023-11-20  Jakub Jelinek  <jakub@redhat.com>

        PR sanitizer/112562
        * sanitizer_common/sanitizer_asm.h (ASM_TYPE_FUNCTION): Use @function
        rather than %function except on arm/aarch64.
        * interception/interception.h (ASM_TYPE_FUNCTION_STR): Define.
        (DECLARE_WRAPPER): Use it instead of hardcoding %function.

--- libsanitizer/sanitizer_common/sanitizer_asm.h.jj    2023-11-15
17:19:11.507783822 +0100
+++ libsanitizer/sanitizer_common/sanitizer_asm.h       2023-11-20
18:16:48.740201609 +0100
@@ -62,7 +62,11 @@

 #if !defined(__APPLE__)
 # define ASM_HIDDEN(symbol) .hidden symbol
-# define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
+# if defined(__arm__) || defined(__aarch64__)
+#  define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
+# else
+#  define ASM_TYPE_FUNCTION(symbol) .type symbol, @function
+# endif
 # define ASM_SIZE(symbol) .size symbol, .-symbol
 # define ASM_SYMBOL(symbol) symbol
 # define ASM_SYMBOL_INTERCEPTOR(symbol) symbol
--- libsanitizer/interception/interception.h.jj 2023-11-15 17:19:11.505783850
+0100
+++ libsanitizer/interception/interception.h    2023-11-20 18:16:48.736201664
+0100
@@ -185,6 +185,11 @@ const interpose_substitution substitutio
 #  else
 #   define __ASM_WEAK_WRAPPER(func) ".weak " #func "\n"
 #  endif  // SANITIZER_FREEBSD || SANITIZER_NETBSD
+#  if defined(__arm__) || defined(__aarch64__)
+#   define ASM_TYPE_FUNCTION_STR "%function"
+#  else
+#   define ASM_TYPE_FUNCTION_STR "@function"
+#  endif
 // Keep trampoline implementation in sync with
sanitizer_common/sanitizer_asm.h
 #  define DECLARE_WRAPPER(ret_type, func, ...)                                
\
      extern "C" ret_type func(__VA_ARGS__);                                   
\
@@ -196,7 +201,8 @@ const interpose_substitution substitutio
        __ASM_WEAK_WRAPPER(func)                                               
\
        ".set " #func ", " SANITIZER_STRINGIFY(TRAMPOLINE(func)) "\n"          
\
        ".globl " SANITIZER_STRINGIFY(TRAMPOLINE(func)) "\n"                   
\
-       ".type  " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", %function\n"        
\
+       ".type  " SANITIZER_STRINGIFY(TRAMPOLINE(func)) ", "                   
\
+         ASM_TYPE_FUNCTION_STR "\n"                                           
\
        SANITIZER_STRINGIFY(TRAMPOLINE(func)) ":\n"                            
\
        SANITIZER_STRINGIFY(CFI_STARTPROC) "\n"                                
\
        SANITIZER_STRINGIFY(ASM_TAIL_CALL) " __interceptor_"                   
\

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-11-20 18:18 ` jakub at gcc dot gnu.org
@ 2023-11-21  9:02 ` jakub at gcc dot gnu.org
  2023-11-21 20:03 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-11-21  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
https://github.com/llvm/llvm-project/issues/72970

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-11-21  9:02 ` jakub at gcc dot gnu.org
@ 2023-11-21 20:03 ` cvs-commit at gcc dot gnu.org
  2023-11-24 16:06 ` jakub at gcc dot gnu.org
  2023-11-27 10:30 ` ro at CeBiTec dot Uni-Bielefeld.DE
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-21 20:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:c7c1ee1cfdea228f79ba9d495b407f3689efc608

commit r14-5693-gc7c1ee1cfdea228f79ba9d495b407f3689efc608
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Nov 21 21:01:48 2023 +0100

    sanitizer: Fix build on SPARC/Solaris with Solaris as [PR112562]

    Solaris as apparently doesn't accept %function and requires @function
    instead.

    This cherry-picks upstream commit.

    2023-11-21  Jakub Jelinek  <jakub@redhat.com>

            PR sanitizer/112562
            * sanitizer_common/sanitizer_asm.h: Cherry-pick llvm-project
revision
            a855a16a02e76a0f4192c038bb64f3773947a2f7.
            * interception/interception.h: Likewise.

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-11-21 20:03 ` cvs-commit at gcc dot gnu.org
@ 2023-11-24 16:06 ` jakub at gcc dot gnu.org
  2023-11-27 10:30 ` ro at CeBiTec dot Uni-Bielefeld.DE
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-11-24 16:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Should be fixed now I believe.

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

* [Bug sanitizer/112562] [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as
  2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2023-11-24 16:06 ` jakub at gcc dot gnu.org
@ 2023-11-27 10:30 ` ro at CeBiTec dot Uni-Bielefeld.DE
  8 siblings, 0 replies; 10+ messages in thread
From: ro at CeBiTec dot Uni-Bielefeld.DE @ 2023-11-27 10:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> ---
> Should be fixed now I believe.

It is indeed: thanks for the quick fix.

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

end of thread, other threads:[~2023-11-27 10:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-16 10:16 [Bug sanitizer/112562] New: [14 regression] asan_interceptors_memintrinsics.cpp doesn't assemble with Solaris/x86 as ro at gcc dot gnu.org
2023-11-16 10:17 ` [Bug sanitizer/112562] " ro at gcc dot gnu.org
2023-11-16 10:25 ` jakub at gcc dot gnu.org
2023-11-16 10:38 ` ro at CeBiTec dot Uni-Bielefeld.DE
2023-11-16 12:48 ` rguenth at gcc dot gnu.org
2023-11-20 18:18 ` jakub at gcc dot gnu.org
2023-11-21  9:02 ` jakub at gcc dot gnu.org
2023-11-21 20:03 ` cvs-commit at gcc dot gnu.org
2023-11-24 16:06 ` jakub at gcc dot gnu.org
2023-11-27 10:30 ` ro at CeBiTec dot Uni-Bielefeld.DE

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