diff options
| author | Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> | 2003-02-14 10:13:33 -0600 |
|---|---|---|
| committer | Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de> | 2003-02-14 10:13:33 -0600 |
| commit | f864c7c2f6732d95cb30cf7b0b2a02c40e1c2bc8 (patch) | |
| tree | ea2b2c55560a281cd09a95a77a687adfd170fabc /scripts/modpost.h | |
| parent | cbc98ae5392ed151ecf74ad41c3ec7b0cb5547bb (diff) | |
kbuild: Merge file2alias into scripts/modpost.c
Up to now, we called "nm" to find the symbol table in vmlinux / modules.
Using code from scripts/file2alias.c allows us to do that parsing ourselves,
which is faster and will give us the opportunity to merge the
MODULE_DEVICE_TABLE() parsing into modpost, too.
Diffstat (limited to 'scripts/modpost.h')
| -rw-r--r-- | scripts/modpost.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/scripts/modpost.h b/scripts/modpost.h new file mode 100644 index 000000000000..1a5c8e829cc8 --- /dev/null +++ b/scripts/modpost.h @@ -0,0 +1,86 @@ +#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" + +#if KERNEL_ELFCLASS == ELFCLASS32 + +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define ELF_ST_BIND ELF32_ST_BIND + +#else + +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define ELF_ST_BIND ELF64_ST_BIND + +#endif + +#if KERNEL_ELFDATA != HOST_ELFDATA + +static 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]; +} + + + +#define TO_NATIVE(x) \ +({ \ + typeof(x) __x; \ + __endian(&(x), &(__x), sizeof(__x)); \ + __x; \ +}) + +#else /* endianness matches */ + +#define TO_NATIVE(x) (x) + +#endif + +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; + struct symbol *unres; + int seen; + struct buffer dev_table_buf; +}; + +struct elf_info { + unsigned long size; + Elf_Ehdr *hdr; + Elf_Shdr *sechdrs; + Elf_Sym *symtab_start; + Elf_Sym *symtab_stop; + const char *strtab; +}; + +void handle_moddevtable(struct module *mod, struct elf_info *info, + Elf_Sym *sym, const char *symname); + +void add_moddevtable(struct buffer *buf, struct module *mod); |
