Blame view
scripts/mod/modpost.h
4.85 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 9 10 11 12 13 |
#include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> #include <fcntl.h> #include <unistd.h> #include <elf.h> #include "elfconfig.h" |
3c0561e00 Avoid conflict wi... |
14 15 16 17 18 |
/* On BSD-alike OSes elf.h defines these according to host's word size */ #undef ELF_ST_BIND #undef ELF_ST_TYPE #undef ELF_R_SYM #undef ELF_R_TYPE |
1da177e4c Linux-2.6.12-rc2 |
19 |
#if KERNEL_ELFCLASS == ELFCLASS32 |
62070fa42 kbuild: kill trai... |
20 21 |
#define Elf_Ehdr Elf32_Ehdr #define Elf_Shdr Elf32_Shdr |
1da177e4c Linux-2.6.12-rc2 |
22 |
#define Elf_Sym Elf32_Sym |
b39927cf4 kbuild: check for... |
23 |
#define Elf_Addr Elf32_Addr |
9ad21c3f3 kbuild: try harde... |
24 |
#define Elf_Sword Elf64_Sword |
4f4c4ee1b kbuild: Use Elfnn... |
25 |
#define Elf_Section Elf32_Half |
1da177e4c Linux-2.6.12-rc2 |
26 27 |
#define ELF_ST_BIND ELF32_ST_BIND #define ELF_ST_TYPE ELF32_ST_TYPE |
2c1a51f39 [PATCH] kbuild: c... |
28 |
#define Elf_Rel Elf32_Rel |
b39927cf4 kbuild: check for... |
29 30 31 |
#define Elf_Rela Elf32_Rela #define ELF_R_SYM ELF32_R_SYM #define ELF_R_TYPE ELF32_R_TYPE |
1da177e4c Linux-2.6.12-rc2 |
32 |
#else |
62070fa42 kbuild: kill trai... |
33 34 |
#define Elf_Ehdr Elf64_Ehdr #define Elf_Shdr Elf64_Shdr |
1da177e4c Linux-2.6.12-rc2 |
35 |
#define Elf_Sym Elf64_Sym |
b39927cf4 kbuild: check for... |
36 |
#define Elf_Addr Elf64_Addr |
9ad21c3f3 kbuild: try harde... |
37 |
#define Elf_Sword Elf64_Sxword |
4f4c4ee1b kbuild: Use Elfnn... |
38 |
#define Elf_Section Elf64_Half |
1da177e4c Linux-2.6.12-rc2 |
39 40 |
#define ELF_ST_BIND ELF64_ST_BIND #define ELF_ST_TYPE ELF64_ST_TYPE |
2c1a51f39 [PATCH] kbuild: c... |
41 |
#define Elf_Rel Elf64_Rel |
b39927cf4 kbuild: check for... |
42 43 44 |
#define Elf_Rela Elf64_Rela #define ELF_R_SYM ELF64_R_SYM #define ELF_R_TYPE ELF64_R_TYPE |
1da177e4c Linux-2.6.12-rc2 |
45 |
#endif |
eae07ac60 [PATCH] kbuild: f... |
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
/* The 64-bit MIPS ELF ABI uses an unusual reloc format. */ typedef struct { Elf32_Word r_sym; /* Symbol index */ unsigned char r_ssym; /* Special symbol for 2nd relocation */ unsigned char r_type3; /* 3rd relocation type */ unsigned char r_type2; /* 2nd relocation type */ unsigned char r_type1; /* 1st relocation type */ } _Elf64_Mips_R_Info; typedef union { Elf64_Xword r_info_number; _Elf64_Mips_R_Info r_info_fields; } _Elf64_Mips_R_Info_union; #define ELF64_MIPS_R_SYM(i) \ ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) |
ae4ac1232 kbuild: make bett... |
64 65 |
#define ELF64_MIPS_R_TYPE(i) \ ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1) |
1da177e4c Linux-2.6.12-rc2 |
66 67 68 69 70 71 72 73 |
#if KERNEL_ELFDATA != HOST_ELFDATA static inline void __endian(const void *src, void *dest, unsigned int size) { unsigned int i; for (i = 0; i < size; i++) ((unsigned char*)dest)[i] = ((unsigned char*)src)[size - i-1]; } |
1da177e4c Linux-2.6.12-rc2 |
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
#define TO_NATIVE(x) \ ({ \ typeof(x) __x; \ __endian(&(x), &(__x), sizeof(__x)); \ __x; \ }) #else /* endianness matches */ #define TO_NATIVE(x) (x) #endif #define NOFAIL(ptr) do_nofail((ptr), #ptr) void *do_nofail(void *ptr, const char *expr); struct buffer { char *p; int pos; int size; }; void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf, const char *fmt, ...); void buf_write(struct buffer *buf, const char *s, int len); struct module { struct module *next; const char *name; |
b817f6fef kbuild: check lic... |
105 |
int gpl_compatible; |
1da177e4c Linux-2.6.12-rc2 |
106 107 108 109 110 111 112 |
struct symbol *unres; int seen; int skip; int has_init; int has_cleanup; struct buffer dev_table_buf; char srcversion[25]; |
258f74263 modpost: Fix modp... |
113 |
int is_dot_o; |
1da177e4c Linux-2.6.12-rc2 |
114 115 116 117 118 119 120 121 |
}; struct elf_info { unsigned long size; Elf_Ehdr *hdr; Elf_Shdr *sechdrs; Elf_Sym *symtab_start; Elf_Sym *symtab_stop; |
bd5cbcedf kbuild: export-ty... |
122 |
Elf_Section export_sec; |
c96fca213 kbuild: warn when... |
123 |
Elf_Section export_unused_sec; |
bd5cbcedf kbuild: export-ty... |
124 |
Elf_Section export_gpl_sec; |
c96fca213 kbuild: warn when... |
125 |
Elf_Section export_unused_gpl_sec; |
bd5cbcedf kbuild: export-ty... |
126 |
Elf_Section export_gpl_future_sec; |
7d02b490e Kbuild, lto: Drop... |
127 |
char *strtab; |
1da177e4c Linux-2.6.12-rc2 |
128 129 |
char *modinfo; unsigned int modinfo_len; |
1ce53adf1 modpost: support ... |
130 131 132 133 134 135 136 137 138 |
/* support for 32bit section numbers */ unsigned int num_sections; /* max_secindex + 1 */ unsigned int secindex_strings; /* if Nth symbol table entry has .st_shndx = SHN_XINDEX, * take shndx from symtab_shndx_start[N] instead */ Elf32_Word *symtab_shndx_start; Elf32_Word *symtab_shndx_stop; |
1da177e4c Linux-2.6.12-rc2 |
139 |
}; |
1ce53adf1 modpost: support ... |
140 141 142 143 |
static inline int is_shndx_special(unsigned int i) { return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; } |
6845756b2 modpost: Update 6... |
144 145 146 147 |
/* * Move reserved section indices SHN_LORESERVE..SHN_HIRESERVE out of * the way to -256..-1, to avoid conflicting with real section * indices. |
1ce53adf1 modpost: support ... |
148 |
*/ |
6845756b2 modpost: Update 6... |
149 |
#define SPECIAL(i) ((i) - (SHN_HIRESERVE + 1)) |
1ce53adf1 modpost: support ... |
150 151 152 153 154 |
/* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ static inline unsigned int get_secindex(const struct elf_info *info, const Elf_Sym *sym) { |
6845756b2 modpost: Update 6... |
155 156 |
if (is_shndx_special(sym->st_shndx)) return SPECIAL(sym->st_shndx); |
1ce53adf1 modpost: support ... |
157 158 |
if (sym->st_shndx != SHN_XINDEX) return sym->st_shndx; |
6845756b2 modpost: Update 6... |
159 |
return info->symtab_shndx_start[sym - info->symtab_start]; |
1ce53adf1 modpost: support ... |
160 |
} |
cb80514d9 kbuild: use warn(... |
161 |
/* file2alias.c */ |
4ce6efed4 kbuild: soften mo... |
162 |
extern unsigned int cross_build; |
1da177e4c Linux-2.6.12-rc2 |
163 164 |
void handle_moddevtable(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname); |
1da177e4c Linux-2.6.12-rc2 |
165 |
void add_moddevtable(struct buffer *buf, struct module *mod); |
cb80514d9 kbuild: use warn(... |
166 |
/* sumversion.c */ |
1da177e4c Linux-2.6.12-rc2 |
167 168 169 170 171 |
void maybe_frob_rcs_version(const char *modfilename, char *version, void *modinfo, unsigned long modinfo_offset); void get_src_version(const char *modname, char sum[], unsigned sumlen); |
cb80514d9 kbuild: use warn(... |
172 |
/* from modpost.c */ |
1da177e4c Linux-2.6.12-rc2 |
173 174 175 |
void *grab_file(const char *filename, unsigned long *size); char* get_next_line(unsigned long *pos, void *file, unsigned long size); void release_file(void *file, unsigned long size); |
cb80514d9 kbuild: use warn(... |
176 177 178 |
void fatal(const char *fmt, ...); void warn(const char *fmt, ...); |
2a1166594 kbuild: distingui... |
179 |
void merror(const char *fmt, ...); |