2 /* Postprocess pmd object files to export hw support
4 * Copyright 2016 Neil Horman <nhorman@tuxdriver.com>
5 * Based in part on modpost.c from the linux kernel
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License V2, incorporated herein by reference.
16 #include <sys/types.h>
22 #include <rte_config.h>
24 #include <rte_byteorder.h>
26 /* On BSD-alike OSes elf.h defines these according to host's word size */
33 * Define ELF64_* to ELF_*, the latter being defined in both 32 and 64 bit
34 * flavors in elf.h. This makes our code a bit more generic between arches
35 * and allows us to support 32 bit code in the future should we ever want to
38 #define Elf_Ehdr Elf64_Ehdr
39 #define Elf_Shdr Elf64_Shdr
40 #define Elf_Sym Elf64_Sym
41 #define Elf_Addr Elf64_Addr
42 #define Elf_Sword Elf64_Sxword
43 #define Elf_Section Elf64_Half
44 #define ELF_ST_BIND ELF64_ST_BIND
45 #define ELF_ST_TYPE ELF64_ST_TYPE
47 #define Elf_Rel Elf64_Rel
48 #define Elf_Rela Elf64_Rela
49 #define ELF_R_SYM ELF64_R_SYM
50 #define ELF_R_TYPE ELF64_R_TYPE
52 #define Elf_Ehdr Elf32_Ehdr
53 #define Elf_Shdr Elf32_Shdr
54 #define Elf_Sym Elf32_Sym
55 #define Elf_Addr Elf32_Addr
56 #define Elf_Sword Elf32_Sxword
57 #define Elf_Section Elf32_Half
58 #define ELF_ST_BIND ELF32_ST_BIND
59 #define ELF_ST_TYPE ELF32_ST_TYPE
61 #define Elf_Rel Elf32_Rel
62 #define Elf_Rela Elf32_Rela
63 #define ELF_R_SYM ELF32_R_SYM
64 #define ELF_R_TYPE ELF32_R_TYPE
69 * Note, it seems odd that we have both a CONVERT_NATIVE and a TO_NATIVE macro
70 * below. We do this because the values passed to TO_NATIVE may themselves be
71 * macros and need both macros here to get expanded. Specifically its the width
72 * variable we are concerned with, because it needs to get expanded prior to
73 * string concatenation
75 #define CONVERT_NATIVE(fend, width, x) ({ \
77 if ((fend) == ELFDATA2LSB) \
78 ___x = rte_le_to_cpu_##width(x); \
80 ___x = rte_be_to_cpu_##width(x); \
84 #define TO_NATIVE(fend, width, x) CONVERT_NATIVE(fend, width, x)
94 struct rte_pci_id *pci_tbl;
95 struct pmd_driver *next;
97 const char *opt_vals[PMD_OPT_MAX];
104 Elf_Sym *symtab_start;
105 Elf_Sym *symtab_stop;
108 /* support for 32bit section numbers */
110 unsigned int num_sections; /* max_secindex + 1 */
111 unsigned int secindex_strings;
112 /* if Nth symbol table entry has .st_shndx = SHN_XINDEX,
113 * take shndx from symtab_shndx_start[N] instead
115 Elf32_Word *symtab_shndx_start;
116 Elf32_Word *symtab_shndx_stop;
118 struct pmd_driver *drivers;