about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/m68k/init-first.c
blob: 384a96c16dbbfb6da7abd1de429563eb990d5a2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* Initialization code run first thing by the ELF startup code.  Linux/m68k.
   Copyright (C) 2010-2018 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library.  If not, see
   <http://www.gnu.org/licenses/>.  */

/* Note: linking in vDSO to a static binary requires changes to
   the main GLIBC proper.  Not yet implemented.  */
#ifdef SHARED

#include <dl-vdso.h>
#include <m68k-vdso.h>

static inline void
_libc_vdso_platform_setup (void)
{
  void *p;

  PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);

  /* It may happen that rtld didn't initialize the vDSO, so fallback
     to the syscall implementations if _dl_vdso_vsym returns NULL.
     This may happen when a static executable dlopen's a dynamic library.
     This really is nothing more than a workaround for rtld/csu
     deficiency.  Ideally, init code would setup the vDSO for static
     binaries too.  */

  p = _dl_vdso_vsym ("__kernel_read_tp", &linux26);
  if (p != NULL)
    {
      __vdso_read_tp = p;
      __rtld___vdso_read_tp = p;
    }
  else
    assert (__vdso_read_tp == (void *) __vdso_read_tp_stub);

  p = _dl_vdso_vsym ("__kernel_atomic_cmpxchg_32", &linux26);
  if (p != NULL)
    {
      __vdso_atomic_cmpxchg_32 = p;
      __rtld___vdso_atomic_cmpxchg_32 = p;
    }
  else
    assert (__vdso_atomic_cmpxchg_32
	    == (void *) __vdso_atomic_cmpxchg_32_stub);

  p = _dl_vdso_vsym ("__kernel_atomic_barrier", &linux26);
  if (p != NULL)
    {
      __vdso_atomic_barrier = p;
      __rtld___vdso_atomic_barrier = p;
    }
  else
    assert (__vdso_atomic_barrier == (void *) __vdso_atomic_barrier_stub);
}

#define VDSO_SETUP _libc_vdso_platform_setup

#endif /* SHARED */

#include <csu/init-first.c>