OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [glibc/] [sysdeps/] [openrisc/] [or32/] [dl-machine.h] - Blame information for rev 1779

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1534 robertmh
/* Machine-dependent ELF dynamic relocation inline functions.  OpenRISC version.
2
   Copyright (C) 1995-2002, 2005 Free Software Foundation, Inc.
3
   This file is part of the GNU C Library.
4
 
5
   Based on sysdeps/powerpc/powerpc32/dl-machine.h.
6
 
7
   The GNU C Library is free software; you can redistribute it and/or
8
   modify it under the terms of the GNU Lesser General Public
9
   License as published by the Free Software Foundation; either
10
   version 2.1 of the License, or (at your option) any later version.
11
 
12
   The GNU C Library is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
   Lesser General Public License for more details.
16
 
17
   You should have received a copy of the GNU Lesser General Public
18
   License along with the GNU C Library; if not, write to the Free
19
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20
   02111-1307 USA.  */
21
 
22
/* FIXME: severely fucked */
23
 
24
#ifndef dl_machine_h
25
#define dl_machine_h
26
 
27
#define ELF_MACHINE_NAME "or32"
28
 
29
#include <assert.h>
30
 
31
/* Return nonzero iff ELF header is compatible with the running host.  */
32
static inline int
33
elf_machine_matches_host (const Elf32_Ehdr *ehdr)
34
{
35
  return ehdr->e_machine == EM_OPENRISC;
36
}
37
 
38
 
39
/* Return the link-time address of _DYNAMIC, stored as
40
   the first value in the GOT. */
41
static inline Elf32_Addr
42
elf_machine_dynamic (void)
43
{
44
  /* FIXME */
45
  return NULL;
46
}
47
 
48
/* Return the run-time load address of the shared object.  */
49
static inline Elf32_Addr
50
elf_machine_load_address (void)
51
{
52
  /* FIXME */
53
  return NULL;
54
}
55
 
56
#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) /* nothing */
57
 
58
/* The PLT uses Elf32_Rela relocs.  */
59
#define elf_machine_relplt elf_machine_rela
60
 
61
/* This code is used in dl-runtime.c to call the `fixup' function
62
   and then redirect to the address it returns.  It is called
63
   from code built in the PLT by elf_machine_runtime_setup.  */
64
#define ELF_MACHINE_RUNTIME_TRAMPOLINE /* FIXME */
65
 
66
/* Mask identifying addresses reserved for the user program,
67
   where the dynamic linker should not map anything.  */
68
#define ELF_MACHINE_USER_ADDRESS_MASK   0xf0000000UL
69
 
70
/* The actual _start code is in dl-start.S.  Use a really
71
   ugly bit of assembler to let dl-start.o see _dl_start.  */
72
#define RTLD_START asm (".globl _dl_start");
73
 
74
/* FIXME */
75
#define ELF_PREFERRED_ADDRESS(loader, maplength, mapstartpref) 0
76
 
77
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
78
   PLT entries should not be allowed to define the value.
79
   ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
80
   of the main executable's symbols, as for a COPY reloc.  */
81
/* We never want to use a PLT entry as the destination of a
82
   reloc, when what is being relocated is a branch. This is
83
   partly for efficiency, but mostly so we avoid loops.  */
84
#define elf_machine_type_class(type) \
85
  ((((type) == R_PPC_JMP_SLOT                           \
86
    || (type) == R_PPC_REL24                            \
87
    || (type) == R_PPC_ADDR24) * ELF_RTYPE_CLASS_PLT)   \
88
   | (((type) == R_PPC_COPY) * ELF_RTYPE_CLASS_COPY))
89
 
90
/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
91
#define ELF_MACHINE_JMP_SLOT    R_PPC_JMP_SLOT
92
 
93
/* The PowerPC never uses REL relocations.  */
94
#define ELF_MACHINE_NO_REL 1
95
 
96
/* FIXME */
97
#define elf_machine_runtime_setup 0
98
 
99
static inline void
100
elf_machine_lazy_rel (struct link_map *map,
101
                      Elf32_Addr l_addr, const Elf32_Rela *reloc)
102
{
103
  /* elf_machine_runtime_setup handles this. */
104
}
105
 
106
/* Change the PLT entry whose reloc is 'reloc' to call the actual routine.  */
107
extern Elf32_Addr __elf_machine_fixup_plt (struct link_map *map,
108
                                           const Elf32_Rela *reloc,
109
                                           Elf32_Addr *reloc_addr,
110
                                           Elf32_Addr finaladdr);
111
 
112
static inline Elf32_Addr
113
elf_machine_fixup_plt (struct link_map *map, lookup_t t,
114
                       const Elf32_Rela *reloc,
115
                       Elf32_Addr *reloc_addr, Elf64_Addr finaladdr)
116
{
117
  return __elf_machine_fixup_plt (map, reloc, reloc_addr, finaladdr);
118
}
119
 
120
/* Return the final value of a plt relocation.  */
121
static inline Elf32_Addr
122
elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
123
                       Elf32_Addr value)
124
{
125
  return value + reloc->r_addend;
126
}
127
 
128
#endif /* dl_machine_h */
129
 
130
#ifdef RESOLVE
131
 
132
/* FIXME */
133
 
134
/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
135
   LOADADDR is the load address of the object; INFO is an array indexed
136
   by DT_* of the .dynamic section info.  */
137
 
138
inline void
139
elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
140
                  const Elf32_Sym *sym, const struct r_found_version *version,
141
                  Elf32_Addr *const reloc_addr)
142
{
143
  const Elf32_Sym *const refsym = sym;
144
  Elf32_Word finaladdr;
145
  const int rinfo = ELF32_R_TYPE (reloc->r_info);
146
 
147
#ifndef RESOLVE_CONFLICT_FIND_MAP
148
  if (__builtin_expect (rinfo == R_PPC_NONE, 0))
149
    return;
150
 
151
  /* The condition on the next two lines is a hack around a bug in Solaris
152
     tools on Sparc.  It's not clear whether it should really be here at all,
153
     but if not the binutils need to be changed.  */
154
  if (rinfo == R_PPC_RELATIVE
155
      || (sym->st_shndx != SHN_UNDEF
156
          && ELF32_ST_BIND (sym->st_info) == STB_LOCAL))
157
    {
158
      /* Has already been relocated.  */
159
      Elf32_Word loadbase = map->l_addr;
160
      finaladdr = loadbase + reloc->r_addend;
161
    }
162
  else
163
    {
164
      Elf32_Word loadbase
165
        = (Elf32_Word) (char *) (RESOLVE (&sym, version,
166
                                          ELF32_R_TYPE(reloc->r_info)));
167
      if (sym == NULL)
168
        {
169
          /* Weak symbol that wasn't actually defined anywhere.  */
170
          assert (loadbase == 0);
171
          finaladdr = reloc->r_addend;
172
        }
173
      else
174
        finaladdr = (loadbase + (Elf32_Word) (char *) sym->st_value
175
                     + reloc->r_addend);
176
    }
177
#else
178
  finaladdr = reloc->r_addend;
179
  if (rinfo == R_PPC_JMP_SLOT)
180
    RESOLVE_CONFLICT_FIND_MAP (map, reloc_addr);
181
#endif
182
 
183
  /* A small amount of code is duplicated here for speed.  In libc,
184
     more than 90% of the relocs are R_PPC_RELATIVE; in the X11 shared
185
     libraries, 60% are R_PPC_RELATIVE, 24% are R_PPC_GLOB_DAT or
186
     R_PPC_ADDR32, and 16% are R_PPC_JMP_SLOT (which this routine
187
     wouldn't usually handle).  As an bonus, doing this here allows
188
     the switch statement in __process_machine_rela to work.  */
189
  if (rinfo == R_PPC_RELATIVE
190
      || rinfo == R_PPC_GLOB_DAT
191
      || rinfo == R_PPC_ADDR32)
192
    {
193
      *reloc_addr = finaladdr;
194
    }
195
  /* FIXME */
196
}
197
 
198
static inline void
199
elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
200
                           Elf32_Addr *const reloc_addr)
201
{
202
  *reloc_addr = l_addr + reloc->r_addend;
203
}
204
 
205
/* The SVR4 ABI specifies that the JMPREL relocs must be inside the
206
   DT_RELA table.  */
207
#define ELF_MACHINE_PLTREL_OVERLAP 1
208
 
209
#endif /* RESOLVE */

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.