init-first.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Initialization code run first thing by the ELF startup code. Linux/m68k.
  2. Copyright (C) 2010-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library. If not, see
  15. <http://www.gnu.org/licenses/>. */
  16. /* Note: linking in vDSO to a static binary requires changes to
  17. the main GLIBC proper. Not yet implemented. */
  18. #ifdef SHARED
  19. #include <dl-vdso.h>
  20. #include <m68k-vdso.h>
  21. static inline void
  22. _libc_vdso_platform_setup (void)
  23. {
  24. void *p;
  25. PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
  26. /* It may happen that rtld didn't initialize the vDSO, so fallback
  27. to the syscall implementations if _dl_vdso_vsym returns NULL.
  28. This may happen when a static executable dlopen's a dynamic library.
  29. This really is nothing more than a workaround for rtld/csu
  30. deficiency. Ideally, init code would setup the vDSO for static
  31. binaries too. */
  32. p = _dl_vdso_vsym ("__kernel_read_tp", &linux26);
  33. if (p != NULL)
  34. {
  35. __vdso_read_tp = p;
  36. __rtld___vdso_read_tp = p;
  37. }
  38. else
  39. assert (__vdso_read_tp == (void *) __vdso_read_tp_stub);
  40. p = _dl_vdso_vsym ("__kernel_atomic_cmpxchg_32", &linux26);
  41. if (p != NULL)
  42. {
  43. __vdso_atomic_cmpxchg_32 = p;
  44. __rtld___vdso_atomic_cmpxchg_32 = p;
  45. }
  46. else
  47. assert (__vdso_atomic_cmpxchg_32
  48. == (void *) __vdso_atomic_cmpxchg_32_stub);
  49. p = _dl_vdso_vsym ("__kernel_atomic_barrier", &linux26);
  50. if (p != NULL)
  51. {
  52. __vdso_atomic_barrier = p;
  53. __rtld___vdso_atomic_barrier = p;
  54. }
  55. else
  56. assert (__vdso_atomic_barrier == (void *) __vdso_atomic_barrier_stub);
  57. }
  58. #define VDSO_SETUP _libc_vdso_platform_setup
  59. #endif /* SHARED */
  60. #include <csu/init-first.c>