~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to include/grub/dl.h

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-09-13 18:02:04 UTC
  • mfrom: (1.17.15 upstream)
  • mto: (17.6.27 experimental)
  • mto: This revision was merged to the branch mainline in revision 145.
  • Revision ID: package-import@ubuntu.com-20120913180204-mojnmocbimlom4im
Tags: upstream-2.00
ImportĀ upstreamĀ versionĀ 2.00

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 */
35
35
#ifndef ASM_FILE
36
36
 
 
37
#if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU)
 
38
 
 
39
#ifndef GRUB_MOD_INIT
 
40
#define GRUB_MOD_INIT(name)     \
 
41
static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
 
42
static void \
 
43
grub_mod_init (grub_dl_t mod __attribute__ ((unused)))
 
44
#endif
 
45
 
 
46
#ifndef GRUB_MOD_FINI
 
47
#define GRUB_MOD_FINI(name)     \
 
48
static void grub_mod_fini (void) __attribute__ ((used)); \
 
49
static void \
 
50
grub_mod_fini (void)
 
51
#endif
 
52
 
 
53
#else
 
54
 
37
55
#ifndef GRUB_MOD_INIT
38
56
#define GRUB_MOD_INIT(name)     \
39
57
static void grub_mod_init (grub_dl_t mod __attribute__ ((unused))) __attribute__ ((used)); \
54
72
grub_mod_fini (void)
55
73
#endif
56
74
 
57
 
#ifdef APPLE_CC
58
 
#define GRUB_MOD_NAME(name)     \
59
 
static char grub_modname[] __attribute__ ((section ("_modname, _modname"), used)) = #name;
60
 
 
61
 
#define GRUB_MOD_DEP(name)      \
62
 
__asm__ (".section _moddeps, _moddeps\n.asciz \"" #name "\"\n")
63
 
#else
64
 
#define GRUB_MOD_NAME(name)     \
65
 
__asm__ (".section .modname\n.asciz \"" #name "\"\n")
66
 
 
67
 
#define GRUB_MOD_DEP(name)      \
68
 
__asm__ (".section .moddeps\n.asciz \"" #name "\"\n")
69
 
 
70
75
#endif
71
76
 
72
77
#endif
73
78
 
74
79
#ifndef ASM_FILE
75
 
#ifdef APPLE_CC
 
80
#ifdef __APPLE__
76
81
#define GRUB_MOD_SECTION(x) "_" #x ", _" #x ""
77
82
#else
78
83
#define GRUB_MOD_SECTION(x) "." #x
79
84
#endif
80
85
#else
81
 
#ifdef APPLE_CC
 
86
#ifdef __APPLE__
82
87
#define GRUB_MOD_SECTION(x) _ ## x , _ ##x 
83
88
#else
84
89
#define GRUB_MOD_SECTION(x) . ## x
85
90
#endif
86
91
#endif
87
92
 
 
93
#ifndef ASM_FILE
 
94
#define GRUB_MOD_DEP(name)      \
 
95
static const char grub_module_depend_##name[] \
 
96
  __attribute__((section(GRUB_MOD_SECTION(moddeps)), __used__)) = #name
 
97
#define GRUB_MOD_NAME(name)     \
 
98
static const char grub_module_name_##name[] \
 
99
 __attribute__((section(GRUB_MOD_SECTION(modname)), __used__)) = #name
 
100
#endif
 
101
 
88
102
/* Me, Vladimir Serbinenko, hereby I add this module check as per new
89
103
   GNU module policy. Note that this license check is informative only.
90
104
   Modules have to be licensed under GPLv3 or GPLv3+ (optionally
96
110
#ifndef ASM_FILE
97
111
#define GRUB_MOD_LICENSE(license)       \
98
112
  static char grub_module_license[] __attribute__ ((section (GRUB_MOD_SECTION (module_license)), used)) = "LICENSE=" license;
99
 
#else
100
 
#define GRUB_MOD_LICENSE(license)       \
101
 
  .section GRUB_MOD_SECTION(module_license), "a";       \
102
 
  .ascii "LICENSE="; \
103
 
  .ascii license; \
104
 
  .byte 0
 
113
#define GRUB_MOD_DEP(name)      \
 
114
static const char grub_module_depend_##name[] \
 
115
 __attribute__((section(GRUB_MOD_SECTION(moddeps)), __used__)) = #name
 
116
#else
 
117
#ifdef __APPLE__
 
118
.macro GRUB_MOD_LICENSE
 
119
  .section GRUB_MOD_SECTION(module_license)
 
120
  .ascii "LICENSE="
 
121
  .ascii $0
 
122
  .byte 0
 
123
.endm
 
124
#else
 
125
.macro GRUB_MOD_LICENSE license
 
126
  .section GRUB_MOD_SECTION(module_license), "a"
 
127
  .ascii "LICENSE="
 
128
  .ascii "\license"
 
129
  .byte 0
 
130
.endm
 
131
#endif
105
132
#endif
106
133
 
107
134
/* Under GPL license obligations you have to distribute your module
130
157
};
131
158
typedef struct grub_dl_dep *grub_dl_dep_t;
132
159
 
 
160
#ifndef GRUB_UTIL
133
161
struct grub_dl
134
162
{
135
163
  char *name;
139
167
  Elf_Sym *symtab;
140
168
  void (*init) (struct grub_dl *mod);
141
169
  void (*fini) (void);
 
170
#if defined (__ia64__) || defined (__powerpc__)
 
171
  void *got;
 
172
  void *tramp;
 
173
#endif
 
174
  void *base;
 
175
  grub_size_t sz;
142
176
  struct grub_dl *next;
143
177
};
 
178
#endif
144
179
typedef struct grub_dl *grub_dl_t;
145
180
 
146
 
grub_dl_t EXPORT_FUNC(grub_dl_load_file) (const char *filename);
 
181
grub_dl_t grub_dl_load_file (const char *filename);
147
182
grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
148
183
grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
149
184
int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
156
191
 
157
192
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
158
193
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
159
 
                                    grub_dl_t mod);
 
194
                                    int isfunc, grub_dl_t mod);
160
195
 
161
196
grub_err_t grub_arch_dl_check_header (void *ehdr);
162
197
grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr);
166
201
void grub_arch_dl_init_linker (void);
167
202
#endif
168
203
 
 
204
#define GRUB_IA64_DL_TRAMP_ALIGN 16
 
205
#define GRUB_IA64_DL_TRAMP_SIZE 48
 
206
#define GRUB_IA64_DL_GOT_ALIGN 16
 
207
 
 
208
void
 
209
grub_ia64_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
 
210
                                 grub_size_t *got);
 
211
 
 
212
#if defined (__ia64__)
 
213
#define GRUB_ARCH_DL_TRAMP_ALIGN GRUB_IA64_DL_TRAMP_ALIGN
 
214
#define GRUB_ARCH_DL_GOT_ALIGN GRUB_IA64_DL_GOT_ALIGN
 
215
#define GRUB_ARCH_DL_TRAMP_SIZE GRUB_IA64_DL_TRAMP_SIZE
 
216
#define grub_arch_dl_get_tramp_got_size grub_ia64_dl_get_tramp_got_size
 
217
#else
 
218
void
 
219
grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
 
220
                                 grub_size_t *got);
 
221
#endif
 
222
 
 
223
#ifdef __powerpc__
 
224
#define GRUB_ARCH_DL_TRAMP_SIZE 16
 
225
#define GRUB_ARCH_DL_TRAMP_ALIGN 4
 
226
#define GRUB_ARCH_DL_GOT_ALIGN 4
 
227
#endif
 
228
 
169
229
#endif
170
230
 
171
231
#endif /* ! GRUB_DL_H */