]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Force building with -fno-common
authorFlorian Weimer <fweimer@redhat.com>
Fri, 9 Jul 2021 18:09:14 +0000 (20:09 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 9 Jul 2021 18:09:14 +0000 (20:09 +0200)
As a result, is not necessary to specify __attribute__ ((nocommon))
on individual definitions.

GCC 10 defaults to -fno-common on all architectures except ARC,
but this change is compatible with older GCC versions and ARC, too.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
21 files changed:
Makeconfig
csu/libc-start.c
elf/dl-support.c
elf/rtld.c
include/shlib-compat.h
malloc/malloc.c
malloc/mtrace.c
misc/regexp.c
nptl/libc_multiple_threads.c
nptl/lowlevellock.c
nptl/pthread_create.c
nptl/pthread_keys.c
nptl/vars.c
resolv/res_libc.c
stdlib/abort.c
sunrpc/key_call.c
sunrpc/rpc_common.c
sunrpc/svcauth_des.c
sysdeps/nptl/dl-tls_init_tp.c
sysdeps/powerpc/nofpu/sim-full.c
sysdeps/unix/sysv/linux/timer_routines.c

index efc7351d718251357c4dfabc57f905ac2a066ff1..68663d984e6a126480f337e9f19b8512ace00162 100644 (file)
@@ -923,8 +923,12 @@ ifeq       "$(strip $(+cflags))" ""
 +cflags        := $(default_cflags)
 endif  # $(+cflags) == ""
 
+# Force building with -fno-common because hidden_def, compat_symbol
+# and other constructs do not work for common symbols (and would
+# otherwise require specifying __attribute__ ((nocommon)) on a
+# case-by-case basis).
 +cflags += $(cflags-cpu) $(+gccwarn) $(+merge-constants) $(+math-flags) \
-          $(+stack-protector)
+          $(+stack-protector) -fno-common
 +gcc-nowarn := -w
 
 # Each sysdeps directory can contain header files that both will be
index 5b5913e7bfd583261e3250fad43c28fae459a81c..0350b006fdcc22d2957c2b0df58cdac1c2e29b85 100644 (file)
@@ -52,8 +52,7 @@ uintptr_t __stack_chk_guard attribute_relro;
 # ifndef  THREAD_SET_POINTER_GUARD
 /* Only exported for architectures that don't store the pointer guard
    value in thread local area.  */
-uintptr_t __pointer_chk_guard_local
-       attribute_relro attribute_hidden __attribute__ ((nocommon));
+uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
 # endif
 #endif
 
index dfc9ab760e665acc98df6b99fada5809ef2d4071..01557181753fb38d2ed9872048104cc731bbc986 100644 (file)
@@ -163,8 +163,8 @@ int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
 ElfW(auxv_t) *_dl_auxv;
 const ElfW(Phdr) *_dl_phdr;
 size_t _dl_phnum;
-uint64_t _dl_hwcap __attribute__ ((nocommon));
-uint64_t _dl_hwcap2 __attribute__ ((nocommon));
+uint64_t _dl_hwcap;
+uint64_t _dl_hwcap2;
 
 /* The value of the FPU control word the kernel will preset in hardware.  */
 fpu_control_t _dl_fpu_control = _FPU_DEFAULT;
@@ -176,7 +176,7 @@ fpu_control_t _dl_fpu_control = _FPU_DEFAULT;
    file.  Since there is no way to set this nonzero (we don't grok the
    LD_HWCAP_MASK environment variable here), there is no real point in
    setting _dl_hwcap nonzero below, but we do anyway.  */
-uint64_t _dl_hwcap_mask __attribute__ ((nocommon));
+uint64_t _dl_hwcap_mask;
 #endif
 
 /* Prevailing state of the stack.  Generally this includes PF_X, indicating it's
index fbbd60b446daa8f07f34bdf5755d38a6bbe4a2ee..e3fb2a5b2aab0c90e5587f24dc744caeb92abbdf 100644 (file)
@@ -163,8 +163,7 @@ uintptr_t __stack_chk_guard attribute_relro;
 
 /* Only exported for architectures that don't store the pointer guard
    value in thread local area.  */
-uintptr_t __pointer_chk_guard_local
-     attribute_relro attribute_hidden __attribute__ ((nocommon));
+uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
 #ifndef THREAD_SET_POINTER_GUARD
 strong_alias (__pointer_chk_guard_local, __pointer_chk_guard)
 #endif
index 6c423c8cb026362e1e7c7bde07ae9f55bac5a473..c29a0e081fcb625e77a08b9d40fcb24ed02eca7d 100644 (file)
    unspecified whether SYMBOL@VERSION is associated with LOCAL, or if
    an intermediate alias is created.  If LOCAL and SYMBOL are
    distinct, and LOCAL is also intended for export, its version should
-   be specified explicitly with versioned_symbol, too.
-
-   If LOCAL is a data symbol and does not have a non-zero initializer,
-   it should be defined with __attribute__ ((nocommon)) for
-   compatibility with GCC versions that default to -fcommon.  */
+   be specified explicitly with versioned_symbol, too.  */
 # define versioned_symbol(lib, local, symbol, version) \
   versioned_symbol_1 (lib, local, symbol, version)
 # define versioned_symbol_1(lib, local, symbol, version) \
index 0253453f276901f4d951c47bfe14f779d979306c..154f6b460c16ee9363006d343356631541547b15 100644 (file)
@@ -2026,7 +2026,7 @@ static void *memalign_hook_ini (size_t alignment, size_t sz,
                                 const void *caller) __THROW;
 
 #if HAVE_MALLOC_INIT_HOOK
-void (*__malloc_initialize_hook) (void) __attribute__ ((nocommon));
+void (*__malloc_initialize_hook) (void);
 compat_symbol (libc, __malloc_initialize_hook,
               __malloc_initialize_hook, GLIBC_2_0);
 #endif
index f5b8321c6bcf83e1cbbeda27cc4ceb7075792200..6c2c58b7061f2b2cc3dfd41d391a4b25de1e38fb 100644 (file)
@@ -59,7 +59,7 @@ __libc_lock_define_initialized (static, lock);
    case some applications ended up linking against them but they don't actually
    do anything anymore; not that they did much before anyway.  */
 
-void *mallwatch __attribute__ ((nocommon));
+void *mallwatch;
 compat_symbol (libc, mallwatch, mallwatch, GLIBC_2_0);
 
 void
index d101afd7a1daf5ae20ecee6a988eb4e6cd4ec49b..ba748756bf382be62368562f69a720d06290c4e6 100644 (file)
 
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
 
-/* Define the variables used for the interface.  Avoid .symver on common
-   symbol, which just creates a new common symbol, not an alias.  */
-char *loc1 __attribute__ ((nocommon));
-char *loc2 __attribute__ ((nocommon));
+/* Define the variables used for the interface.  */
+char *loc1;
+char *loc2;
 compat_symbol (libc, loc1, loc1, GLIBC_2_0);
 compat_symbol (libc, loc2, loc2, GLIBC_2_0);
 
 /* Although we do not support the use we define this variable as well.  */
-char *locs __attribute__ ((nocommon));
+char *locs;
 compat_symbol (libc, locs, locs, GLIBC_2_0);
 
 
index a0e7932c26e81b2c57d54c25210db7f3f622cdf5..4eeec856adde5d7e58db60ff2fecab05482f4bd2 100644 (file)
@@ -23,7 +23,7 @@
 /* Variable set to a nonzero value either if more than one thread runs or ran,
    or if a single-threaded process is trying to cancel itself.  See
    nptl/descr.h for more context on the single-threaded process case.  */
-int __libc_multiple_threads __attribute__ ((nocommon));
+int __libc_multiple_threads;
 libc_hidden_data_def (__libc_multiple_threads)
 # endif
 #endif
index 4f88178964eda7d58c2db5200e883a29fd435735..9dccc9889e05252a72cbc93abef3f8df9ff0127c 100644 (file)
@@ -67,6 +67,6 @@ __lll_lock_wake (int *futex, int private)
 libc_hidden_def (__lll_lock_wake)
 
 #if ENABLE_ELISION_SUPPORT
-int __pthread_force_elision __attribute__ ((nocommon));
+int __pthread_force_elision;
 libc_hidden_data_def (__pthread_force_elision)
 #endif
index d1b6817a81b21ef1cbdc2c6acc492bd45edfaf2e..440adc2a6f93d663e268e70ff56733f6876f0833 100644 (file)
 
 
 /* Globally enabled events.  */
-td_thr_events_t __nptl_threads_events __attribute__ ((nocommon));
+td_thr_events_t __nptl_threads_events;
 libc_hidden_proto (__nptl_threads_events)
 libc_hidden_data_def (__nptl_threads_events)
 
 /* Pointer to descriptor with the last event.  */
-struct pthread *__nptl_last_event __attribute__ ((nocommon));
+struct pthread *__nptl_last_event;
 libc_hidden_proto (__nptl_last_event)
 libc_hidden_data_def (__nptl_last_event)
 
index 76e4cfad3431c121aeb76926b24f7aa9d95b24e8..d7bbdd9af7aebbf504d61add2a78415570527e01 100644 (file)
@@ -19,6 +19,5 @@
 #include <pthreadP.h>
 
 /* Table of the key information.  */
-struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX]
-  __attribute__ ((nocommon));
+struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX];
 libc_hidden_data_def (__pthread_keys)
index 989d7930e0d1113e8b727b304dc014c6a13d5db3..c3ec368b1b9be5445b76cb53f4013b50651945fc 100644 (file)
 
 /* Default thread attributes for the case when the user does not
    provide any.  */
-union pthread_attr_transparent __default_pthread_attr
-  __attribute__ ((nocommon));
+union pthread_attr_transparent __default_pthread_attr;
 libc_hidden_data_def (__default_pthread_attr)
 
 /* Mutex protecting __default_pthread_attr.  */
-int __default_pthread_attr_lock __attribute__ ((nocommon))
-  = LLL_LOCK_INITIALIZER;
+int __default_pthread_attr_lock = LLL_LOCK_INITIALIZER;
 libc_hidden_data_def (__default_pthread_attr_lock)
index 636d2385920943a072eff437c71334218886ebd8..41d44caa57993a29e7160e237e4cba206dcf17d0 100644 (file)
@@ -88,7 +88,7 @@ res_init (void)
    This differs from plain `struct __res_state _res;' in that it doesn't
    create a common definition, but a plain symbol that resides in .bss,
    which can have an alias.  */
-struct __res_state _res __attribute__ ((nocommon));
+struct __res_state _res;
 
 #undef __resp
 __thread struct __res_state *__resp = &_res;
index 8f5f4fe6b8ec65a2d6887fe8a603879e7092535a..018f735fbfa1509aa181dbed0a2c460b0e8deca5 100644 (file)
@@ -32,7 +32,7 @@
 #endif
 
 /* Exported variable to locate abort message in core files etc.  */
-struct abort_msg_s *__abort_msg __attribute__ ((nocommon));
+struct abort_msg_s *__abort_msg;
 libc_hidden_def (__abort_msg)
 
 /* We must avoid to run in circles.  Therefore we remember how far we
index f13b0a7e4c3feb6a2446fe6919f92bc811fc43cf..8ea4303d7d6c55ea7e1a366bccf76948804bfb70 100644 (file)
@@ -290,11 +290,9 @@ libc_hidden_nolink_sunrpc (key_get_conv, GLIBC_2_1)
  * implementations of these functions, and to call those in key_call().
  */
 
-cryptkeyres *(*__key_encryptsession_pk_LOCAL) (uid_t, char *)
-  __attribute__ ((nocommon));
-cryptkeyres *(*__key_decryptsession_pk_LOCAL) (uid_t, char *)
-  __attribute__ ((nocommon));
-des_block *(*__key_gendes_LOCAL) (uid_t, char *) __attribute__ ((nocommon));
+cryptkeyres *(*__key_encryptsession_pk_LOCAL) (uid_t, char *);
+cryptkeyres *(*__key_decryptsession_pk_LOCAL) (uid_t, char *);
+des_block *(*__key_gendes_LOCAL) (uid_t, char *);
 #ifdef SHARED
 # ifndef EXPORT_RPC_SYMBOLS
 compat_symbol (libc, __key_encryptsession_pk_LOCAL,
index 05abab2a1dd48c8cc133f4cafa02cc10cc6fe5b5..97e90be89c540f74121f42429b6cf7005f40d48a 100644 (file)
 /* We are very tricky here.  We want to have _null_auth in a read-only
    section but we cannot add const to the type because this isn't how
    the variable is declared.  So we use the section attribute.  */
-struct opaque_auth _null_auth __attribute__ ((nocommon));
+struct opaque_auth _null_auth;
 libc_hidden_nolink_sunrpc (_null_auth, GLIBC_2_0)
 
-/* The variables need the nocommon attribute, so that it is possible
-   to create aliases and specify symbol versions.  */
-fd_set svc_fdset  __attribute__ ((nocommon));
-struct rpc_createerr rpc_createerr  __attribute__ ((nocommon));
-struct pollfd *svc_pollfd  __attribute__ ((nocommon));
-int svc_max_pollfd  __attribute__ ((nocommon));
+fd_set svc_fdset;
+struct rpc_createerr rpc_createerr;
+struct pollfd *svc_pollfd;
+int svc_max_pollfd;
 #ifdef SHARED
 # ifndef EXPORT_RPC_SYMBOLS
 compat_symbol (libc, svc_fdset, svc_fdset, GLIBC_2_0);
index 25a85c90970d4cedd9da724180bfc11016d7fec1..dba66a0d77bb9dcf9802298f27fd7d600f95b998 100644 (file)
@@ -93,7 +93,7 @@ struct
     u_long ncachereplays;      /* times cache hit, and is replay */
     u_long ncachemisses;       /* times cache missed */
   }
-svcauthdes_stats __attribute__ ((nocommon));
+svcauthdes_stats;
 #ifdef SHARED
 compat_symbol (libc, svcauthdes_stats, svcauthdes_stats, GLIBC_2_0);
 #endif
index c3349dd14c93e4ad1af25fd26f65d5bb8fbd1985..ca494dd3a52c4ebf9d6f9f08ea0940b24d974401 100644 (file)
 #include <tls.h>
 
 #ifndef __ASSUME_SET_ROBUST_LIST
-bool __nptl_set_robust_list_avail __attribute__ ((nocommon));
+bool __nptl_set_robust_list_avail;
 rtld_hidden_data_def (__nptl_set_robust_list_avail)
 #endif
 
-bool __nptl_initial_report_events __attribute__ ((nocommon));
+bool __nptl_initial_report_events;
 rtld_hidden_def (__nptl_initial_report_events)
 
 #ifdef SHARED
index 1867e8d305b9905e7ab66886909c5fba264ae423..ab1e97d9edf24da4dadf6f8ec2ad5fcea183b541 100644 (file)
 #include "soft-supp.h"
 
 /* Thread-local to store sticky exceptions.  */
-__thread int __sim_exceptions_thread __attribute__ ((nocommon));
+__thread int __sim_exceptions_thread;
 libc_hidden_tls_def (__sim_exceptions_thread);
 
 /* By default, no exceptions should trap.  */
 __thread int __sim_disabled_exceptions_thread = 0xffffffff;
 libc_hidden_tls_def (__sim_disabled_exceptions_thread);
 
-__thread int __sim_round_mode_thread __attribute__ ((nocommon));
+__thread int __sim_round_mode_thread;
 libc_hidden_tls_def (__sim_round_mode_thread);
 
 #if SIM_GLOBAL_COMPAT
-int __sim_exceptions_global __attribute__ ((nocommon));
+int __sim_exceptions_global;
 libc_hidden_data_def (__sim_exceptions_global);
 SIM_COMPAT_SYMBOL (__sim_exceptions_global, __sim_exceptions);
 
@@ -42,7 +42,7 @@ libc_hidden_data_def (__sim_disabled_exceptions_global);
 SIM_COMPAT_SYMBOL (__sim_disabled_exceptions_global,
                   __sim_disabled_exceptions);
 
-int __sim_round_mode_global __attribute__ ((nocommon));
+int __sim_round_mode_global;
 libc_hidden_data_def (__sim_round_mode_global);
 SIM_COMPAT_SYMBOL (__sim_round_mode_global, __sim_round_mode);
 #endif
index 30ad32b4fcae528ec2a5ec25b898d9b9494bea70..02bad0384e3cec3e6d7024693d76d7181f62752e 100644 (file)
@@ -107,12 +107,11 @@ timer_helper_thread (void *arg)
 
 
 /* Control variable for helper thread creation.  */
-pthread_once_t __timer_helper_once __attribute__ ((nocommon))
-  = PTHREAD_ONCE_INIT;
+pthread_once_t __timer_helper_once = PTHREAD_ONCE_INIT;
 
 
 /* TID of the helper thread.  */
-pid_t __timer_helper_tid __attribute__ ((nocommon));
+pid_t __timer_helper_tid;
 
 
 /* Reset variables so that after a fork a new helper thread gets started.  */