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 <sys/endian.h>
29 /* On BSD-alike OSes elf.h defines these according to host's word size */
36 * Define ELF64_* to ELF_*, the latter being defined in both 32 and 64 bit
37 * flavors in elf.h. This makes our code a bit more generic between arches
38 * and allows us to support 32 bit code in the future should we ever want to
41 #define Elf_Ehdr Elf64_Ehdr
42 #define Elf_Shdr Elf64_Shdr
43 #define Elf_Sym Elf64_Sym
44 #define Elf_Addr Elf64_Addr
45 #define Elf_Sword Elf64_Sxword
46 #define Elf_Section Elf64_Half
47 #define ELF_ST_BIND ELF64_ST_BIND
48 #define ELF_ST_TYPE ELF64_ST_TYPE
50 #define Elf_Rel Elf64_Rel
51 #define Elf_Rela Elf64_Rela
52 #define ELF_R_SYM ELF64_R_SYM
53 #define ELF_R_TYPE ELF64_R_TYPE
55 #define Elf_Ehdr Elf32_Ehdr
56 #define Elf_Shdr Elf32_Shdr
57 #define Elf_Sym Elf32_Sym
58 #define Elf_Addr Elf32_Addr
59 #define Elf_Sword Elf32_Sxword
60 #define Elf_Section Elf32_Half
61 #define ELF_ST_BIND ELF32_ST_BIND
62 #define ELF_ST_TYPE ELF32_ST_TYPE
64 #define Elf_Rel Elf32_Rel
65 #define Elf_Rela Elf32_Rela
66 #define ELF_R_SYM ELF32_R_SYM
67 #define ELF_R_TYPE ELF32_R_TYPE
72 * Note, it seems odd that we have both a CONVERT_NATIVE and a TO_NATIVE macro
73 * below. We do this because the values passed to TO_NATIVE may themselves be
74 * macros and need both macros here to get expanded. Specifically its the width
75 * variable we are concerned with, because it needs to get expanded prior to
76 * string concatenation
78 #define CONVERT_NATIVE(fend, width, x) ({ \
80 if ((fend) == ELFDATA2LSB) \
81 ___x = le##width##toh(x); \
83 ___x = be##width##toh(x); \
87 #define TO_NATIVE(fend, width, x) CONVERT_NATIVE(fend, width, x)
98 struct rte_pci_id *pci_tbl;
99 struct pmd_driver *next;
101 const char *opt_vals[PMD_OPT_MAX];
108 Elf_Sym *symtab_start;
109 Elf_Sym *symtab_stop;
112 /* support for 32bit section numbers */
114 unsigned int num_sections; /* max_secindex + 1 */
115 unsigned int secindex_strings;
116 /* if Nth symbol table entry has .st_shndx = SHN_XINDEX,
117 * take shndx from symtab_shndx_start[N] instead
119 Elf32_Word *symtab_shndx_start;
120 Elf32_Word *symtab_shndx_stop;
122 struct pmd_driver *drivers;