public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/31655] New: clang can't build glibc with stack protector
@ 2024-04-18 15:00 hjl.tools at gmail dot com
  2024-04-18 15:08 ` [Bug libc/31655] " adhemerval.zanella at linaro dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2024-04-18 15:00 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=31655

            Bug ID: 31655
           Summary: clang can't build glibc with stack protector
           Product: glibc
           Version: 2.40
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
                CC: adhemerval.zanella at linaro dot org, drepper.fsp at gmail dot com,
                    skpgkp2 at gmail dot com
  Target Milestone: ---
            Target: x86

On x86, glibc built with stack protector using clang crashed very early:

(gdb) bt
#0 0x00000000005b3327 in bsearch (__key=__key@entry=0x7fffffffe540,
__base=0x6bde70 <intel_02_known>, __nmemb=__nmemb@entry=68,
__size=__size@entry=8,
__compar=__compar@entry=0x5b2400 <intel_02_known_compare>) at
../bits/stdlib-bsearch.h:22
#1 0x00000000005b220a in intel_check_word (name=name@entry=188, value=16711424,
has_level_2=has_level_2@entry=0x7fffffffe587,
no_level_2_or_3=no_level_2_or_3@entry=0x7fffffffe586, cpu_features=)
at ../sysdeps/x86/dl-cacheinfo.h:217
#2 0x00000000005b1904 in handle_intel (name=name@entry=188, cpu_features=)
at ../sysdeps/x86/dl-cacheinfo.h:279
#3 0x00000000005b0606 in dl_init_cacheinfo (cpu_features=)
at ../sysdeps/x86/dl-cacheinfo.h:811
#4 init_cpu_features (cpu_features=) at ../sysdeps/x86/cpu-features.c:1030
#5 __libc_start_main_impl (main=0x4599c0

, argc=13, argv=0x7fffffffe718,
init=, fini=, rtld_fini=0x0, stack_end=0x7fffffffe708)
at ../csu/libc-start.c:269
#6 0x0000000000401201 in _start () at ../sysdeps/x86_64/start.S:115
(gdb)

since the stack-protector canary in TCB hasn't been set up yet.
bits/stdlib-bsearch.h has an __extern_inline bsearch which is protected by

#ifdef __USE_EXTERN_INLINES
# include <bits/stdlib-bsearch.h>
#endif

But __USE_EXTERN_INLINES isn't defined for clang when building glibc on
azanella/clang branch:

/* Decide whether we can define 'extern inline' functions in headers.  */
#if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
    && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__ \
    && defined __extern_inline && !(defined __clang__ && defined _LIBC)
# define __USE_EXTERN_INLINES   1
#endif

As the result, clang can't build glibc with stack protector on x86.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2024-04-18 19:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18 15:00 [Bug libc/31655] New: clang can't build glibc with stack protector hjl.tools at gmail dot com
2024-04-18 15:08 ` [Bug libc/31655] " adhemerval.zanella at linaro dot org
2024-04-18 17:43 ` skpgkp1 at gmail dot com
2024-04-18 17:45 ` hjl.tools at gmail dot com
2024-04-18 18:10 ` adhemerval.zanella at linaro dot org
2024-04-18 18:13 ` skpgkp1 at gmail dot com
2024-04-18 19:31 ` adhemerval.zanella at linaro dot org
2024-04-18 19:37 ` hjl.tools at gmail 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).