/root/src/xen/xen/common/libelf/libelf-private.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * This library is free software; you can redistribute it and/or |
3 | | * modify it under the terms of the GNU Lesser General Public |
4 | | * License as published by the Free Software Foundation; |
5 | | * version 2.1 of the License. |
6 | | * |
7 | | * This library is distributed in the hope that it will be useful, |
8 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
10 | | * Lesser General Public License for more details. |
11 | | * |
12 | | * You should have received a copy of the GNU Lesser General Public |
13 | | * License along with this library; If not, see <http://www.gnu.org/licenses/>. |
14 | | */ |
15 | | #ifndef __LIBELF_PRIVATE_H__ |
16 | | #define __LIBELF_PRIVATE_H__ |
17 | | |
18 | | #ifdef __XEN__ |
19 | | |
20 | | #include <xen/lib.h> |
21 | | #include <xen/libelf.h> |
22 | | #include <xen/softirq.h> |
23 | | #include <asm/byteorder.h> |
24 | | #include <public/elfnote.h> |
25 | | |
26 | | /* we would like to use elf->log_callback but we can't because |
27 | | * there is no vprintk in Xen */ |
28 | | #define elf_msg(elf, fmt, args ... ) \ |
29 | 29 | if (elf->verbose) printk(fmt, ## args ) |
30 | | #define elf_err(elf, fmt, args ... ) \ |
31 | 0 | printk(fmt, ## args ) |
32 | | |
33 | 0 | #define strtoull(str, end, base) simple_strtoull(str, end, base) |
34 | 0 | #define bswap_16(x) swab16(x) |
35 | 0 | #define bswap_32(x) swab32(x) |
36 | 0 | #define bswap_64(x) swab64(x) |
37 | | |
38 | | #else /* !__XEN__ */ |
39 | | |
40 | | #include <stdarg.h> |
41 | | #include <stdio.h> |
42 | | #include <stdlib.h> |
43 | | #include <string.h> |
44 | | #include <stddef.h> |
45 | | #include <inttypes.h> |
46 | | #include <limits.h> |
47 | | #ifdef __sun__ |
48 | | #include <sys/byteorder.h> |
49 | | #define bswap_16(x) BSWAP_16(x) |
50 | | #define bswap_32(x) BSWAP_32(x) |
51 | | #define bswap_64(x) BSWAP_64(x) |
52 | | #elif defined(__NetBSD__) |
53 | | #include <sys/bswap.h> |
54 | | #define bswap_16(x) bswap16(x) |
55 | | #define bswap_32(x) bswap32(x) |
56 | | #define bswap_64(x) bswap64(x) |
57 | | #elif defined(__OpenBSD__) |
58 | | #include <machine/endian.h> |
59 | | #define bswap_16(x) swap16(x) |
60 | | #define bswap_32(x) swap32(x) |
61 | | #define bswap_64(x) swap64(x) |
62 | | #elif defined(__FreeBSD__) |
63 | | #include <sys/endian.h> |
64 | | #define bswap_16(x) bswap16(x) |
65 | | #define bswap_32(x) bswap32(x) |
66 | | #define bswap_64(x) bswap64(x) |
67 | | #elif defined(__linux__) || defined(__Linux__) || defined(__MINIOS__) |
68 | | #include <byteswap.h> |
69 | | #else |
70 | | #error Unsupported OS |
71 | | #endif |
72 | | #include <xen/elfnote.h> |
73 | | #include <xen/libelf/libelf.h> |
74 | | |
75 | | #ifndef FUZZ_NO_LIBXC |
76 | | #include "xenctrl.h" |
77 | | #include "xc_private.h" |
78 | | #endif |
79 | | |
80 | | #define elf_msg(elf, fmt, args ... ) \ |
81 | | elf_call_log_callback(elf, 0, fmt , ## args ); |
82 | | #define elf_err(elf, fmt, args ... ) \ |
83 | | elf_call_log_callback(elf, 1, fmt , ## args ); |
84 | | |
85 | | void elf_call_log_callback(struct elf_binary*, bool iserr, const char *fmt,...); |
86 | | |
87 | | #define safe_strcpy(d,s) \ |
88 | | do { strncpy((d),(s),sizeof((d))-1); \ |
89 | | (d)[sizeof((d))-1] = '\0'; \ |
90 | | } while (0) |
91 | | |
92 | | #endif |
93 | | |
94 | | #undef memcpy |
95 | | #undef memset |
96 | | #undef memmove |
97 | | #undef strcpy |
98 | | |
99 | | #define memcpy MISTAKE_unspecified_memcpy |
100 | | #define memset MISTAKE_unspecified_memset |
101 | | #define memmove MISTAKE_unspecified_memmove |
102 | | #define strcpy MISTAKE_unspecified_strcpy |
103 | | /* This prevents libelf from using these undecorated versions |
104 | | * of memcpy, memset, memmove and strcpy. Every call site |
105 | | * must either use elf_mem*_unchecked, or elf_mem*_safe. */ |
106 | | |
107 | | #endif /* __LIBELF_PRIVATE_H__ */ |
108 | | |
109 | | /* |
110 | | * Local variables: |
111 | | * mode: C |
112 | | * c-file-style: "BSD" |
113 | | * c-basic-offset: 4 |
114 | | * tab-width: 4 |
115 | | * indent-tabs-mode: nil |
116 | | * End: |
117 | | */ |