FD.io VPP
v16.06
Vector Packet Processing
Main Page
Related Pages
Data Structures
Source
Files
Symbols
elf_clib.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Cisco and/or its affiliates.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at:
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
/*
16
Copyright (c) 2012 Eliot Dresselhaus
17
18
Permission is hereby granted, free of charge, to any person obtaining
19
a copy of this software and associated documentation files (the
20
"Software"), to deal in the Software without restriction, including
21
without limitation the rights to use, copy, modify, merge, publish,
22
distribute, sublicense, and/or sell copies of the Software, and to
23
permit persons to whom the Software is furnished to do so, subject to
24
the following conditions:
25
26
The above copyright notice and this permission notice shall be
27
included in all copies or substantial portions of the Software.
28
29
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36
*/
37
38
#ifndef included_clib_elf_self_h
39
#define included_clib_elf_self_h
40
41
#include <
vppinfra/elf.h
>
42
#include <
vppinfra/hash.h
>
43
44
#define CLIB_ELF_SECTION_DATA_ALIGN 32
45
46
#define CLIB_ELF_SECTION_ADD_PREFIX(n) "clib_elf_section_" n
47
48
/* Attribute used is so that static registrations work even if
49
variable is not referenced. */
50
#define CLIB_ELF_SECTION(SECTION) \
51
__attribute__ ((used, \
52
aligned (CLIB_ELF_SECTION_DATA_ALIGN), \
53
section (CLIB_ELF_SECTION_ADD_PREFIX (SECTION))))
54
55
/* Given pointer to previous data A get next pointer. EXTRA gives extra
56
space beyond A + 1 used in object. */
57
#define clib_elf_section_data_next(a,extra) \
58
uword_to_pointer (round_pow2 (pointer_to_uword (a + 1) + (extra), \
59
CLIB_ELF_SECTION_DATA_ALIGN), \
60
void *)
61
62
typedef
struct
{
63
void
*
lo
, *
hi
;
64
}
clib_elf_section_bounds_t
;
65
66
typedef
struct
{
67
/* Vector of bounds for this section. Multiple shared objects may have instances
68
of the same sections. */
69
clib_elf_section_bounds_t
*
bounds
;
70
71
/* Name of ELF section (e.g. .text). */
72
u8
*
name
;
73
}
clib_elf_section_t
;
74
75
typedef
struct
{
76
/* Vector of sections. */
77
clib_elf_section_t
*
sections
;
78
79
/* Hash map of name to section index. */
80
uword
*
section_by_name
;
81
82
/* Unix path that we were exec()ed with. */
83
char
*
exec_path
;
84
85
elf_main_t
*
elf_mains
;
86
}
clib_elf_main_t
;
87
88
always_inline
void
89
clib_elf_main_free
(
clib_elf_main_t
* m)
90
{
91
clib_elf_section_t
* s;
92
vec_foreach
(s, m->
sections
)
93
{
94
vec_free
(s->
bounds
);
95
vec_free
(s->
name
);
96
}
97
vec_free
(m->
sections
);
98
hash_free
(m->
section_by_name
);
99
100
{
101
elf_main_t
* em;
102
vec_foreach
(em, m->
elf_mains
)
103
{
104
elf_main_free
(em);
105
}
106
vec_free
(m->
elf_mains
);
107
}
108
}
109
110
/* Call with exec_path equal to argv[0] from C main. */
111
void
clib_elf_main_init
(
char
* exec_path);
112
113
clib_elf_section_bounds_t
*
clib_elf_get_section_bounds
(
char
* name);
114
115
typedef
struct
{
116
/* The symbol. */
117
elf64_symbol_t
symbol
;
118
119
/* elf_main_t where symbol came from. */
120
u32
elf_main_index
;
121
122
/* Symbol table in elf_main_t where this symbol came from. */
123
u32
symbol_table_index
;
124
}
clib_elf_symbol_t
;
125
126
/* Returns 1 if found; otherwise zero. */
127
uword
clib_elf_symbol_by_name
(
char
* name,
clib_elf_symbol_t
* result);
128
uword
clib_elf_symbol_by_address
(
uword
address,
clib_elf_symbol_t
* result);
129
130
format_function_t
format_clib_elf_symbol
,
format_clib_elf_symbol_with_address
;
131
132
#endif
/* included_clib_elf_self_h */
clib_elf_main_t::sections
clib_elf_section_t * sections
Definition:
elf_clib.h:77
hi
vmrglw vmrglh hi
Definition:
vector_altivec.h:121
format_clib_elf_symbol
format_function_t format_clib_elf_symbol
Definition:
elf_clib.h:130
clib_elf_section_bounds_t
Definition:
elf_clib.h:62
clib_elf_section_bounds_t::lo
void * lo
Definition:
elf_clib.h:63
clib_elf_symbol_t
Definition:
elf_clib.h:115
hash.h
clib_elf_section_t::bounds
clib_elf_section_bounds_t * bounds
Definition:
elf_clib.h:69
clib_elf_symbol_by_address
uword clib_elf_symbol_by_address(uword address, clib_elf_symbol_t *result)
Definition:
elf_clib.c:313
always_inline
#define always_inline
Definition:
clib.h:84
clib_elf_main_free
always_inline void clib_elf_main_free(clib_elf_main_t *m)
Definition:
elf_clib.h:89
clib_elf_symbol_t::symbol
elf64_symbol_t symbol
Definition:
elf_clib.h:117
clib_elf_main_t::exec_path
char * exec_path
Definition:
elf_clib.h:83
clib_elf_symbol_by_name
uword clib_elf_symbol_by_name(char *name, clib_elf_symbol_t *result)
Definition:
elf_clib.c:310
clib_elf_section_t::name
u8 * name
Definition:
elf_clib.h:72
hash_free
#define hash_free(h)
Definition:
hash.h:269
elf.h
clib_elf_main_t::section_by_name
uword * section_by_name
Definition:
elf_clib.h:80
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition:
vec.h:298
elf_main_free
always_inline void elf_main_free(elf_main_t *em)
Definition:
elf.h:903
clib_elf_main_t
Definition:
elf_clib.h:75
clib_elf_main_t::elf_mains
elf_main_t * elf_mains
Definition:
elf_clib.h:85
u32
unsigned int u32
Definition:
types.h:88
clib_elf_section_t
Definition:
elf_clib.h:66
clib_elf_main_init
void clib_elf_main_init(char *exec_path)
Definition:
elf_clib.c:250
format_function_t
u8 *( format_function_t)(u8 *s, va_list *args)
Definition:
format.h:48
uword
u64 uword
Definition:
types.h:112
u8
unsigned char u8
Definition:
types.h:56
format_clib_elf_symbol_with_address
format_function_t format_clib_elf_symbol_with_address
Definition:
elf_clib.h:130
clib_elf_symbol_t::elf_main_index
u32 elf_main_index
Definition:
elf_clib.h:120
elf64_symbol_t
Definition:
elf.h:331
clib_elf_get_section_bounds
clib_elf_section_bounds_t * clib_elf_get_section_bounds(char *name)
Definition:
elf_clib.c:260
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition:
vec_bootstrap.h:172
elf_main_t
Definition:
elf.h:861
clib_elf_symbol_t::symbol_table_index
u32 symbol_table_index
Definition:
elf_clib.h:123
vppinfra
vppinfra
elf_clib.h
Generated on Thu Sep 1 2016 09:11:55 for FD.io VPP by
1.8.11