Revision abcd5da7
b/dyngen.c | ||
---|---|---|
25 | 25 |
#include <unistd.h> |
26 | 26 |
#include <fcntl.h> |
27 | 27 |
|
28 |
#include "config.h" |
|
28 |
#include "config-host.h"
|
|
29 | 29 |
|
30 | 30 |
/* elf format definitions. We use these macros to test the CPU to |
31 | 31 |
allow cross compilation (this tool must be ran on the build |
... | ... | |
108 | 108 |
#define SHT_RELOC SHT_REL |
109 | 109 |
#endif |
110 | 110 |
|
111 |
#define NO_THUNK_TYPE_SIZE |
|
112 |
#include "thunk.h" |
|
111 |
#include "bswap.h" |
|
113 | 112 |
|
114 | 113 |
enum { |
115 | 114 |
OUT_GEN_OP, |
... | ... | |
648 | 647 |
{ |
649 | 648 |
ElfW(Sym) *sym; |
650 | 649 |
const char *sym_name, *p; |
651 |
target_ulong val;
|
|
650 |
unsigned long val;
|
|
652 | 651 |
int n; |
653 | 652 |
|
654 | 653 |
for(i = 0, sym = symtab; i < nb_syms; i++, sym++) { |
... | ... | |
663 | 662 |
if (!ptr) |
664 | 663 |
error("__op_labelN in invalid section"); |
665 | 664 |
offset = sym->st_value; |
666 |
val = *(target_ulong *)(ptr + offset);
|
|
665 |
val = *(unsigned long *)(ptr + offset);
|
|
667 | 666 |
#ifdef ELF_USES_RELOCA |
668 | 667 |
{ |
669 | 668 |
int reloc_shndx, nb_relocs1, j; |
... | ... | |
687 | 686 |
|
688 | 687 |
if (val >= start_offset && val < start_offset + copy_size) { |
689 | 688 |
n = strtol(p, NULL, 10); |
690 |
fprintf(outfile, " label_offsets[%d] = %d + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset); |
|
689 |
fprintf(outfile, " label_offsets[%d] = %ld + (gen_code_ptr - gen_code_buf);\n", n, val - start_offset);
|
|
691 | 690 |
} |
692 | 691 |
} |
693 | 692 |
} |
b/thunk.h | ||
---|---|---|
23 | 23 |
#include <inttypes.h> |
24 | 24 |
#include "config.h" |
25 | 25 |
|
26 |
#ifdef HAVE_BYTESWAP_H |
|
27 |
#include <byteswap.h> |
|
28 |
#else |
|
29 |
|
|
30 |
#define bswap_16(x) \ |
|
31 |
({ \ |
|
32 |
uint16_t __x = (x); \ |
|
33 |
((uint16_t)( \ |
|
34 |
(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \ |
|
35 |
(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \ |
|
36 |
}) |
|
37 |
|
|
38 |
#define bswap_32(x) \ |
|
39 |
({ \ |
|
40 |
uint32_t __x = (x); \ |
|
41 |
((uint32_t)( \ |
|
42 |
(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ |
|
43 |
(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ |
|
44 |
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ |
|
45 |
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \ |
|
46 |
}) |
|
47 |
|
|
48 |
#define bswap_64(x) \ |
|
49 |
({ \ |
|
50 |
uint64_t __x = (x); \ |
|
51 |
((uint64_t)( \ |
|
52 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \ |
|
53 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ |
|
54 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ |
|
55 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ |
|
56 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ |
|
57 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ |
|
58 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ |
|
59 |
(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \ |
|
60 |
}) |
|
61 |
|
|
62 |
#endif |
|
26 |
#include "bswap.h" |
|
63 | 27 |
|
64 | 28 |
#if defined(WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) |
65 | 29 |
#define BSWAP_NEEDED |
... | ... | |
68 | 32 |
/* XXX: autoconf */ |
69 | 33 |
#define TARGET_LONG_BITS 32 |
70 | 34 |
|
71 |
#if defined(__alpha__) || defined (__ia64__) |
|
72 |
#define HOST_LONG_BITS 64 |
|
73 |
#else |
|
74 |
#define HOST_LONG_BITS 32 |
|
75 |
#endif |
|
76 |
|
|
77 | 35 |
#define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) |
78 |
#define HOST_LONG_SIZE (HOST_LONG_BITS / 8) |
|
79 |
|
|
80 |
static inline uint16_t bswap16(uint16_t x) |
|
81 |
{ |
|
82 |
return bswap_16(x); |
|
83 |
} |
|
84 |
|
|
85 |
static inline uint32_t bswap32(uint32_t x) |
|
86 |
{ |
|
87 |
return bswap_32(x); |
|
88 |
} |
|
89 |
|
|
90 |
static inline uint64_t bswap64(uint64_t x) |
|
91 |
{ |
|
92 |
return bswap_64(x); |
|
93 |
} |
|
94 |
|
|
95 |
static inline void bswap16s(uint16_t *s) |
|
96 |
{ |
|
97 |
*s = bswap16(*s); |
|
98 |
} |
|
99 |
|
|
100 |
static inline void bswap32s(uint32_t *s) |
|
101 |
{ |
|
102 |
*s = bswap32(*s); |
|
103 |
} |
|
104 |
|
|
105 |
static inline void bswap64s(uint64_t *s) |
|
106 |
{ |
|
107 |
*s = bswap64(*s); |
|
108 |
} |
|
109 | 36 |
|
110 | 37 |
#ifdef BSWAP_NEEDED |
111 | 38 |
|
b/vlmkcow.c | ||
---|---|---|
38 | 38 |
#include <sys/poll.h> |
39 | 39 |
#include <errno.h> |
40 | 40 |
#include <sys/wait.h> |
41 |
#include <sys/stat.h> |
|
41 | 42 |
#include <netinet/in.h> |
42 | 43 |
|
43 | 44 |
#include "vl.h" |
44 | 45 |
|
45 |
#define NO_THUNK_TYPE_SIZE |
|
46 |
#include "thunk.h" |
|
46 |
#include "bswap.h" |
|
47 | 47 |
|
48 | 48 |
int cow_create(int cow_fd, const char *image_filename, |
49 | 49 |
int64_t image_sectors) |
Also available in: Unified diff