public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Revert __malloc_initialize_hook symbol poisoning
@ 2016-06-13 12:20 Florian Weimer
  2016-06-20  9:00 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2016-06-13 12:20 UTC (permalink / raw)
  To: libc-alpha

It turns out the Emacs-internal malloc implementation uses
__malloc_* symbols.  If glibc poisons them in <stdc-pre.h>,
Emacs will no longer compile.

2016-06-13  Florian Weimer  <fweimer@redhat.com>

	Revert symbol poisoning of  __malloc_initialize_hook.
	* include/stdc-predef.h (__malloc_initialize_hook): Remove
	poisoning.
	* malloc/Makefile: Remove un-poisoning.
	* malloc/arena.c (ptmalloc_init): Use __malloc_initialize_hook
	instead of old__malloc_initialize_hook.
	* malloc/malloc-hooks.h: Likewise.
	* malloc/malloc.c: Likewise.
	* malloc/mcheck-init.c: Likewise.

diff --git a/include/stdc-predef.h b/include/stdc-predef.h
index 52cf8d1..f9f7f73 100644
--- a/include/stdc-predef.h
+++ b/include/stdc-predef.h
@@ -57,11 +57,4 @@
 /* We do not support C11 <threads.h>.  */
 #define __STDC_NO_THREADS__		1
 
-/* Remove symbols from the API which can be interposed.  */
-#if defined (__GNUC__)
-# if __GNUC__ >= 4
-#  pragma GCC poison __malloc_initialize_hook
-# endif	 /* __GNUC__ >= 4 */
-#endif	/* __GNUC__ */
-
 #endif
diff --git a/malloc/Makefile b/malloc/Makefile
index 91eb17d..fa1730e 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -115,20 +115,6 @@ endif
 
 include ../Rules
 
-# Support references to removed APIs.  We use #pragma GCC poison in
-# <stdc-predef.h> to make it difficult to reference them.  For select
-# source files, we work around this poisoning by defining a macro on
-# the command line (which is processed before <stdc-predef.h> and can
-# therefore use tokens poisoned later).
-poisoned_apis = \
-  __malloc_initialize_hook \
-
-unpoisoned_api_defines := \
-  $(foreach sym,$(poisoned_apis), \
-    $(patsubst %,-Dold%, $(sym))=$(sym))
-CPPFLAGS-malloc.c = $(unpoisoned_api_defines)
-CPPFLAGS-mcheck-init.c = $(unpoisoned_api_defines)
-
 CFLAGS-mcheck-init.c = $(PIC-ccflag)
 CFLAGS-obstack.c = $(uses-callbacks)
 
diff --git a/malloc/arena.c b/malloc/arena.c
index 64a118c..ed5a4d5 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -341,7 +341,7 @@ ptmalloc_init (void)
         __malloc_check_init ();
     }
 #if HAVE_MALLOC_INIT_HOOK
-  void (*hook) (void) = atomic_forced_read (old__malloc_initialize_hook);
+  void (*hook) (void) = atomic_forced_read (__malloc_initialize_hook);
   if (hook != NULL)
     (*hook)();
 #endif
diff --git a/malloc/malloc-hooks.h b/malloc/malloc-hooks.h
index 3be391b..c7aa8b2 100644
--- a/malloc/malloc-hooks.h
+++ b/malloc/malloc-hooks.h
@@ -19,9 +19,6 @@
 #ifndef _MALLOC_HOOKS_H
 #define _MALLOC_HOOKS_H
 
-/* These hooks are no longer part of the public API and are poisoned
-   in <stdc-predef.h>.  Their names here reflect the command-line
-   mapping which is used inside glibc to get past the poisoning.  */
-void (*old__malloc_initialize_hook) (void);
+void (*__malloc_initialize_hook) (void);
 
 #endif  /* _MALLOC_HOOKS_H */
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 21a912a..1f5f166 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1851,9 +1851,9 @@ static void *memalign_hook_ini (size_t alignment, size_t sz,
                                 const void *caller) __THROW;
 
 #if HAVE_MALLOC_INIT_HOOK
-void weak_variable (*old__malloc_initialize_hook) (void) = NULL;
-compat_symbol (libc, old__malloc_initialize_hook,
-	       old__malloc_initialize_hook, GLIBC_2_0);
+void weak_variable (*__malloc_initialize_hook) (void) = NULL;
+compat_symbol (libc, __malloc_initialize_hook,
+	       __malloc_initialize_hook, GLIBC_2_0);
 #endif
 
 void weak_variable (*__free_hook) (void *__ptr,
diff --git a/malloc/mcheck-init.c b/malloc/mcheck-init.c
index 3218bb0..8d63dd3 100644
--- a/malloc/mcheck-init.c
+++ b/malloc/mcheck-init.c
@@ -27,4 +27,4 @@ turn_on_mcheck (void)
   mcheck (NULL);
 }
 
-void (*old__malloc_initialize_hook) (void) = turn_on_mcheck;
+void (*__malloc_initialize_hook) (void) = turn_on_mcheck;

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

* Re: [PATCH] Revert __malloc_initialize_hook symbol poisoning
  2016-06-13 12:20 [PATCH] Revert __malloc_initialize_hook symbol poisoning Florian Weimer
@ 2016-06-20  9:00 ` Andreas Schwab
  2016-06-23 15:07   ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2016-06-20  9:00 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

fweimer@redhat.com (Florian Weimer) writes:

> It turns out the Emacs-internal malloc implementation uses
> __malloc_* symbols.  If glibc poisons them in <stdc-pre.h>,
> Emacs will no longer compile.

Please install.  I don't think we should be in the business of poisoning
identifiers, even if they are in the implementation name space.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [PATCH] Revert __malloc_initialize_hook symbol poisoning
  2016-06-20  9:00 ` Andreas Schwab
@ 2016-06-23 15:07   ` Florian Weimer
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2016-06-23 15:07 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

On 06/20/2016 11:00 AM, Andreas Schwab wrote:
> fweimer@redhat.com (Florian Weimer) writes:
>
>> It turns out the Emacs-internal malloc implementation uses
>> __malloc_* symbols.  If glibc poisons them in <stdc-pre.h>,
>> Emacs will no longer compile.
>
> Please install.  I don't think we should be in the business of poisoning
> identifiers, even if they are in the implementation name space.

It is the only way to remove a symbol from the API which is used via 
interposition, which is why I went down this route in this case.

I would have done this for the other malloc hooks, but it would still 
break Emacs compatibility, so I'm just going to remove them from the header.

Florian

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

end of thread, other threads:[~2016-06-23 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-13 12:20 [PATCH] Revert __malloc_initialize_hook symbol poisoning Florian Weimer
2016-06-20  9:00 ` Andreas Schwab
2016-06-23 15:07   ` Florian Weimer

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