From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2799 Path: news.gmane.org!not-for-mail From: Jens Gustedt Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 1/5] Clearly identify the readonly replacement symbols that serve as 'dummies' that could (or could not) be provided by other compilation units. Date: Sat, 16 Feb 2013 00:23:18 +0100 Message-ID: References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1360970610 5864 80.91.229.3 (15 Feb 2013 23:23:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Feb 2013 23:23:30 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2800-gllmg-musl=m.gmane.org@lists.openwall.com Sat Feb 16 00:23:52 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U6UdC-0008AO-Na for gllmg-musl@plane.gmane.org; Sat, 16 Feb 2013 00:23:50 +0100 Original-Received: (qmail 9850 invoked by uid 550); 15 Feb 2013 23:23:30 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 9842 invoked from network); 15 Feb 2013 23:23:30 -0000 X-IronPort-AV: E=Sophos;i="4.84,675,1355094000"; d="scan'208";a="3112294" In-Reply-To: Resent-From: Jens Gustedt Resent-To: musl@lists.openwall.com Resent-Cc: musl X-Mailer: Evolution 3.2.3-0ubuntu6 Xref: news.gmane.org gmane.linux.lib.musl.general:2799 Archived-At: 9 0 src/internal/libc.h 4 4 src/stdio/__stdio_exit.c 2 2 src/stdio/__toread.c 2 2 src/stdio/fflush.c 3 5 src/stdio/popen.c 5 7 src/thread/pthread_create.c diff --git a/src/internal/libc.h b/src/internal/libc.h index c9416f0..a2f36fb 100644 --- a/src/internal/libc.h +++ b/src/internal/libc.h @@ -58,6 +58,15 @@ int __setxid(int, int, int, int); extern char **__environ; + +/* Provide a dummy location for all readonly symbols that are + weak. This is a fallback that should always have a value of all + zero and suitable aligned to be able to serve as an address for any + type. */ +#define WEAK_PROVIDE_DUMMY __attribute__((__weak__, __aligned__(32))) struct { unsigned char const _arr[32]; } __readonly_dummy + +#define _Readonly_alias extern __attribute__((__weak__,__alias__("__readonly_dummy"))) + #undef weak_alias #define weak_alias(old, new) \ extern __typeof(old) new __attribute__((weak, alias(#old))) diff --git a/src/stdio/__stdio_exit.c b/src/stdio/__stdio_exit.c index 0fb3323..2a38c8d 100644 --- a/src/stdio/__stdio_exit.c +++ b/src/stdio/__stdio_exit.c @@ -1,9 +1,9 @@ #include "stdio_impl.h" -static FILE *const dummy_file = 0; -weak_alias(dummy_file, __stdin_used); -weak_alias(dummy_file, __stdout_used); -weak_alias(dummy_file, __stderr_used); +WEAK_PROVIDE_DUMMY; +_Readonly_alias FILE *const __stdin_used; +_Readonly_alias FILE *const __stdout_used; +_Readonly_alias FILE *const __stderr_used; static void close_file(FILE *f) { diff --git a/src/stdio/__toread.c b/src/stdio/__toread.c index 2e804f6..7c5145c 100644 --- a/src/stdio/__toread.c +++ b/src/stdio/__toread.c @@ -13,8 +13,8 @@ int __toread(FILE *f) return 0; } -static const int dummy = 0; -weak_alias(dummy, __towrite_used); +WEAK_PROVIDE_DUMMY; +_Readonly_alias int const __towrite_used; void __stdio_exit(void); diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index af70950..22debf0 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -19,8 +19,8 @@ static int __fflush_unlocked(FILE *f) } /* stdout.c will override this if linked */ -static FILE *const dummy = 0; -weak_alias(dummy, __stdout_used); +WEAK_PROVIDE_DUMMY; +_Readonly_alias FILE *const __stdout_used; int fflush(FILE *f) { diff --git a/src/stdio/popen.c b/src/stdio/popen.c index e5fbc4f..a1fa149 100644 --- a/src/stdio/popen.c +++ b/src/stdio/popen.c @@ -6,11 +6,9 @@ #include "pthread_impl.h" #include "syscall.h" -static void dummy_0() -{ -} -weak_alias(dummy_0, __acquire_ptc); -weak_alias(dummy_0, __release_ptc); +WEAK_PROVIDE_VOID; +weak_alias(__weak_dummy_void, __acquire_ptc); +weak_alias(__weak_dummy_void, __release_ptc); pid_t __vfork(void); diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index d11dcfa..3f30116 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -81,13 +81,11 @@ static int start(void *p) #define ROUND(x) (((x)+PAGE_SIZE-1)&-PAGE_SIZE) /* pthread_key_create.c overrides this */ -static const size_t dummy = 0; -weak_alias(dummy, __pthread_tsd_size); - -static FILE *const dummy_file = 0; -weak_alias(dummy_file, __stdin_used); -weak_alias(dummy_file, __stdout_used); -weak_alias(dummy_file, __stderr_used); +WEAK_PROVIDE_DUMMY; +_Readonly_alias const size_t __pthread_tsd_size; +_Readonly_alias FILE *const __stdin_used; +_Readonly_alias FILE *const __stdout_used; +_Readonly_alias FILE *const __stderr_used; static void init_file_lock(FILE *f) { -- 1.7.9.5