summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/unformat.c
AgeCommit message (Expand)AuthorFilesLines
2022-04-04vppinfra: make _vec_len() read-onlyDamjan Marion1-3/+3
2022-03-23ip: Add unformat for flow_hash_configNathan Skrzypczak1-16/+0
2021-10-13dpdk: fix vmbus device name parsingBenoît Ganne1-1/+2
2020-10-22vppinfra: missing __clib_export va_unformatJuraj Linkeš1-1/+1
2020-10-17vppinfra: explicitly export symbolsDamjan Marion1-17/+17
2019-10-04vppinfra: create unformat function for data size parsingMathiasRaoul1-0/+24
2019-04-30vppinfra: fix buffer overflow in unformat_tokenBenoît Ganne1-2/+8
2018-10-23c11 safe string handling supportDave Barach1-4/+4
2018-09-27Trivial: Cleanup some typos.Paul Vinciguerra1-1/+1
2017-10-03Repair vlib API socket serverDave Barach1-3/+3
2017-07-10VPP-904: fixes zero length CLI parameters parseAlexander Kotov1-2/+3
2017-02-16VPP-638: 'set interface ipsec key garbage' causes infinite loopBilly McFall1-0/+5
2017-01-27IP Multicast FIB (mfib)Neale Ranns1-8/+8
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion1-0/+1077
old } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/* Postprocess pmd object files to export hw support
 *
 * Copyright 2016 Neil Horman <nhorman@tuxdriver.com>
 * Based in part on modpost.c from the linux kernel
 *
 * This software may be used and distributed according to the terms
 * of the GNU General Public License V2, incorporated herein by reference.
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#ifdef __linux__
#include <endian.h>
#else
#include <sys/endian.h>
#endif
#include <fcntl.h>
#include <unistd.h>
#include <elf.h>
#include <rte_config.h>
#include <rte_pci.h>

/* 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

/*
 * Define ELF64_* to ELF_*, the latter being defined in both 32 and 64 bit
 * flavors in elf.h.  This makes our code a bit more generic between arches
 * and allows us to support 32 bit code in the future should we ever want to
 */
#ifdef RTE_ARCH_64
#define Elf_Ehdr    Elf64_Ehdr
#define Elf_Shdr    Elf64_Shdr
#define Elf_Sym     Elf64_Sym
#define Elf_Addr    Elf64_Addr
#define Elf_Sword   Elf64_Sxword
#define Elf_Section Elf64_Half
#define ELF_ST_BIND ELF64_ST_BIND
#define ELF_ST_TYPE ELF64_ST_TYPE

#define Elf_Rel     Elf64_Rel
#define Elf_Rela    Elf64_Rela
#define ELF_R_SYM   ELF64_R_SYM
#define ELF_R_TYPE  ELF64_R_TYPE
#else
#define Elf_Ehdr    Elf32_Ehdr
#define Elf_Shdr    Elf32_Shdr
#define Elf_Sym     Elf32_Sym
#define Elf_Addr    Elf32_Addr
#define Elf_Sword   Elf32_Sxword
#define Elf_Section Elf32_Half
#define ELF_ST_BIND ELF32_ST_BIND
#define ELF_ST_TYPE ELF32_ST_TYPE

#define Elf_Rel     Elf32_Rel
#define Elf_Rela    Elf32_Rela
#define ELF_R_SYM   ELF32_R_SYM
#define ELF_R_TYPE  ELF32_R_TYPE
#endif


/*
 * Note, it seems odd that we have both a CONVERT_NATIVE and a TO_NATIVE macro
 * below.  We do this because the values passed to TO_NATIVE may themselves be
 * macros and need both macros here to get expanded.  Specifically its the width
 * variable we are concerned with, because it needs to get expanded prior to
 * string concatenation
 */
#define CONVERT_NATIVE(fend, width, x) ({ \
typeof(x) ___x; \
if ((fend) == ELFDATA2LSB) \
	___x = le##width##toh(x); \
else \
	___x = be##width##toh(x); \
	___x; \
})

#define TO_NATIVE(fend, width, x) CONVERT_NATIVE(fend, width, x)

enum opt_params {
	PMD_PARAM_STRING = 0,
	PMD_KMOD_DEP,
	PMD_OPT_MAX
};

struct pmd_driver {
	Elf_Sym *name_sym;
	const char *name;
	struct rte_pci_id *pci_tbl;
	struct pmd_driver *next;

	const char *opt_vals[PMD_OPT_MAX];
};

struct elf_info {
	unsigned long size;
	Elf_Ehdr     *hdr;
	Elf_Shdr     *sechdrs;
	Elf_Sym      *symtab_start;
	Elf_Sym      *symtab_stop;
	char         *strtab;

	/* 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;

	struct pmd_driver *drivers;
};