Guest User

Untitled

a guest
Apr 9th, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. commit 2e53dd645d5348f207cec7f8595969dc566c5a55
  2. Author: Denys Vlasenko <vda.linux@googlemail.com>
  3. Date: Mon May 17 15:56:19 2010 +0200
  4.  
  5. workaround GCC PR32219
  6.  
  7. we ended up calling 0
  8. Fixes bug #1033
  9.  
  10. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  11. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
  12.  
  13. diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
  14. index f9e1244..4ee4443 100644
  15. --- a/libc/misc/internals/__uClibc_main.c
  16. +++ b/libc/misc/internals/__uClibc_main.c
  17. @@ -105,6 +105,17 @@ _pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer *__buffer,
  18.  
  19. #endif /* !SHARED */
  20.  
  21. +/* Defeat compiler optimization which assumes function addresses are never NULL */
  22. +static __always_inline int not_null_ptr(const void *p)
  23. +{
  24. + const void *q;
  25. + asm (""
  26. + : "=r" (q) /* output */
  27. + : "0" (p) /* input */
  28. + );
  29. + return q != 0;
  30. +}
  31. +
  32. /*
  33. * Prototypes.
  34. */
  35. @@ -254,7 +265,7 @@ void __uClibc_init(void)
  36.  
  37. #ifdef __UCLIBC_HAS_LOCALE__
  38. /* Initialize the global locale structure. */
  39. - if (likely(_locale_init!=NULL))
  40. + if (likely(not_null_ptr(_locale_init)))
  41. _locale_init();
  42. #endif
  43.  
  44. @@ -264,7 +275,7 @@ void __uClibc_init(void)
  45. * Thus we get a nice size savings because the stdio functions
  46. * won't be pulled into the final static binary unless used.
  47. */
  48. - if (likely(_stdio_init != NULL))
  49. + if (likely(not_null_ptr(_stdio_init)))
  50. _stdio_init();
  51.  
  52. }
Add Comment
Please, Sign In to add comment