~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to ports/sysdeps/tile/dl-runtime.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2011 Free Software Foundation, Inc.
 
2
   This file is part of the GNU C Library.
 
3
   Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
 
4
 
 
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
 
 
10
   The GNU C Library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with the GNU C Library; if not, write to the Free
 
17
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
18
   02111-1307 USA.  */
 
19
 
 
20
/* Like x86_64, we pass the index of the relocation and not its offset.
 
21
   In _dl_profile_fixup and _dl_call_pltexit we also use the index.
 
22
   Therefore it is wasteful to compute the offset in the trampoline
 
23
   just to reverse the operation immediately afterwards.  */
 
24
#define reloc_offset reloc_arg * sizeof (PLTREL)
 
25
#define reloc_index  reloc_arg
 
26
 
 
27
#include <elf/dl-runtime.c>
 
28
 
 
29
#include <sys/mman.h>
 
30
#include <arch/sim.h>
 
31
 
 
32
/* Support notifying the simulator about new objects. */
 
33
void internal_function
 
34
_dl_arch_map_object (struct link_map *l)
 
35
{
 
36
  int shift;
 
37
 
 
38
#define DLPUTC(c) __insn_mtspr(SPR_SIM_CONTROL,                         \
 
39
                               (SIM_CONTROL_DLOPEN                      \
 
40
                                | ((c) << _SIM_CONTROL_OPERATOR_BITS)))
 
41
 
 
42
  /* Write the library address in hex. */
 
43
  DLPUTC ('0');
 
44
  DLPUTC ('x');
 
45
  for (shift = (int) sizeof (unsigned long) * 8 - 4; shift >= 0; shift -= 4)
 
46
    DLPUTC ("0123456789abcdef"[(l->l_map_start >> shift) & 0xF]);
 
47
  DLPUTC (':');
 
48
 
 
49
  /* Write the library path, including the terminating '\0'. */
 
50
  for (size_t i = 0;; i++)
 
51
    {
 
52
      DLPUTC (l->l_name[i]);
 
53
      if (l->l_name[i] == '\0')
 
54
        break;
 
55
    }
 
56
#undef DLPUTC
 
57
}
 
58
 
 
59
/* Support notifying the simulator about removed objects prior to munmap(). */
 
60
void internal_function
 
61
_dl_unmap (struct link_map *l)
 
62
{
 
63
  int shift;
 
64
 
 
65
#define DLPUTC(c) __insn_mtspr(SPR_SIM_CONTROL,                         \
 
66
                               (SIM_CONTROL_DLCLOSE                     \
 
67
                                | ((c) << _SIM_CONTROL_OPERATOR_BITS)))
 
68
 
 
69
  /* Write the library address in hex. */
 
70
  DLPUTC ('0');
 
71
  DLPUTC ('x');
 
72
  for (shift = (int) sizeof (unsigned long) * 8 - 4; shift >= 0; shift -= 4)
 
73
    DLPUTC ("0123456789abcdef"[(l->l_map_start >> shift) & 0xF]);
 
74
  DLPUTC ('\0');
 
75
#undef DLPUTC
 
76
 
 
77
  __munmap ((void *) l->l_map_start, l->l_map_end - l->l_map_start);
 
78
}
 
79
 
 
80
#define DL_UNMAP(map) _dl_unmap (map)