2 * Copyright (c) 2004, Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
13 * its contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
34 #define __exception exception
35 #define __fpregs fpregs
37 #define __fpscr_pad fpscr_pad
76 #define __vrsave vrsave
79 #define __darwin_i386_exception_state i386_exception_state
80 #define __darwin_i386_float_state i386_float_state
81 #define __darwin_i386_thread_state i386_thread_state
88 #define __darwin_fp_control fp_control
89 #define __darwin_fp_status fp_status
90 #define __darwin_mmst_reg mmst_reg
91 #define __darwin_xmm_reg xmm_reg
92 #define __denorm denorm
100 #define __eflags eflags
103 #define __errsumm errsumm
107 #define __faultvaddr faultvaddr
108 #define __fpu_cs fpu_cs
109 #define __fpu_dp fpu_dp
110 #define __fpu_ds fpu_ds
111 #define __fpu_fcw fpu_fcw
112 #define __fpu_fop fpu_fop
113 #define __fpu_fsw fpu_fsw
114 #define __fpu_ftw fpu_ftw
115 #define __fpu_ip fpu_ip
116 #define __fpu_mxcsr fpu_mxcsr
117 #define __fpu_mxcsrmask fpu_mxcsrmask
118 #define __fpu_reserved fpu_reserved
119 #define __fpu_reserved1 fpu_reserved1
120 #define __fpu_rsrv1 fpu_rsrv1
121 #define __fpu_rsrv2 fpu_rsrv2
122 #define __fpu_rsrv3 fpu_rsrv3
123 #define __fpu_rsrv4 fpu_rsrv4
124 #define __fpu_stmm0 fpu_stmm0
125 #define __fpu_stmm1 fpu_stmm1
126 #define __fpu_stmm2 fpu_stmm2
127 #define __fpu_stmm3 fpu_stmm3
128 #define __fpu_stmm4 fpu_stmm4
129 #define __fpu_stmm5 fpu_stmm5
130 #define __fpu_stmm6 fpu_stmm6
131 #define __fpu_stmm7 fpu_stmm7
132 #define __fpu_xmm0 fpu_xmm0
133 #define __fpu_xmm1 fpu_xmm1
134 #define __fpu_xmm2 fpu_xmm2
135 #define __fpu_xmm3 fpu_xmm3
136 #define __fpu_xmm4 fpu_xmm4
137 #define __fpu_xmm5 fpu_xmm5
138 #define __fpu_xmm6 fpu_xmm6
139 #define __fpu_xmm7 fpu_xmm7
142 #define __invalid invalid
143 #define __mmst_reg mmst_reg
144 #define __mmst_rsrv mmst_rsrv
145 #define __ovrfl ovrfl
147 #define __precis precis
150 #define __stkflt stkflt
152 #define __trapno trapno
153 #define __undfl undfl
154 #define __xmm_reg xmm_reg
174 #define __rflags rflags
186 #include <mach-o/fat.h>
187 #include <mach-o/loader.h>
188 #include <mach/m68k/thread_status.h>
189 #undef MACHINE_THREAD_STATE /* need to undef these to avoid warnings */
190 #undef MACHINE_THREAD_STATE_COUNT
191 #undef THREAD_STATE_NONE
192 #undef VALID_THREAD_STATE_FLAVOR
193 #include <mach/ppc/thread_status.h>
194 #undef MACHINE_THREAD_STATE /* need to undef these to avoid warnings */
195 #undef MACHINE_THREAD_STATE_COUNT
196 #undef THREAD_STATE_NONE
197 #undef VALID_THREAD_STATE_FLAVOR
198 #include <mach/m88k/thread_status.h>
199 #include <mach/i860/thread_status.h>
200 #include <mach/i386/thread_status.h>
201 #include <mach/hppa/thread_status.h>
202 #include <mach/sparc/thread_status.h>
203 #undef MACHINE_THREAD_STATE /* need to undef these to avoid warnings */
204 #undef MACHINE_THREAD_STATE_COUNT
205 #undef THREAD_STATE_NONE
206 #undef VALID_THREAD_STATE_FLAVOR
207 #include <mach/arm/thread_status.h>
208 #include <mach-o/nlist.h>
209 #include <mach-o/reloc.h>
210 #include <mach-o/ranlib.h>
211 #include "stuff/bool.h"
212 #include "stuff/bytesex.h"
274 * get_host_byte_sex() returns the enum constant for the byte sex of the host
284 s
= (BIG_ENDIAN_BYTE_SEX
<< 24) | LITTLE_ENDIAN_BYTE_SEX
;
285 return((enum byte_sex
)*((char *)&s
));
291 struct fat_header
*fat_header
,
292 enum byte_sex target_byte_sex
)
296 dummy
= target_byte_sex
;
299 fat_header
->magic
= SWAP_INT(fat_header
->magic
);
300 fat_header
->nfat_arch
= SWAP_INT(fat_header
->nfat_arch
);
306 struct fat_arch
*fat_archs
,
308 enum byte_sex target_byte_sex
)
313 dummy
= target_byte_sex
;
316 for(i
= 0; i
< nfat_arch
; i
++){
317 fat_archs
[i
].cputype
= SWAP_INT(fat_archs
[i
].cputype
);
318 fat_archs
[i
].cpusubtype
= SWAP_INT(fat_archs
[i
].cpusubtype
);
319 fat_archs
[i
].offset
= SWAP_INT(fat_archs
[i
].offset
);
320 fat_archs
[i
].size
= SWAP_INT(fat_archs
[i
].size
);
321 fat_archs
[i
].align
= SWAP_INT(fat_archs
[i
].align
);
328 struct mach_header
*mh
,
329 enum byte_sex target_byte_sex
)
333 dummy
= target_byte_sex
;
335 mh
->magic
= SWAP_INT(mh
->magic
);
336 mh
->cputype
= SWAP_INT(mh
->cputype
);
337 mh
->cpusubtype
= SWAP_INT(mh
->cpusubtype
);
338 mh
->filetype
= SWAP_INT(mh
->filetype
);
339 mh
->ncmds
= SWAP_INT(mh
->ncmds
);
340 mh
->sizeofcmds
= SWAP_INT(mh
->sizeofcmds
);
341 mh
->flags
= SWAP_INT(mh
->flags
);
347 struct mach_header_64
*mh
,
348 enum byte_sex target_byte_sex
)
352 dummy
= target_byte_sex
;
354 mh
->magic
= SWAP_INT(mh
->magic
);
355 mh
->cputype
= SWAP_INT(mh
->cputype
);
356 mh
->cpusubtype
= SWAP_INT(mh
->cpusubtype
);
357 mh
->filetype
= SWAP_INT(mh
->filetype
);
358 mh
->ncmds
= SWAP_INT(mh
->ncmds
);
359 mh
->sizeofcmds
= SWAP_INT(mh
->sizeofcmds
);
360 mh
->flags
= SWAP_INT(mh
->flags
);
361 mh
->reserved
= SWAP_INT(mh
->reserved
);
367 struct load_command
*lc
,
368 enum byte_sex target_byte_sex
)
372 dummy
= target_byte_sex
;
374 lc
->cmd
= SWAP_INT(lc
->cmd
);
375 lc
->cmdsize
= SWAP_INT(lc
->cmdsize
);
380 swap_segment_command(
381 struct segment_command
*sg
,
382 enum byte_sex target_byte_sex
)
386 dummy
= target_byte_sex
;
389 sg
->cmd
= SWAP_INT(sg
->cmd
);
390 sg
->cmdsize
= SWAP_INT(sg
->cmdsize
);
391 sg
->vmaddr
= SWAP_INT(sg
->vmaddr
);
392 sg
->vmsize
= SWAP_INT(sg
->vmsize
);
393 sg
->fileoff
= SWAP_INT(sg
->fileoff
);
394 sg
->filesize
= SWAP_INT(sg
->filesize
);
395 sg
->maxprot
= SWAP_INT(sg
->maxprot
);
396 sg
->initprot
= SWAP_INT(sg
->initprot
);
397 sg
->nsects
= SWAP_INT(sg
->nsects
);
398 sg
->flags
= SWAP_INT(sg
->flags
);
403 swap_segment_command_64(
404 struct segment_command_64
*sg
,
405 enum byte_sex target_byte_sex
)
409 dummy
= target_byte_sex
;
412 sg
->cmd
= SWAP_INT(sg
->cmd
);
413 sg
->cmdsize
= SWAP_INT(sg
->cmdsize
);
414 sg
->vmaddr
= SWAP_LONG_LONG(sg
->vmaddr
);
415 sg
->vmsize
= SWAP_LONG_LONG(sg
->vmsize
);
416 sg
->fileoff
= SWAP_LONG_LONG(sg
->fileoff
);
417 sg
->filesize
= SWAP_LONG_LONG(sg
->filesize
);
418 sg
->maxprot
= SWAP_INT(sg
->maxprot
);
419 sg
->initprot
= SWAP_INT(sg
->initprot
);
420 sg
->nsects
= SWAP_INT(sg
->nsects
);
421 sg
->flags
= SWAP_INT(sg
->flags
);
429 enum byte_sex target_byte_sex
)
434 dummy
= target_byte_sex
;
437 for(i
= 0; i
< nsects
; i
++){
440 s
[i
].addr
= SWAP_INT(s
[i
].addr
);
441 s
[i
].size
= SWAP_INT(s
[i
].size
);
442 s
[i
].offset
= SWAP_INT(s
[i
].offset
);
443 s
[i
].align
= SWAP_INT(s
[i
].align
);
444 s
[i
].reloff
= SWAP_INT(s
[i
].reloff
);
445 s
[i
].nreloc
= SWAP_INT(s
[i
].nreloc
);
446 s
[i
].flags
= SWAP_INT(s
[i
].flags
);
447 s
[i
].reserved1
= SWAP_INT(s
[i
].reserved1
);
448 s
[i
].reserved2
= SWAP_INT(s
[i
].reserved2
);
455 struct section_64
*s
,
457 enum byte_sex target_byte_sex
)
462 dummy
= target_byte_sex
;
465 for(i
= 0; i
< nsects
; i
++){
468 s
[i
].addr
= SWAP_LONG_LONG(s
[i
].addr
);
469 s
[i
].size
= SWAP_LONG_LONG(s
[i
].size
);
470 s
[i
].offset
= SWAP_INT(s
[i
].offset
);
471 s
[i
].align
= SWAP_INT(s
[i
].align
);
472 s
[i
].reloff
= SWAP_INT(s
[i
].reloff
);
473 s
[i
].nreloc
= SWAP_INT(s
[i
].nreloc
);
474 s
[i
].flags
= SWAP_INT(s
[i
].flags
);
475 s
[i
].reserved1
= SWAP_INT(s
[i
].reserved1
);
476 s
[i
].reserved2
= SWAP_INT(s
[i
].reserved2
);
483 struct symtab_command
*st
,
484 enum byte_sex target_byte_sex
)
488 dummy
= target_byte_sex
;
490 st
->cmd
= SWAP_INT(st
->cmd
);
491 st
->cmdsize
= SWAP_INT(st
->cmdsize
);
492 st
->symoff
= SWAP_INT(st
->symoff
);
493 st
->nsyms
= SWAP_INT(st
->nsyms
);
494 st
->stroff
= SWAP_INT(st
->stroff
);
495 st
->strsize
= SWAP_INT(st
->strsize
);
500 swap_dysymtab_command(
501 struct dysymtab_command
*dyst
,
502 enum byte_sex target_byte_sex
)
506 dummy
= target_byte_sex
;
508 dyst
->cmd
= SWAP_INT(dyst
->cmd
);
509 dyst
->cmdsize
= SWAP_INT(dyst
->cmdsize
);
510 dyst
->ilocalsym
= SWAP_INT(dyst
->ilocalsym
);
511 dyst
->nlocalsym
= SWAP_INT(dyst
->nlocalsym
);
512 dyst
->iextdefsym
= SWAP_INT(dyst
->iextdefsym
);
513 dyst
->nextdefsym
= SWAP_INT(dyst
->nextdefsym
);
514 dyst
->iundefsym
= SWAP_INT(dyst
->iundefsym
);
515 dyst
->nundefsym
= SWAP_INT(dyst
->nundefsym
);
516 dyst
->tocoff
= SWAP_INT(dyst
->tocoff
);
517 dyst
->ntoc
= SWAP_INT(dyst
->ntoc
);
518 dyst
->modtaboff
= SWAP_INT(dyst
->modtaboff
);
519 dyst
->nmodtab
= SWAP_INT(dyst
->nmodtab
);
520 dyst
->extrefsymoff
= SWAP_INT(dyst
->extrefsymoff
);
521 dyst
->nextrefsyms
= SWAP_INT(dyst
->nextrefsyms
);
522 dyst
->indirectsymoff
= SWAP_INT(dyst
->indirectsymoff
);
523 dyst
->nindirectsyms
= SWAP_INT(dyst
->nindirectsyms
);
524 dyst
->extreloff
= SWAP_INT(dyst
->extreloff
);
525 dyst
->nextrel
= SWAP_INT(dyst
->nextrel
);
526 dyst
->locreloff
= SWAP_INT(dyst
->locreloff
);
527 dyst
->nlocrel
= SWAP_INT(dyst
->nlocrel
);
533 struct symseg_command
*ss
,
534 enum byte_sex target_byte_sex
)
538 dummy
= target_byte_sex
;
540 ss
->cmd
= SWAP_INT(ss
->cmd
);
541 ss
->cmdsize
= SWAP_INT(ss
->cmdsize
);
542 ss
->offset
= SWAP_INT(ss
->offset
);
543 ss
->size
= SWAP_INT(ss
->size
);
549 struct fvmlib_command
*fl
,
550 enum byte_sex target_byte_sex
)
554 dummy
= target_byte_sex
;
556 fl
->cmd
= SWAP_INT(fl
->cmd
);
557 fl
->cmdsize
= SWAP_INT(fl
->cmdsize
);
558 fl
->fvmlib
.name
.offset
= SWAP_INT(fl
->fvmlib
.name
.offset
);
559 fl
->fvmlib
.minor_version
= SWAP_INT(fl
->fvmlib
.minor_version
);
560 fl
->fvmlib
.header_addr
= SWAP_INT(fl
->fvmlib
.header_addr
);
566 struct dylib_command
*dl
,
567 enum byte_sex target_byte_sex
)
571 dummy
= target_byte_sex
;
573 dl
->cmd
= SWAP_INT(dl
->cmd
);
574 dl
->cmdsize
= SWAP_INT(dl
->cmdsize
);
575 dl
->dylib
.name
.offset
= SWAP_INT(dl
->dylib
.name
.offset
);
576 dl
->dylib
.timestamp
= SWAP_INT(dl
->dylib
.timestamp
);
577 dl
->dylib
.current_version
= SWAP_INT(dl
->dylib
.current_version
);
578 dl
->dylib
.compatibility_version
=
579 SWAP_INT(dl
->dylib
.compatibility_version
);
584 swap_sub_framework_command(
585 struct sub_framework_command
*sub
,
586 enum byte_sex target_byte_sex
)
590 dummy
= target_byte_sex
;
592 sub
->cmd
= SWAP_INT(sub
->cmd
);
593 sub
->cmdsize
= SWAP_INT(sub
->cmdsize
);
594 sub
->umbrella
.offset
= SWAP_INT(sub
->umbrella
.offset
);
599 swap_sub_umbrella_command(
600 struct sub_umbrella_command
*usub
,
601 enum byte_sex target_byte_sex
)
605 dummy
= target_byte_sex
;
607 usub
->cmd
= SWAP_INT(usub
->cmd
);
608 usub
->cmdsize
= SWAP_INT(usub
->cmdsize
);
609 usub
->sub_umbrella
.offset
= SWAP_INT(usub
->sub_umbrella
.offset
);
614 swap_sub_library_command(
615 struct sub_library_command
*lsub
,
616 enum byte_sex target_byte_sex
)
620 dummy
= target_byte_sex
;
622 lsub
->cmd
= SWAP_INT(lsub
->cmd
);
623 lsub
->cmdsize
= SWAP_INT(lsub
->cmdsize
);
624 lsub
->sub_library
.offset
= SWAP_INT(lsub
->sub_library
.offset
);
629 swap_sub_client_command(
630 struct sub_client_command
*csub
,
631 enum byte_sex target_byte_sex
)
635 dummy
= target_byte_sex
;
637 csub
->cmd
= SWAP_INT(csub
->cmd
);
638 csub
->cmdsize
= SWAP_INT(csub
->cmdsize
);
639 csub
->client
.offset
= SWAP_INT(csub
->client
.offset
);
644 swap_prebound_dylib_command(
645 struct prebound_dylib_command
*pbdylib
,
646 enum byte_sex target_byte_sex
)
650 dummy
= target_byte_sex
;
652 pbdylib
->cmd
= SWAP_INT(pbdylib
->cmd
);
653 pbdylib
->cmdsize
= SWAP_INT(pbdylib
->cmdsize
);
654 pbdylib
->name
.offset
= SWAP_INT(pbdylib
->name
.offset
);
655 pbdylib
->nmodules
= SWAP_INT(pbdylib
->nmodules
);
656 pbdylib
->linked_modules
.offset
=
657 SWAP_INT(pbdylib
->linked_modules
.offset
);
662 swap_dylinker_command(
663 struct dylinker_command
*dyld
,
664 enum byte_sex target_byte_sex
)
668 dummy
= target_byte_sex
;
670 dyld
->cmd
= SWAP_INT(dyld
->cmd
);
671 dyld
->cmdsize
= SWAP_INT(dyld
->cmdsize
);
672 dyld
->name
.offset
= SWAP_INT(dyld
->name
.offset
);
677 swap_fvmfile_command(
678 struct fvmfile_command
*ff
,
679 enum byte_sex target_byte_sex
)
683 dummy
= target_byte_sex
;
685 ff
->cmd
= SWAP_INT(ff
->cmd
);
686 ff
->cmdsize
= SWAP_INT(ff
->cmdsize
);
687 ff
->name
.offset
= SWAP_INT(ff
->name
.offset
);
688 ff
->header_addr
= SWAP_INT(ff
->header_addr
);
695 struct thread_command
*ut
,
696 enum byte_sex target_byte_sex
)
700 dummy
= target_byte_sex
;
702 ut
->cmd
= SWAP_INT(ut
->cmd
);
703 ut
->cmdsize
= SWAP_INT(ut
->cmdsize
);
708 swap_m68k_thread_state_regs(
709 struct m68k_thread_state_regs
*cpu
,
710 enum byte_sex target_byte_sex
)
715 dummy
= target_byte_sex
;
718 for(i
= 0; i
< 8; i
++)
719 cpu
->dreg
[i
] = SWAP_INT(cpu
->dreg
[i
]);
720 for(i
= 0; i
< 8; i
++)
721 cpu
->areg
[i
] = SWAP_INT(cpu
->areg
[i
]);
722 cpu
->pad0
= SWAP_SHORT(cpu
->pad0
);
723 cpu
->sr
= SWAP_SHORT(cpu
->sr
);
724 cpu
->pc
= SWAP_INT(cpu
->pc
);
729 swap_m68k_thread_state_68882(
730 struct m68k_thread_state_68882
*fpu
,
731 enum byte_sex target_byte_sex
)
736 dummy
= target_byte_sex
;
739 for(i
= 0; i
< 8; i
++){
740 tmp
= SWAP_INT(fpu
->regs
[i
].fp
[0]);
741 fpu
->regs
[i
].fp
[1] = SWAP_INT(fpu
->regs
[i
].fp
[1]);
742 fpu
->regs
[i
].fp
[0] = SWAP_INT(fpu
->regs
[i
].fp
[2]);
743 fpu
->regs
[i
].fp
[2] = tmp
;
745 fpu
->cr
= SWAP_INT(fpu
->cr
);
746 fpu
->sr
= SWAP_INT(fpu
->sr
);
747 fpu
->iar
= SWAP_INT(fpu
->iar
);
748 fpu
->state
= SWAP_INT(fpu
->state
);
753 swap_m68k_thread_state_user_reg(
754 struct m68k_thread_state_user_reg
*user_reg
,
755 enum byte_sex target_byte_sex
)
759 dummy
= target_byte_sex
;
761 user_reg
->user_reg
= SWAP_INT(user_reg
->user_reg
);
766 swap_ppc_thread_state_t(
767 ppc_thread_state_t
*cpu
,
768 enum byte_sex target_byte_sex
)
770 cpu
->srr0
= SWAP_INT(cpu
->srr0
);
771 cpu
->srr1
= SWAP_INT(cpu
->srr1
);
772 cpu
->r0
= SWAP_INT(cpu
->r0
);
773 cpu
->r1
= SWAP_INT(cpu
->r1
);
774 cpu
->r2
= SWAP_INT(cpu
->r2
);
775 cpu
->r3
= SWAP_INT(cpu
->r3
);
776 cpu
->r4
= SWAP_INT(cpu
->r4
);
777 cpu
->r5
= SWAP_INT(cpu
->r5
);
778 cpu
->r6
= SWAP_INT(cpu
->r6
);
779 cpu
->r7
= SWAP_INT(cpu
->r7
);
780 cpu
->r8
= SWAP_INT(cpu
->r8
);
781 cpu
->r9
= SWAP_INT(cpu
->r9
);
782 cpu
->r10
= SWAP_INT(cpu
->r10
);
783 cpu
->r11
= SWAP_INT(cpu
->r11
);
784 cpu
->r12
= SWAP_INT(cpu
->r12
);
785 cpu
->r13
= SWAP_INT(cpu
->r13
);
786 cpu
->r14
= SWAP_INT(cpu
->r14
);
787 cpu
->r15
= SWAP_INT(cpu
->r15
);
788 cpu
->r16
= SWAP_INT(cpu
->r16
);
789 cpu
->r17
= SWAP_INT(cpu
->r17
);
790 cpu
->r18
= SWAP_INT(cpu
->r18
);
791 cpu
->r19
= SWAP_INT(cpu
->r19
);
792 cpu
->r20
= SWAP_INT(cpu
->r20
);
793 cpu
->r21
= SWAP_INT(cpu
->r21
);
794 cpu
->r22
= SWAP_INT(cpu
->r22
);
795 cpu
->r23
= SWAP_INT(cpu
->r23
);
796 cpu
->r24
= SWAP_INT(cpu
->r24
);
797 cpu
->r25
= SWAP_INT(cpu
->r25
);
798 cpu
->r26
= SWAP_INT(cpu
->r26
);
799 cpu
->r27
= SWAP_INT(cpu
->r27
);
800 cpu
->r28
= SWAP_INT(cpu
->r28
);
801 cpu
->r29
= SWAP_INT(cpu
->r29
);
802 cpu
->r30
= SWAP_INT(cpu
->r30
);
803 cpu
->r31
= SWAP_INT(cpu
->r31
);
804 cpu
->cr
= SWAP_INT(cpu
->cr
);
805 cpu
->xer
= SWAP_INT(cpu
->xer
);
806 cpu
->lr
= SWAP_INT(cpu
->lr
);
807 cpu
->ctr
= SWAP_INT(cpu
->ctr
);
808 cpu
->mq
= SWAP_INT(cpu
->mq
);
809 cpu
->vrsave
= SWAP_INT(cpu
->vrsave
);
814 swap_ppc_thread_state64_t(
815 ppc_thread_state64_t
*cpu
,
816 enum byte_sex target_byte_sex
)
818 cpu
->srr0
= SWAP_LONG_LONG(cpu
->srr0
);
819 cpu
->srr1
= SWAP_LONG_LONG(cpu
->srr1
);
820 cpu
->r0
= SWAP_LONG_LONG(cpu
->r0
);
821 cpu
->r1
= SWAP_LONG_LONG(cpu
->r1
);
822 cpu
->r2
= SWAP_LONG_LONG(cpu
->r2
);
823 cpu
->r3
= SWAP_LONG_LONG(cpu
->r3
);
824 cpu
->r4
= SWAP_LONG_LONG(cpu
->r4
);
825 cpu
->r5
= SWAP_LONG_LONG(cpu
->r5
);
826 cpu
->r6
= SWAP_LONG_LONG(cpu
->r6
);
827 cpu
->r7
= SWAP_LONG_LONG(cpu
->r7
);
828 cpu
->r8
= SWAP_LONG_LONG(cpu
->r8
);
829 cpu
->r9
= SWAP_LONG_LONG(cpu
->r9
);
830 cpu
->r10
= SWAP_LONG_LONG(cpu
->r10
);
831 cpu
->r11
= SWAP_LONG_LONG(cpu
->r11
);
832 cpu
->r12
= SWAP_LONG_LONG(cpu
->r12
);
833 cpu
->r13
= SWAP_LONG_LONG(cpu
->r13
);
834 cpu
->r14
= SWAP_LONG_LONG(cpu
->r14
);
835 cpu
->r15
= SWAP_LONG_LONG(cpu
->r15
);
836 cpu
->r16
= SWAP_LONG_LONG(cpu
->r16
);
837 cpu
->r17
= SWAP_LONG_LONG(cpu
->r17
);
838 cpu
->r18
= SWAP_LONG_LONG(cpu
->r18
);
839 cpu
->r19
= SWAP_LONG_LONG(cpu
->r19
);
840 cpu
->r20
= SWAP_LONG_LONG(cpu
->r20
);
841 cpu
->r21
= SWAP_LONG_LONG(cpu
->r21
);
842 cpu
->r22
= SWAP_LONG_LONG(cpu
->r22
);
843 cpu
->r23
= SWAP_LONG_LONG(cpu
->r23
);
844 cpu
->r24
= SWAP_LONG_LONG(cpu
->r24
);
845 cpu
->r25
= SWAP_LONG_LONG(cpu
->r25
);
846 cpu
->r26
= SWAP_LONG_LONG(cpu
->r26
);
847 cpu
->r27
= SWAP_LONG_LONG(cpu
->r27
);
848 cpu
->r28
= SWAP_LONG_LONG(cpu
->r28
);
849 cpu
->r29
= SWAP_LONG_LONG(cpu
->r29
);
850 cpu
->r30
= SWAP_LONG_LONG(cpu
->r30
);
851 cpu
->r31
= SWAP_LONG_LONG(cpu
->r31
);
852 cpu
->cr
= SWAP_INT(cpu
->cr
);
853 cpu
->xer
= SWAP_LONG_LONG(cpu
->xer
);
854 cpu
->lr
= SWAP_LONG_LONG(cpu
->lr
);
855 cpu
->ctr
= SWAP_LONG_LONG(cpu
->ctr
);
856 cpu
->vrsave
= SWAP_INT(cpu
->vrsave
);
861 swap_ppc_float_state_t(
862 ppc_float_state_t
*fpu
,
863 enum byte_sex target_byte_sex
)
868 dummy
= target_byte_sex
;
871 for(i
= 0; i
< 32; i
++)
872 fpu
->fpregs
[i
] = SWAP_DOUBLE(fpu
->fpregs
[i
]);
874 fpu
->fpscr_pad
= SWAP_INT(fpu
->fpscr_pad
);
875 fpu
->fpscr
= SWAP_INT(fpu
->fpscr
);
880 swap_ppc_exception_state_t(
881 ppc_exception_state_t
*state
,
882 enum byte_sex target_byte_sex
)
887 dummy
= target_byte_sex
;
890 state
->dar
= SWAP_INT(state
->dar
);
891 state
->dsisr
= SWAP_INT(state
->dsisr
);
892 state
->exception
= SWAP_INT(state
->exception
);
893 state
->pad0
= SWAP_INT(state
->pad0
);
895 for(i
= 0; i
< 4; i
++)
896 state
->pad1
[i
] = SWAP_INT(state
->pad1
[i
]);
901 swap_m88k_thread_state_grf_t(
902 m88k_thread_state_grf_t
*cpu
,
903 enum byte_sex target_byte_sex
)
907 dummy
= target_byte_sex
;
909 cpu
->r1
= SWAP_INT(cpu
->r1
);
910 cpu
->r2
= SWAP_INT(cpu
->r2
);
911 cpu
->r3
= SWAP_INT(cpu
->r3
);
912 cpu
->r4
= SWAP_INT(cpu
->r4
);
913 cpu
->r5
= SWAP_INT(cpu
->r5
);
914 cpu
->r6
= SWAP_INT(cpu
->r6
);
915 cpu
->r7
= SWAP_INT(cpu
->r7
);
916 cpu
->r8
= SWAP_INT(cpu
->r8
);
917 cpu
->r9
= SWAP_INT(cpu
->r9
);
918 cpu
->r10
= SWAP_INT(cpu
->r10
);
919 cpu
->r11
= SWAP_INT(cpu
->r11
);
920 cpu
->r12
= SWAP_INT(cpu
->r12
);
921 cpu
->r13
= SWAP_INT(cpu
->r13
);
922 cpu
->r14
= SWAP_INT(cpu
->r14
);
923 cpu
->r15
= SWAP_INT(cpu
->r15
);
924 cpu
->r16
= SWAP_INT(cpu
->r16
);
925 cpu
->r17
= SWAP_INT(cpu
->r17
);
926 cpu
->r18
= SWAP_INT(cpu
->r18
);
927 cpu
->r19
= SWAP_INT(cpu
->r19
);
928 cpu
->r20
= SWAP_INT(cpu
->r20
);
929 cpu
->r21
= SWAP_INT(cpu
->r21
);
930 cpu
->r22
= SWAP_INT(cpu
->r22
);
931 cpu
->r23
= SWAP_INT(cpu
->r23
);
932 cpu
->r24
= SWAP_INT(cpu
->r24
);
933 cpu
->r25
= SWAP_INT(cpu
->r25
);
934 cpu
->r26
= SWAP_INT(cpu
->r26
);
935 cpu
->r27
= SWAP_INT(cpu
->r27
);
936 cpu
->r28
= SWAP_INT(cpu
->r28
);
937 cpu
->r29
= SWAP_INT(cpu
->r29
);
938 cpu
->r30
= SWAP_INT(cpu
->r30
);
939 cpu
->r31
= SWAP_INT(cpu
->r31
);
940 cpu
->xip
= SWAP_INT(cpu
->xip
);
941 cpu
->xip_in_bd
= SWAP_INT(cpu
->xip_in_bd
);
942 cpu
->nip
= SWAP_INT(cpu
->nip
);
947 swap_m88k_thread_state_xrf_t(
948 m88k_thread_state_xrf_t
*fpu
,
949 enum byte_sex target_byte_sex
)
951 enum byte_sex host_byte_sex
;
953 struct swapped_m88k_fpsr
{
956 unsigned afinx
:BIT_WIDTH(0);
957 unsigned afovf
:BIT_WIDTH(1);
958 unsigned afunf
:BIT_WIDTH(2);
959 unsigned afdvz
:BIT_WIDTH(3);
960 unsigned afinv
:BIT_WIDTH(4);
961 unsigned :BITS_WIDTH(15,5);
962 unsigned xmod
:BIT_WIDTH(16);
963 unsigned :BITS_WIDTH(31,17);
968 struct swapped_m88k_fpcr
{
971 unsigned efinx
:BIT_WIDTH(0);
972 unsigned efovf
:BIT_WIDTH(1);
973 unsigned efunf
:BIT_WIDTH(2);
974 unsigned efdvz
:BIT_WIDTH(3);
975 unsigned efinv
:BIT_WIDTH(4);
976 unsigned :BITS_WIDTH(13,5);
977 m88k_fpcr_rm_t rm
:BITS_WIDTH(15,14);
978 unsigned :BITS_WIDTH(31,16);
984 host_byte_sex
= get_host_byte_sex();
986 fpu
->x1
.x
[0] = SWAP_INT(fpu
->x1
.x
[0]);
987 fpu
->x1
.x
[1] = SWAP_INT(fpu
->x1
.x
[1]);
988 fpu
->x1
.x
[2] = SWAP_INT(fpu
->x1
.x
[2]);
989 fpu
->x1
.x
[3] = SWAP_INT(fpu
->x1
.x
[3]);
990 fpu
->x2
.x
[0] = SWAP_INT(fpu
->x2
.x
[0]);
991 fpu
->x2
.x
[1] = SWAP_INT(fpu
->x2
.x
[1]);
992 fpu
->x2
.x
[2] = SWAP_INT(fpu
->x2
.x
[2]);
993 fpu
->x2
.x
[3] = SWAP_INT(fpu
->x2
.x
[3]);
994 fpu
->x3
.x
[0] = SWAP_INT(fpu
->x3
.x
[0]);
995 fpu
->x3
.x
[1] = SWAP_INT(fpu
->x3
.x
[1]);
996 fpu
->x3
.x
[2] = SWAP_INT(fpu
->x3
.x
[2]);
997 fpu
->x3
.x
[3] = SWAP_INT(fpu
->x3
.x
[3]);
998 fpu
->x4
.x
[0] = SWAP_INT(fpu
->x4
.x
[0]);
999 fpu
->x4
.x
[1] = SWAP_INT(fpu
->x4
.x
[1]);
1000 fpu
->x4
.x
[2] = SWAP_INT(fpu
->x4
.x
[2]);
1001 fpu
->x4
.x
[3] = SWAP_INT(fpu
->x4
.x
[3]);
1002 fpu
->x5
.x
[0] = SWAP_INT(fpu
->x5
.x
[0]);
1003 fpu
->x5
.x
[1] = SWAP_INT(fpu
->x5
.x
[1]);
1004 fpu
->x5
.x
[2] = SWAP_INT(fpu
->x5
.x
[2]);
1005 fpu
->x5
.x
[3] = SWAP_INT(fpu
->x5
.x
[3]);
1006 fpu
->x6
.x
[0] = SWAP_INT(fpu
->x6
.x
[0]);
1007 fpu
->x6
.x
[1] = SWAP_INT(fpu
->x6
.x
[1]);
1008 fpu
->x6
.x
[2] = SWAP_INT(fpu
->x6
.x
[2]);
1009 fpu
->x6
.x
[3] = SWAP_INT(fpu
->x6
.x
[3]);
1010 fpu
->x7
.x
[0] = SWAP_INT(fpu
->x7
.x
[0]);
1011 fpu
->x7
.x
[1] = SWAP_INT(fpu
->x7
.x
[1]);
1012 fpu
->x7
.x
[2] = SWAP_INT(fpu
->x7
.x
[2]);
1013 fpu
->x7
.x
[3] = SWAP_INT(fpu
->x7
.x
[3]);
1014 fpu
->x8
.x
[0] = SWAP_INT(fpu
->x8
.x
[0]);
1015 fpu
->x8
.x
[1] = SWAP_INT(fpu
->x8
.x
[1]);
1016 fpu
->x8
.x
[2] = SWAP_INT(fpu
->x8
.x
[2]);
1017 fpu
->x8
.x
[3] = SWAP_INT(fpu
->x8
.x
[3]);
1018 fpu
->x9
.x
[0] = SWAP_INT(fpu
->x9
.x
[0]);
1019 fpu
->x9
.x
[1] = SWAP_INT(fpu
->x9
.x
[1]);
1020 fpu
->x9
.x
[2] = SWAP_INT(fpu
->x9
.x
[2]);
1021 fpu
->x9
.x
[3] = SWAP_INT(fpu
->x9
.x
[3]);
1022 fpu
->x10
.x
[0] = SWAP_INT(fpu
->x10
.x
[0]);
1023 fpu
->x10
.x
[1] = SWAP_INT(fpu
->x10
.x
[1]);
1024 fpu
->x10
.x
[2] = SWAP_INT(fpu
->x10
.x
[2]);
1025 fpu
->x10
.x
[3] = SWAP_INT(fpu
->x10
.x
[3]);
1026 fpu
->x11
.x
[0] = SWAP_INT(fpu
->x11
.x
[0]);
1027 fpu
->x11
.x
[1] = SWAP_INT(fpu
->x11
.x
[1]);
1028 fpu
->x11
.x
[2] = SWAP_INT(fpu
->x11
.x
[2]);
1029 fpu
->x11
.x
[3] = SWAP_INT(fpu
->x11
.x
[3]);
1030 fpu
->x12
.x
[0] = SWAP_INT(fpu
->x12
.x
[0]);
1031 fpu
->x12
.x
[1] = SWAP_INT(fpu
->x12
.x
[1]);
1032 fpu
->x12
.x
[2] = SWAP_INT(fpu
->x12
.x
[2]);
1033 fpu
->x12
.x
[3] = SWAP_INT(fpu
->x12
.x
[3]);
1034 fpu
->x13
.x
[0] = SWAP_INT(fpu
->x13
.x
[0]);
1035 fpu
->x13
.x
[1] = SWAP_INT(fpu
->x13
.x
[1]);
1036 fpu
->x13
.x
[2] = SWAP_INT(fpu
->x13
.x
[2]);
1037 fpu
->x13
.x
[3] = SWAP_INT(fpu
->x13
.x
[3]);
1038 fpu
->x14
.x
[0] = SWAP_INT(fpu
->x14
.x
[0]);
1039 fpu
->x14
.x
[1] = SWAP_INT(fpu
->x14
.x
[1]);
1040 fpu
->x14
.x
[2] = SWAP_INT(fpu
->x14
.x
[2]);
1041 fpu
->x14
.x
[3] = SWAP_INT(fpu
->x14
.x
[3]);
1042 fpu
->x15
.x
[0] = SWAP_INT(fpu
->x15
.x
[0]);
1043 fpu
->x15
.x
[1] = SWAP_INT(fpu
->x15
.x
[1]);
1044 fpu
->x15
.x
[2] = SWAP_INT(fpu
->x15
.x
[2]);
1045 fpu
->x15
.x
[3] = SWAP_INT(fpu
->x15
.x
[3]);
1046 fpu
->x16
.x
[0] = SWAP_INT(fpu
->x16
.x
[0]);
1047 fpu
->x16
.x
[1] = SWAP_INT(fpu
->x16
.x
[1]);
1048 fpu
->x16
.x
[2] = SWAP_INT(fpu
->x16
.x
[2]);
1049 fpu
->x16
.x
[3] = SWAP_INT(fpu
->x16
.x
[3]);
1050 fpu
->x17
.x
[0] = SWAP_INT(fpu
->x17
.x
[0]);
1051 fpu
->x17
.x
[1] = SWAP_INT(fpu
->x17
.x
[1]);
1052 fpu
->x17
.x
[2] = SWAP_INT(fpu
->x17
.x
[2]);
1053 fpu
->x17
.x
[3] = SWAP_INT(fpu
->x17
.x
[3]);
1054 fpu
->x18
.x
[0] = SWAP_INT(fpu
->x18
.x
[0]);
1055 fpu
->x18
.x
[1] = SWAP_INT(fpu
->x18
.x
[1]);
1056 fpu
->x18
.x
[2] = SWAP_INT(fpu
->x18
.x
[2]);
1057 fpu
->x18
.x
[3] = SWAP_INT(fpu
->x18
.x
[3]);
1058 fpu
->x19
.x
[0] = SWAP_INT(fpu
->x19
.x
[0]);
1059 fpu
->x19
.x
[1] = SWAP_INT(fpu
->x19
.x
[1]);
1060 fpu
->x19
.x
[2] = SWAP_INT(fpu
->x19
.x
[2]);
1061 fpu
->x19
.x
[3] = SWAP_INT(fpu
->x19
.x
[3]);
1062 fpu
->x20
.x
[0] = SWAP_INT(fpu
->x20
.x
[0]);
1063 fpu
->x20
.x
[1] = SWAP_INT(fpu
->x20
.x
[1]);
1064 fpu
->x20
.x
[2] = SWAP_INT(fpu
->x20
.x
[2]);
1065 fpu
->x20
.x
[3] = SWAP_INT(fpu
->x20
.x
[3]);
1066 fpu
->x21
.x
[0] = SWAP_INT(fpu
->x21
.x
[0]);
1067 fpu
->x21
.x
[1] = SWAP_INT(fpu
->x21
.x
[1]);
1068 fpu
->x21
.x
[2] = SWAP_INT(fpu
->x21
.x
[2]);
1069 fpu
->x21
.x
[3] = SWAP_INT(fpu
->x21
.x
[3]);
1070 fpu
->x22
.x
[0] = SWAP_INT(fpu
->x22
.x
[0]);
1071 fpu
->x22
.x
[1] = SWAP_INT(fpu
->x22
.x
[1]);
1072 fpu
->x22
.x
[2] = SWAP_INT(fpu
->x22
.x
[2]);
1073 fpu
->x22
.x
[3] = SWAP_INT(fpu
->x22
.x
[3]);
1074 fpu
->x23
.x
[0] = SWAP_INT(fpu
->x23
.x
[0]);
1075 fpu
->x23
.x
[1] = SWAP_INT(fpu
->x23
.x
[1]);
1076 fpu
->x23
.x
[2] = SWAP_INT(fpu
->x23
.x
[2]);
1077 fpu
->x23
.x
[3] = SWAP_INT(fpu
->x23
.x
[3]);
1078 fpu
->x24
.x
[0] = SWAP_INT(fpu
->x24
.x
[0]);
1079 fpu
->x24
.x
[1] = SWAP_INT(fpu
->x24
.x
[1]);
1080 fpu
->x24
.x
[2] = SWAP_INT(fpu
->x24
.x
[2]);
1081 fpu
->x24
.x
[3] = SWAP_INT(fpu
->x24
.x
[3]);
1082 fpu
->x25
.x
[0] = SWAP_INT(fpu
->x25
.x
[0]);
1083 fpu
->x25
.x
[1] = SWAP_INT(fpu
->x25
.x
[1]);
1084 fpu
->x25
.x
[2] = SWAP_INT(fpu
->x25
.x
[2]);
1085 fpu
->x25
.x
[3] = SWAP_INT(fpu
->x25
.x
[3]);
1086 fpu
->x26
.x
[0] = SWAP_INT(fpu
->x26
.x
[0]);
1087 fpu
->x26
.x
[1] = SWAP_INT(fpu
->x26
.x
[1]);
1088 fpu
->x26
.x
[2] = SWAP_INT(fpu
->x26
.x
[2]);
1089 fpu
->x26
.x
[3] = SWAP_INT(fpu
->x26
.x
[3]);
1090 fpu
->x27
.x
[0] = SWAP_INT(fpu
->x27
.x
[0]);
1091 fpu
->x27
.x
[1] = SWAP_INT(fpu
->x27
.x
[1]);
1092 fpu
->x27
.x
[2] = SWAP_INT(fpu
->x27
.x
[2]);
1093 fpu
->x27
.x
[3] = SWAP_INT(fpu
->x27
.x
[3]);
1094 fpu
->x28
.x
[0] = SWAP_INT(fpu
->x28
.x
[0]);
1095 fpu
->x28
.x
[1] = SWAP_INT(fpu
->x28
.x
[1]);
1096 fpu
->x28
.x
[2] = SWAP_INT(fpu
->x28
.x
[2]);
1097 fpu
->x28
.x
[3] = SWAP_INT(fpu
->x28
.x
[3]);
1098 fpu
->x29
.x
[0] = SWAP_INT(fpu
->x29
.x
[0]);
1099 fpu
->x29
.x
[1] = SWAP_INT(fpu
->x29
.x
[1]);
1100 fpu
->x29
.x
[2] = SWAP_INT(fpu
->x29
.x
[2]);
1101 fpu
->x29
.x
[3] = SWAP_INT(fpu
->x29
.x
[3]);
1102 fpu
->x30
.x
[0] = SWAP_INT(fpu
->x30
.x
[0]);
1103 fpu
->x30
.x
[1] = SWAP_INT(fpu
->x30
.x
[1]);
1104 fpu
->x30
.x
[2] = SWAP_INT(fpu
->x30
.x
[2]);
1105 fpu
->x30
.x
[3] = SWAP_INT(fpu
->x30
.x
[3]);
1106 fpu
->x31
.x
[0] = SWAP_INT(fpu
->x31
.x
[0]);
1107 fpu
->x31
.x
[1] = SWAP_INT(fpu
->x31
.x
[1]);
1108 fpu
->x31
.x
[2] = SWAP_INT(fpu
->x31
.x
[2]);
1109 fpu
->x31
.x
[3] = SWAP_INT(fpu
->x31
.x
[3]);
1111 if(target_byte_sex
== host_byte_sex
){
1112 memcpy(&ssr
, &(fpu
->fpsr
), sizeof(struct swapped_m88k_fpsr
));
1113 ssr
.u
.word
= SWAP_INT(ssr
.u
.word
);
1114 fpu
->fpsr
.afinx
= ssr
.u
.fields
.afinx
;
1115 fpu
->fpsr
.afovf
= ssr
.u
.fields
.afovf
;
1116 fpu
->fpsr
.afunf
= ssr
.u
.fields
.afunf
;
1117 fpu
->fpsr
.afdvz
= ssr
.u
.fields
.afdvz
;
1118 fpu
->fpsr
.afinv
= ssr
.u
.fields
.afinv
;
1119 fpu
->fpsr
.xmod
= ssr
.u
.fields
.xmod
;
1121 memcpy(&scr
, &(fpu
->fpcr
), sizeof(struct swapped_m88k_fpcr
));
1122 scr
.u
.word
= SWAP_INT(scr
.u
.word
);
1123 fpu
->fpcr
.efinx
= scr
.u
.fields
.efinx
;
1124 fpu
->fpcr
.efovf
= scr
.u
.fields
.efovf
;
1125 fpu
->fpcr
.efunf
= scr
.u
.fields
.efunf
;
1126 fpu
->fpcr
.efdvz
= scr
.u
.fields
.efdvz
;
1127 fpu
->fpcr
.efinv
= scr
.u
.fields
.efinv
;
1128 fpu
->fpcr
.rm
= scr
.u
.fields
.rm
;
1131 ssr
.u
.fields
.afinx
= fpu
->fpsr
.afinx
;
1132 ssr
.u
.fields
.afovf
= fpu
->fpsr
.afovf
;
1133 ssr
.u
.fields
.afunf
= fpu
->fpsr
.afunf
;
1134 ssr
.u
.fields
.afdvz
= fpu
->fpsr
.afdvz
;
1135 ssr
.u
.fields
.afinv
= fpu
->fpsr
.afinv
;
1136 ssr
.u
.fields
.xmod
= fpu
->fpsr
.xmod
;
1137 ssr
.u
.word
= SWAP_INT(ssr
.u
.word
);
1138 memcpy(&(fpu
->fpsr
), &ssr
, sizeof(struct swapped_m88k_fpsr
));
1140 scr
.u
.fields
.efinx
= fpu
->fpcr
.efinx
;
1141 scr
.u
.fields
.efovf
= fpu
->fpcr
.efovf
;
1142 scr
.u
.fields
.efunf
= fpu
->fpcr
.efunf
;
1143 scr
.u
.fields
.efdvz
= fpu
->fpcr
.efdvz
;
1144 scr
.u
.fields
.efinv
= fpu
->fpcr
.efinv
;
1145 scr
.u
.fields
.rm
= fpu
->fpcr
.rm
;
1146 scr
.u
.word
= SWAP_INT(scr
.u
.word
);
1147 memcpy(&(fpu
->fpcr
), &scr
, sizeof(struct swapped_m88k_fpcr
));
1153 swap_m88k_thread_state_user_t(
1154 m88k_thread_state_user_t
*user
,
1155 enum byte_sex target_byte_sex
)
1158 enum byte_sex dummy
;
1159 dummy
= target_byte_sex
;
1161 user
->user
= SWAP_INT(user
->user
);
1166 swap_m88110_thread_state_impl_t(
1167 m88110_thread_state_impl_t
*spu
,
1168 enum byte_sex target_byte_sex
)
1171 enum byte_sex host_byte_sex
;
1173 struct swapped_m88110_bp_ctrl
{
1176 unsigned v
:BIT_WIDTH(0);
1177 m88110_match_t addr_match
:BITS_WIDTH(12,1);
1178 unsigned :BITS_WIDTH(26,13);
1179 unsigned rwm
:BIT_WIDTH(27);
1180 unsigned rw
:BIT_WIDTH(28);
1181 unsigned :BITS_WIDTH(31,29);
1187 struct swap_m88110_psr
{
1190 unsigned :BITS_WIDTH(1,0);
1191 unsigned mxm_dis
:BIT_WIDTH(2);
1192 unsigned sfu1dis
:BIT_WIDTH(3);
1193 unsigned :BITS_WIDTH(22,4);
1194 unsigned trace
:BIT_WIDTH(23);
1195 unsigned :BIT_WIDTH(24);
1196 unsigned sm
:BIT_WIDTH(25);
1197 unsigned sgn_imd
:BIT_WIDTH(26);
1198 unsigned :BIT_WIDTH(27);
1199 unsigned c
:BIT_WIDTH(28);
1200 unsigned se
:BIT_WIDTH(29);
1201 unsigned le
:BIT_WIDTH(30);
1202 unsigned supr
:BIT_WIDTH(31);
1208 struct swapped_m88110_fp_trap_status
{
1211 unsigned efinx
:BIT_WIDTH(0);
1212 unsigned efovf
:BIT_WIDTH(1);
1213 unsigned efunf
:BIT_WIDTH(2);
1214 unsigned efdvz
:BIT_WIDTH(3);
1215 unsigned efinv
:BIT_WIDTH(4);
1216 unsigned priv
:BIT_WIDTH(5);
1217 unsigned unimp
:BIT_WIDTH(6);
1218 unsigned int:BIT_WIDTH(7);
1219 unsigned sfu1_disabled
:BIT_WIDTH(8);
1220 unsigned :BITS_WIDTH(13,9);
1221 m88110_iresult_size_t iresult_size
:BITS_WIDTH(15,14);
1222 unsigned :BITS_WIDTH(31,16);
1228 host_byte_sex
= get_host_byte_sex();
1230 if(target_byte_sex
== host_byte_sex
){
1231 for(i
= 0; i
< M88110_N_DATA_BP
; i
++){
1232 spu
->data_bp
[i
].addr
= SWAP_INT(spu
->data_bp
[i
].addr
);
1233 memcpy(&sbpc
, &(spu
->data_bp
[i
].ctrl
),
1234 sizeof(struct swapped_m88110_bp_ctrl
));
1235 sbpc
.u
.word
= SWAP_INT(sbpc
.u
.word
);
1236 spu
->data_bp
[i
].ctrl
.v
= sbpc
.u
.fields
.v
;
1237 spu
->data_bp
[i
].ctrl
.addr_match
= sbpc
.u
.fields
.addr_match
;
1238 spu
->data_bp
[i
].ctrl
.rwm
= sbpc
.u
.fields
.rwm
;
1239 spu
->data_bp
[i
].ctrl
.rw
= sbpc
.u
.fields
.rw
;
1242 memcpy(&spsr
, &(spu
->psr
), sizeof(struct swap_m88110_psr
));
1243 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
1244 spu
->psr
.mxm_dis
= spsr
.u
.fields
.mxm_dis
;
1245 spu
->psr
.sfu1dis
= spsr
.u
.fields
.sfu1dis
;
1246 spu
->psr
.trace
= spsr
.u
.fields
.trace
;
1247 spu
->psr
.sm
= spsr
.u
.fields
.sm
;
1248 spu
->psr
.sgn_imd
= spsr
.u
.fields
.sgn_imd
;
1249 spu
->psr
.c
= spsr
.u
.fields
.c
;
1250 spu
->psr
.se
= spsr
.u
.fields
.se
;
1251 spu
->psr
.le
= spsr
.u
.fields
.le
;
1252 spu
->psr
.supr
= spsr
.u
.fields
.supr
;
1254 memcpy(&sfps
, &(spu
->fp_trap_status
),
1255 sizeof(struct swapped_m88110_fp_trap_status
));
1256 sfps
.u
.word
= SWAP_INT(sfps
.u
.word
);
1257 spu
->fp_trap_status
.efinx
= sfps
.u
.fields
.efinx
;
1258 spu
->fp_trap_status
.efovf
= sfps
.u
.fields
.efovf
;
1259 spu
->fp_trap_status
.efunf
= sfps
.u
.fields
.efunf
;
1260 spu
->fp_trap_status
.efdvz
= sfps
.u
.fields
.efdvz
;
1261 spu
->fp_trap_status
.efinv
= sfps
.u
.fields
.efinv
;
1262 spu
->fp_trap_status
.priv
= sfps
.u
.fields
.priv
;
1263 spu
->fp_trap_status
.unimp
= sfps
.u
.fields
.unimp
;
1264 spu
->fp_trap_status
.sfu1_disabled
= sfps
.u
.fields
.sfu1_disabled
;
1265 spu
->fp_trap_status
.iresult_size
= sfps
.u
.fields
.iresult_size
;
1268 for(i
= 0; i
< M88110_N_DATA_BP
; i
++){
1269 spu
->data_bp
[i
].addr
= SWAP_INT(spu
->data_bp
[i
].addr
);
1270 sbpc
.u
.fields
.v
= spu
->data_bp
[i
].ctrl
.v
;
1271 sbpc
.u
.fields
.addr_match
= spu
->data_bp
[i
].ctrl
.addr_match
;
1272 sbpc
.u
.fields
.rwm
= spu
->data_bp
[i
].ctrl
.rwm
;
1273 sbpc
.u
.fields
.rw
= spu
->data_bp
[i
].ctrl
.rw
;
1274 sbpc
.u
.word
= SWAP_INT(sbpc
.u
.word
);
1275 memcpy(&(spu
->data_bp
[i
].ctrl
), &sbpc
,
1276 sizeof(struct swapped_m88110_bp_ctrl
));
1279 spsr
.u
.fields
.mxm_dis
= spu
->psr
.mxm_dis
;
1280 spsr
.u
.fields
.sfu1dis
= spu
->psr
.sfu1dis
;
1281 spsr
.u
.fields
.trace
= spu
->psr
.trace
;
1282 spsr
.u
.fields
.sm
= spu
->psr
.sm
;
1283 spsr
.u
.fields
.sgn_imd
= spu
->psr
.sgn_imd
;
1284 spsr
.u
.fields
.c
= spu
->psr
.c
;
1285 spsr
.u
.fields
.se
= spu
->psr
.se
;
1286 spsr
.u
.fields
.le
= spu
->psr
.le
;
1287 spsr
.u
.fields
.supr
= spu
->psr
.supr
;
1288 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
1289 memcpy(&(spu
->psr
), &spsr
, sizeof(struct swap_m88110_psr
));
1291 sfps
.u
.fields
.efinx
= spu
->fp_trap_status
.efinx
;
1292 sfps
.u
.fields
.efovf
= spu
->fp_trap_status
.efovf
;
1293 sfps
.u
.fields
.efunf
= spu
->fp_trap_status
.efunf
;
1294 sfps
.u
.fields
.efdvz
= spu
->fp_trap_status
.efdvz
;
1295 sfps
.u
.fields
.efinv
= spu
->fp_trap_status
.efinv
;
1296 sfps
.u
.fields
.priv
= spu
->fp_trap_status
.priv
;
1297 sfps
.u
.fields
.unimp
= spu
->fp_trap_status
.unimp
;
1298 sfps
.u
.fields
.sfu1_disabled
= spu
->fp_trap_status
.sfu1_disabled
;
1299 sfps
.u
.fields
.iresult_size
= spu
->fp_trap_status
.iresult_size
;
1300 sfps
.u
.word
= SWAP_INT(sfps
.u
.word
);
1301 memcpy(&(spu
->fp_trap_status
), &sfps
,
1302 sizeof(struct swapped_m88110_fp_trap_status
));
1304 spu
->intermediate_result
.x
[0] =
1305 SWAP_INT(spu
->intermediate_result
.x
[0]);
1306 spu
->intermediate_result
.x
[1] =
1307 SWAP_INT(spu
->intermediate_result
.x
[1]);
1308 spu
->intermediate_result
.x
[2] =
1309 SWAP_INT(spu
->intermediate_result
.x
[2]);
1310 spu
->intermediate_result
.x
[3] =
1311 SWAP_INT(spu
->intermediate_result
.x
[3]);
1316 swap_i860_thread_state_regs(
1317 struct i860_thread_state_regs
*cpu
,
1318 enum byte_sex target_byte_sex
)
1322 enum byte_sex dummy
;
1323 dummy
= target_byte_sex
;
1326 for(i
= 0; i
< 31; i
++)
1327 cpu
->ireg
[i
] = SWAP_INT(cpu
->ireg
[i
]);
1328 for(i
= 0; i
< 30; i
++)
1329 cpu
->freg
[i
] = SWAP_INT(cpu
->freg
[i
]);
1330 cpu
->psr
= SWAP_INT(cpu
->psr
);
1331 cpu
->epsr
= SWAP_INT(cpu
->epsr
);
1332 cpu
->db
= SWAP_INT(cpu
->db
);
1333 cpu
->pc
= SWAP_INT(cpu
->pc
);
1334 cpu
->_padding_
= SWAP_INT(cpu
->_padding_
);
1335 cpu
->Mres3
= SWAP_DOUBLE(cpu
->Mres3
);
1336 cpu
->Ares3
= SWAP_DOUBLE(cpu
->Ares3
);
1337 cpu
->Mres2
= SWAP_DOUBLE(cpu
->Mres2
);
1338 cpu
->Ares2
= SWAP_DOUBLE(cpu
->Ares2
);
1339 cpu
->Mres1
= SWAP_DOUBLE(cpu
->Mres1
);
1340 cpu
->Ares1
= SWAP_DOUBLE(cpu
->Ares1
);
1341 cpu
->Ires1
= SWAP_DOUBLE(cpu
->Ires1
);
1342 cpu
->Lres3m
= SWAP_DOUBLE(cpu
->Lres3m
);
1343 cpu
->Lres2m
= SWAP_DOUBLE(cpu
->Lres2m
);
1344 cpu
->Lres1m
= SWAP_DOUBLE(cpu
->Lres1m
);
1345 cpu
->KR
= SWAP_DOUBLE(cpu
->KR
);
1346 cpu
->KI
= SWAP_DOUBLE(cpu
->KI
);
1347 cpu
->T
= SWAP_DOUBLE(cpu
->T
);
1348 cpu
->Fsr3
= SWAP_INT(cpu
->Fsr3
);
1349 cpu
->Fsr2
= SWAP_INT(cpu
->Fsr2
);
1350 cpu
->Fsr1
= SWAP_INT(cpu
->Fsr1
);
1351 cpu
->Mergelo32
= SWAP_INT(cpu
->Mergelo32
);
1352 cpu
->Mergehi32
= SWAP_INT(cpu
->Mergehi32
);
1357 swap_i386_thread_state(
1358 i386_thread_state_t
*cpu
,
1359 enum byte_sex target_byte_sex
)
1362 enum byte_sex dummy
;
1363 dummy
= target_byte_sex
;
1365 cpu
->eax
= SWAP_INT(cpu
->eax
);
1366 cpu
->ebx
= SWAP_INT(cpu
->ebx
);
1367 cpu
->ecx
= SWAP_INT(cpu
->ecx
);
1368 cpu
->edx
= SWAP_INT(cpu
->edx
);
1369 cpu
->edi
= SWAP_INT(cpu
->edi
);
1370 cpu
->esi
= SWAP_INT(cpu
->esi
);
1371 cpu
->ebp
= SWAP_INT(cpu
->ebp
);
1372 cpu
->esp
= SWAP_INT(cpu
->esp
);
1373 cpu
->ss
= SWAP_INT(cpu
->ss
);
1374 cpu
->eflags
= SWAP_INT(cpu
->eflags
);
1375 cpu
->eip
= SWAP_INT(cpu
->eip
);
1376 cpu
->cs
= SWAP_INT(cpu
->cs
);
1377 cpu
->ds
= SWAP_INT(cpu
->ds
);
1378 cpu
->es
= SWAP_INT(cpu
->es
);
1379 cpu
->fs
= SWAP_INT(cpu
->fs
);
1380 cpu
->gs
= SWAP_INT(cpu
->gs
);
1383 #ifdef x86_THREAD_STATE64
1386 swap_x86_thread_state64(
1387 x86_thread_state64_t
*cpu
,
1388 enum byte_sex target_byte_sex
)
1390 cpu
->rax
= SWAP_LONG_LONG(cpu
->rax
);
1391 cpu
->rbx
= SWAP_LONG_LONG(cpu
->rbx
);
1392 cpu
->rcx
= SWAP_LONG_LONG(cpu
->rcx
);
1393 cpu
->rdx
= SWAP_LONG_LONG(cpu
->rdx
);
1394 cpu
->rdi
= SWAP_LONG_LONG(cpu
->rdi
);
1395 cpu
->rsi
= SWAP_LONG_LONG(cpu
->rsi
);
1396 cpu
->rbp
= SWAP_LONG_LONG(cpu
->rbp
);
1397 cpu
->rsp
= SWAP_LONG_LONG(cpu
->rsp
);
1398 cpu
->rflags
= SWAP_LONG_LONG(cpu
->rflags
);
1399 cpu
->rip
= SWAP_LONG_LONG(cpu
->rip
);
1400 cpu
->r8
= SWAP_LONG_LONG(cpu
->r8
);
1401 cpu
->r9
= SWAP_LONG_LONG(cpu
->r9
);
1402 cpu
->r10
= SWAP_LONG_LONG(cpu
->r10
);
1403 cpu
->r11
= SWAP_LONG_LONG(cpu
->r11
);
1404 cpu
->r12
= SWAP_LONG_LONG(cpu
->r12
);
1405 cpu
->r13
= SWAP_LONG_LONG(cpu
->r13
);
1406 cpu
->r14
= SWAP_LONG_LONG(cpu
->r14
);
1407 cpu
->r15
= SWAP_LONG_LONG(cpu
->r15
);
1408 cpu
->cs
= SWAP_LONG_LONG(cpu
->cs
);
1409 cpu
->fs
= SWAP_LONG_LONG(cpu
->fs
);
1410 cpu
->gs
= SWAP_LONG_LONG(cpu
->gs
);
1412 #endif /* x86_THREAD_STATE64 */
1414 /* current i386 thread states */
1415 #if i386_THREAD_STATE == 1
1418 swap_i386_float_state(
1419 struct i386_float_state
*fpu
,
1420 enum byte_sex target_byte_sex
)
1422 #ifndef i386_EXCEPTION_STATE_COUNT
1423 /* this routine does nothing as their are currently no non-byte fields */
1424 #else /* defined(i386_EXCEPTION_STATE_COUNT) */
1425 struct swapped_fp_control
{
1441 unsigned short half
;
1445 struct swapped_fp_status
{
1464 unsigned short half
;
1468 enum byte_sex host_byte_sex
;
1470 host_byte_sex
= get_host_byte_sex();
1472 fpu
->fpu_reserved
[0] = SWAP_INT(fpu
->fpu_reserved
[0]);
1473 fpu
->fpu_reserved
[1] = SWAP_INT(fpu
->fpu_reserved
[1]);
1475 if(target_byte_sex
== host_byte_sex
){
1476 memcpy(&sfpc
, &(fpu
->fpu_fcw
),
1477 sizeof(struct swapped_fp_control
));
1478 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1479 fpu
->fpu_fcw
.rc
= sfpc
.u
.fields
.rc
;
1480 fpu
->fpu_fcw
.pc
= sfpc
.u
.fields
.pc
;
1481 fpu
->fpu_fcw
.precis
= sfpc
.u
.fields
.precis
;
1482 fpu
->fpu_fcw
.undfl
= sfpc
.u
.fields
.undfl
;
1483 fpu
->fpu_fcw
.ovrfl
= sfpc
.u
.fields
.ovrfl
;
1484 fpu
->fpu_fcw
.zdiv
= sfpc
.u
.fields
.zdiv
;
1485 fpu
->fpu_fcw
.denorm
= sfpc
.u
.fields
.denorm
;
1486 fpu
->fpu_fcw
.invalid
= sfpc
.u
.fields
.invalid
;
1488 memcpy(&sfps
, &(fpu
->fpu_fsw
),
1489 sizeof(struct swapped_fp_status
));
1490 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1491 fpu
->fpu_fsw
.busy
= sfps
.u
.fields
.busy
;
1492 fpu
->fpu_fsw
.c3
= sfps
.u
.fields
.c3
;
1493 fpu
->fpu_fsw
.tos
= sfps
.u
.fields
.tos
;
1494 fpu
->fpu_fsw
.c2
= sfps
.u
.fields
.c2
;
1495 fpu
->fpu_fsw
.c1
= sfps
.u
.fields
.c1
;
1496 fpu
->fpu_fsw
.c0
= sfps
.u
.fields
.c0
;
1497 fpu
->fpu_fsw
.errsumm
= sfps
.u
.fields
.errsumm
;
1498 fpu
->fpu_fsw
.stkflt
= sfps
.u
.fields
.stkflt
;
1499 fpu
->fpu_fsw
.precis
= sfps
.u
.fields
.precis
;
1500 fpu
->fpu_fsw
.undfl
= sfps
.u
.fields
.undfl
;
1501 fpu
->fpu_fsw
.ovrfl
= sfps
.u
.fields
.ovrfl
;
1502 fpu
->fpu_fsw
.zdiv
= sfps
.u
.fields
.zdiv
;
1503 fpu
->fpu_fsw
.denorm
= sfps
.u
.fields
.denorm
;
1504 fpu
->fpu_fsw
.invalid
= sfps
.u
.fields
.invalid
;
1507 sfpc
.u
.fields
.rc
= fpu
->fpu_fcw
.rc
;
1508 sfpc
.u
.fields
.pc
= fpu
->fpu_fcw
.pc
;
1509 sfpc
.u
.fields
.precis
= fpu
->fpu_fcw
.precis
;
1510 sfpc
.u
.fields
.undfl
= fpu
->fpu_fcw
.undfl
;
1511 sfpc
.u
.fields
.ovrfl
= fpu
->fpu_fcw
.ovrfl
;
1512 sfpc
.u
.fields
.zdiv
= fpu
->fpu_fcw
.zdiv
;
1513 sfpc
.u
.fields
.denorm
= fpu
->fpu_fcw
.denorm
;
1514 sfpc
.u
.fields
.invalid
= fpu
->fpu_fcw
.invalid
;
1515 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1516 memcpy(&(fpu
->fpu_fcw
), &sfpc
,
1517 sizeof(struct swapped_fp_control
));
1519 sfps
.u
.fields
.busy
= fpu
->fpu_fsw
.busy
;
1520 sfps
.u
.fields
.c3
= fpu
->fpu_fsw
.c3
;
1521 sfps
.u
.fields
.tos
= fpu
->fpu_fsw
.tos
;
1522 sfps
.u
.fields
.c2
= fpu
->fpu_fsw
.c2
;
1523 sfps
.u
.fields
.c1
= fpu
->fpu_fsw
.c1
;
1524 sfps
.u
.fields
.c0
= fpu
->fpu_fsw
.c0
;
1525 sfps
.u
.fields
.errsumm
= fpu
->fpu_fsw
.errsumm
;
1526 sfps
.u
.fields
.stkflt
= fpu
->fpu_fsw
.stkflt
;
1527 sfps
.u
.fields
.precis
= fpu
->fpu_fsw
.precis
;
1528 sfps
.u
.fields
.undfl
= fpu
->fpu_fsw
.undfl
;
1529 sfps
.u
.fields
.ovrfl
= fpu
->fpu_fsw
.ovrfl
;
1530 sfps
.u
.fields
.zdiv
= fpu
->fpu_fsw
.zdiv
;
1531 sfps
.u
.fields
.denorm
= fpu
->fpu_fsw
.denorm
;
1532 sfps
.u
.fields
.invalid
= fpu
->fpu_fsw
.invalid
;
1533 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1534 memcpy(&(fpu
->fpu_fsw
), &sfps
,
1535 sizeof(struct swapped_fp_status
));
1537 fpu
->fpu_fop
= SWAP_SHORT(fpu
->fpu_fop
);
1538 fpu
->fpu_ip
= SWAP_INT(fpu
->fpu_ip
);
1539 fpu
->fpu_cs
= SWAP_SHORT(fpu
->fpu_cs
);
1540 fpu
->fpu_rsrv2
= SWAP_SHORT(fpu
->fpu_rsrv2
);
1541 fpu
->fpu_dp
= SWAP_INT(fpu
->fpu_dp
);
1542 fpu
->fpu_ds
= SWAP_SHORT(fpu
->fpu_ds
);
1543 fpu
->fpu_rsrv3
= SWAP_SHORT(fpu
->fpu_rsrv3
);
1544 fpu
->fpu_mxcsr
= SWAP_INT(fpu
->fpu_mxcsr
);
1545 fpu
->fpu_mxcsrmask
= SWAP_INT(fpu
->fpu_mxcsrmask
);
1546 fpu
->fpu_reserved1
= SWAP_INT(fpu
->fpu_reserved1
);
1548 #endif /* defined(i386_EXCEPTION_STATE_COUNT) */
1553 swap_i386_exception_state(
1554 i386_exception_state_t
*exc
,
1555 enum byte_sex target_byte_sex
)
1557 exc
->trapno
= SWAP_INT(exc
->trapno
);
1558 exc
->err
= SWAP_INT(exc
->err
);
1559 exc
->faultvaddr
= SWAP_INT(exc
->faultvaddr
);
1562 #ifdef x86_THREAD_STATE64
1566 swap_x86_float_state64(
1567 x86_float_state64_t
*fpu
,
1568 enum byte_sex target_byte_sex
)
1570 struct swapped_fp_control
{
1586 unsigned short half
;
1590 struct swapped_fp_status
{
1609 unsigned short half
;
1613 enum byte_sex host_byte_sex
;
1615 host_byte_sex
= get_host_byte_sex();
1617 fpu
->fpu_reserved
[0] = SWAP_INT(fpu
->fpu_reserved
[0]);
1618 fpu
->fpu_reserved
[1] = SWAP_INT(fpu
->fpu_reserved
[1]);
1620 if(target_byte_sex
== host_byte_sex
){
1621 memcpy(&sfpc
, &(fpu
->fpu_fcw
),
1622 sizeof(struct swapped_fp_control
));
1623 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1624 fpu
->fpu_fcw
.rc
= sfpc
.u
.fields
.rc
;
1625 fpu
->fpu_fcw
.pc
= sfpc
.u
.fields
.pc
;
1626 fpu
->fpu_fcw
.precis
= sfpc
.u
.fields
.precis
;
1627 fpu
->fpu_fcw
.undfl
= sfpc
.u
.fields
.undfl
;
1628 fpu
->fpu_fcw
.ovrfl
= sfpc
.u
.fields
.ovrfl
;
1629 fpu
->fpu_fcw
.zdiv
= sfpc
.u
.fields
.zdiv
;
1630 fpu
->fpu_fcw
.denorm
= sfpc
.u
.fields
.denorm
;
1631 fpu
->fpu_fcw
.invalid
= sfpc
.u
.fields
.invalid
;
1633 memcpy(&sfps
, &(fpu
->fpu_fsw
),
1634 sizeof(struct swapped_fp_status
));
1635 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1636 fpu
->fpu_fsw
.busy
= sfps
.u
.fields
.busy
;
1637 fpu
->fpu_fsw
.c3
= sfps
.u
.fields
.c3
;
1638 fpu
->fpu_fsw
.tos
= sfps
.u
.fields
.tos
;
1639 fpu
->fpu_fsw
.c2
= sfps
.u
.fields
.c2
;
1640 fpu
->fpu_fsw
.c1
= sfps
.u
.fields
.c1
;
1641 fpu
->fpu_fsw
.c0
= sfps
.u
.fields
.c0
;
1642 fpu
->fpu_fsw
.errsumm
= sfps
.u
.fields
.errsumm
;
1643 fpu
->fpu_fsw
.stkflt
= sfps
.u
.fields
.stkflt
;
1644 fpu
->fpu_fsw
.precis
= sfps
.u
.fields
.precis
;
1645 fpu
->fpu_fsw
.undfl
= sfps
.u
.fields
.undfl
;
1646 fpu
->fpu_fsw
.ovrfl
= sfps
.u
.fields
.ovrfl
;
1647 fpu
->fpu_fsw
.zdiv
= sfps
.u
.fields
.zdiv
;
1648 fpu
->fpu_fsw
.denorm
= sfps
.u
.fields
.denorm
;
1649 fpu
->fpu_fsw
.invalid
= sfps
.u
.fields
.invalid
;
1652 sfpc
.u
.fields
.rc
= fpu
->fpu_fcw
.rc
;
1653 sfpc
.u
.fields
.pc
= fpu
->fpu_fcw
.pc
;
1654 sfpc
.u
.fields
.precis
= fpu
->fpu_fcw
.precis
;
1655 sfpc
.u
.fields
.undfl
= fpu
->fpu_fcw
.undfl
;
1656 sfpc
.u
.fields
.ovrfl
= fpu
->fpu_fcw
.ovrfl
;
1657 sfpc
.u
.fields
.zdiv
= fpu
->fpu_fcw
.zdiv
;
1658 sfpc
.u
.fields
.denorm
= fpu
->fpu_fcw
.denorm
;
1659 sfpc
.u
.fields
.invalid
= fpu
->fpu_fcw
.invalid
;
1660 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1661 memcpy(&(fpu
->fpu_fcw
), &sfpc
,
1662 sizeof(struct swapped_fp_control
));
1664 sfps
.u
.fields
.busy
= fpu
->fpu_fsw
.busy
;
1665 sfps
.u
.fields
.c3
= fpu
->fpu_fsw
.c3
;
1666 sfps
.u
.fields
.tos
= fpu
->fpu_fsw
.tos
;
1667 sfps
.u
.fields
.c2
= fpu
->fpu_fsw
.c2
;
1668 sfps
.u
.fields
.c1
= fpu
->fpu_fsw
.c1
;
1669 sfps
.u
.fields
.c0
= fpu
->fpu_fsw
.c0
;
1670 sfps
.u
.fields
.errsumm
= fpu
->fpu_fsw
.errsumm
;
1671 sfps
.u
.fields
.stkflt
= fpu
->fpu_fsw
.stkflt
;
1672 sfps
.u
.fields
.precis
= fpu
->fpu_fsw
.precis
;
1673 sfps
.u
.fields
.undfl
= fpu
->fpu_fsw
.undfl
;
1674 sfps
.u
.fields
.ovrfl
= fpu
->fpu_fsw
.ovrfl
;
1675 sfps
.u
.fields
.zdiv
= fpu
->fpu_fsw
.zdiv
;
1676 sfps
.u
.fields
.denorm
= fpu
->fpu_fsw
.denorm
;
1677 sfps
.u
.fields
.invalid
= fpu
->fpu_fsw
.invalid
;
1678 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1679 memcpy(&(fpu
->fpu_fsw
), &sfps
,
1680 sizeof(struct swapped_fp_status
));
1682 fpu
->fpu_fop
= SWAP_SHORT(fpu
->fpu_fop
);
1683 fpu
->fpu_ip
= SWAP_INT(fpu
->fpu_ip
);
1684 fpu
->fpu_cs
= SWAP_SHORT(fpu
->fpu_cs
);
1685 fpu
->fpu_rsrv2
= SWAP_SHORT(fpu
->fpu_rsrv2
);
1686 fpu
->fpu_dp
= SWAP_INT(fpu
->fpu_dp
);
1687 fpu
->fpu_ds
= SWAP_SHORT(fpu
->fpu_ds
);
1688 fpu
->fpu_rsrv3
= SWAP_SHORT(fpu
->fpu_rsrv3
);
1689 fpu
->fpu_mxcsr
= SWAP_INT(fpu
->fpu_mxcsr
);
1690 fpu
->fpu_mxcsrmask
= SWAP_INT(fpu
->fpu_mxcsrmask
);
1691 fpu
->fpu_reserved1
= SWAP_INT(fpu
->fpu_reserved1
);
1696 swap_x86_exception_state64(
1697 x86_exception_state64_t
*exc
,
1698 enum byte_sex target_byte_sex
)
1700 exc
->trapno
= SWAP_INT(exc
->trapno
);
1701 exc
->err
= SWAP_INT(exc
->err
);
1702 exc
->faultvaddr
= SWAP_LONG_LONG(exc
->faultvaddr
);
1707 swap_x86_debug_state32(
1708 x86_debug_state32_t
*debug
,
1709 enum byte_sex target_byte_sex
)
1711 debug
->dr0
= SWAP_INT(debug
->dr0
);
1712 debug
->dr1
= SWAP_INT(debug
->dr1
);
1713 debug
->dr2
= SWAP_INT(debug
->dr2
);
1714 debug
->dr3
= SWAP_INT(debug
->dr3
);
1715 debug
->dr4
= SWAP_INT(debug
->dr4
);
1716 debug
->dr5
= SWAP_INT(debug
->dr5
);
1717 debug
->dr6
= SWAP_INT(debug
->dr6
);
1718 debug
->dr7
= SWAP_INT(debug
->dr7
);
1723 swap_x86_debug_state64(
1724 x86_debug_state64_t
*debug
,
1725 enum byte_sex target_byte_sex
)
1727 debug
->dr0
= SWAP_LONG_LONG(debug
->dr0
);
1728 debug
->dr1
= SWAP_LONG_LONG(debug
->dr1
);
1729 debug
->dr2
= SWAP_LONG_LONG(debug
->dr2
);
1730 debug
->dr3
= SWAP_LONG_LONG(debug
->dr3
);
1731 debug
->dr4
= SWAP_LONG_LONG(debug
->dr4
);
1732 debug
->dr5
= SWAP_LONG_LONG(debug
->dr5
);
1733 debug
->dr6
= SWAP_LONG_LONG(debug
->dr6
);
1734 debug
->dr7
= SWAP_LONG_LONG(debug
->dr7
);
1740 struct x86_state_hdr
*hdr
,
1741 enum byte_sex target_byte_sex
)
1743 hdr
->flavor
= SWAP_INT(hdr
->flavor
);
1744 hdr
->count
= SWAP_INT(hdr
->count
);
1746 #endif /* x86_THREAD_STATE64 */
1748 #endif /* i386_THREAD_STATE == 1 */
1750 /* i386 thread states on older releases */
1751 #if i386_THREAD_STATE == -1
1754 swap_i386_thread_fpstate(
1755 i386_thread_fpstate_t
*fpu
,
1756 enum byte_sex target_byte_sex
)
1758 struct swapped_fp_control
{
1774 unsigned short half
;
1778 struct swapped_fp_status
{
1797 unsigned short half
;
1801 struct swapped_fp_tag
{
1814 unsigned short half
;
1818 struct swapped_fp_data_reg
{
1819 unsigned short mant
;
1820 unsigned short mant1
:16,
1825 unsigned short sign
:1,
1828 unsigned short half
;
1832 struct swapped_sel
{
1840 unsigned short half
;
1844 enum byte_sex host_byte_sex
;
1847 host_byte_sex
= get_host_byte_sex();
1849 fpu
->environ
.ip
= SWAP_INT(fpu
->environ
.ip
);
1850 fpu
->environ
.opcode
= SWAP_SHORT(fpu
->environ
.opcode
);
1851 fpu
->environ
.dp
= SWAP_INT(fpu
->environ
.dp
);
1853 if(target_byte_sex
== host_byte_sex
){
1854 memcpy(&sfpc
, &(fpu
->environ
.control
),
1855 sizeof(struct swapped_fp_control
));
1856 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1857 fpu
->environ
.control
.rc
= sfpc
.u
.fields
.rc
;
1858 fpu
->environ
.control
.pc
= sfpc
.u
.fields
.pc
;
1859 fpu
->environ
.control
.precis
= sfpc
.u
.fields
.precis
;
1860 fpu
->environ
.control
.undfl
= sfpc
.u
.fields
.undfl
;
1861 fpu
->environ
.control
.ovrfl
= sfpc
.u
.fields
.ovrfl
;
1862 fpu
->environ
.control
.zdiv
= sfpc
.u
.fields
.zdiv
;
1863 fpu
->environ
.control
.denorm
= sfpc
.u
.fields
.denorm
;
1864 fpu
->environ
.control
.invalid
= sfpc
.u
.fields
.invalid
;
1866 memcpy(&sfps
, &(fpu
->environ
.status
),
1867 sizeof(struct swapped_fp_status
));
1868 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1869 fpu
->environ
.status
.busy
= sfps
.u
.fields
.busy
;
1870 fpu
->environ
.status
.c3
= sfps
.u
.fields
.c3
;
1871 fpu
->environ
.status
.tos
= sfps
.u
.fields
.tos
;
1872 fpu
->environ
.status
.c2
= sfps
.u
.fields
.c2
;
1873 fpu
->environ
.status
.c1
= sfps
.u
.fields
.c1
;
1874 fpu
->environ
.status
.c0
= sfps
.u
.fields
.c0
;
1875 fpu
->environ
.status
.errsumm
= sfps
.u
.fields
.errsumm
;
1876 fpu
->environ
.status
.stkflt
= sfps
.u
.fields
.stkflt
;
1877 fpu
->environ
.status
.precis
= sfps
.u
.fields
.precis
;
1878 fpu
->environ
.status
.undfl
= sfps
.u
.fields
.undfl
;
1879 fpu
->environ
.status
.ovrfl
= sfps
.u
.fields
.ovrfl
;
1880 fpu
->environ
.status
.zdiv
= sfps
.u
.fields
.zdiv
;
1881 fpu
->environ
.status
.denorm
= sfps
.u
.fields
.denorm
;
1882 fpu
->environ
.status
.invalid
= sfps
.u
.fields
.invalid
;
1884 memcpy(&sfpt
, &(fpu
->environ
.tag
),
1885 sizeof(struct swapped_fp_tag
));
1886 sfpt
.u
.half
= SWAP_SHORT(sfpt
.u
.half
);
1887 fpu
->environ
.tag
.tag7
= sfpt
.u
.fields
.tag7
;
1888 fpu
->environ
.tag
.tag6
= sfpt
.u
.fields
.tag6
;
1889 fpu
->environ
.tag
.tag5
= sfpt
.u
.fields
.tag5
;
1890 fpu
->environ
.tag
.tag4
= sfpt
.u
.fields
.tag4
;
1891 fpu
->environ
.tag
.tag3
= sfpt
.u
.fields
.tag3
;
1892 fpu
->environ
.tag
.tag2
= sfpt
.u
.fields
.tag2
;
1893 fpu
->environ
.tag
.tag1
= sfpt
.u
.fields
.tag1
;
1894 fpu
->environ
.tag
.tag0
= sfpt
.u
.fields
.tag0
;
1896 memcpy(&ss
, &(fpu
->environ
.cs
),
1897 sizeof(struct swapped_sel
));
1898 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1899 fpu
->environ
.cs
.index
= ss
.u
.fields
.index
;
1900 fpu
->environ
.cs
.ti
= ss
.u
.fields
.ti
;
1901 fpu
->environ
.cs
.rpl
= ss
.u
.fields
.rpl
;
1903 memcpy(&ss
, &(fpu
->environ
.ds
),
1904 sizeof(struct swapped_sel
));
1905 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1906 fpu
->environ
.ds
.index
= ss
.u
.fields
.index
;
1907 fpu
->environ
.ds
.ti
= ss
.u
.fields
.ti
;
1908 fpu
->environ
.ds
.rpl
= ss
.u
.fields
.rpl
;
1910 for(i
= 0; i
< 8; i
++){
1911 memcpy(&sfpd
, &(fpu
->stack
.ST
[i
]),
1912 sizeof(struct swapped_fp_data_reg
));
1913 fpu
->stack
.ST
[i
].mant
= SWAP_SHORT(sfpd
.mant
);
1914 fpu
->stack
.ST
[i
].mant1
= SWAP_SHORT(sfpd
.mant1
);
1915 fpu
->stack
.ST
[i
].mant2
= SWAP_SHORT(sfpd
.mant2
);
1916 fpu
->stack
.ST
[i
].mant3
= SWAP_SHORT(sfpd
.mant3
);
1917 sfpd
.u
.half
= SWAP_SHORT(sfpd
.u
.half
);
1918 fpu
->stack
.ST
[i
].exp
= sfpd
.u
.fields
.exp
;
1919 fpu
->stack
.ST
[i
].sign
= sfpd
.u
.fields
.sign
;
1923 sfpc
.u
.fields
.rc
= fpu
->environ
.control
.rc
;
1924 sfpc
.u
.fields
.pc
= fpu
->environ
.control
.pc
;
1925 sfpc
.u
.fields
.precis
= fpu
->environ
.control
.precis
;
1926 sfpc
.u
.fields
.undfl
= fpu
->environ
.control
.undfl
;
1927 sfpc
.u
.fields
.ovrfl
= fpu
->environ
.control
.ovrfl
;
1928 sfpc
.u
.fields
.zdiv
= fpu
->environ
.control
.zdiv
;
1929 sfpc
.u
.fields
.denorm
= fpu
->environ
.control
.denorm
;
1930 sfpc
.u
.fields
.invalid
= fpu
->environ
.control
.invalid
;
1931 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1932 memcpy(&(fpu
->environ
.control
), &sfpc
,
1933 sizeof(struct swapped_fp_control
));
1935 sfps
.u
.fields
.busy
= fpu
->environ
.status
.busy
;
1936 sfps
.u
.fields
.c3
= fpu
->environ
.status
.c3
;
1937 sfps
.u
.fields
.tos
= fpu
->environ
.status
.tos
;
1938 sfps
.u
.fields
.c2
= fpu
->environ
.status
.c2
;
1939 sfps
.u
.fields
.c1
= fpu
->environ
.status
.c1
;
1940 sfps
.u
.fields
.c0
= fpu
->environ
.status
.c0
;
1941 sfps
.u
.fields
.errsumm
= fpu
->environ
.status
.errsumm
;
1942 sfps
.u
.fields
.stkflt
= fpu
->environ
.status
.stkflt
;
1943 sfps
.u
.fields
.precis
= fpu
->environ
.status
.precis
;
1944 sfps
.u
.fields
.undfl
= fpu
->environ
.status
.undfl
;
1945 sfps
.u
.fields
.ovrfl
= fpu
->environ
.status
.ovrfl
;
1946 sfps
.u
.fields
.zdiv
= fpu
->environ
.status
.zdiv
;
1947 sfps
.u
.fields
.denorm
= fpu
->environ
.status
.denorm
;
1948 sfps
.u
.fields
.invalid
= fpu
->environ
.status
.invalid
;
1949 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1950 memcpy(&(fpu
->environ
.status
), &sfps
,
1951 sizeof(struct swapped_fp_status
));
1953 sfpt
.u
.fields
.tag7
= fpu
->environ
.tag
.tag7
;
1954 sfpt
.u
.fields
.tag6
= fpu
->environ
.tag
.tag6
;
1955 sfpt
.u
.fields
.tag5
= fpu
->environ
.tag
.tag5
;
1956 sfpt
.u
.fields
.tag4
= fpu
->environ
.tag
.tag4
;
1957 sfpt
.u
.fields
.tag3
= fpu
->environ
.tag
.tag3
;
1958 sfpt
.u
.fields
.tag2
= fpu
->environ
.tag
.tag2
;
1959 sfpt
.u
.fields
.tag1
= fpu
->environ
.tag
.tag1
;
1960 sfpt
.u
.fields
.tag0
= fpu
->environ
.tag
.tag0
;
1961 sfpt
.u
.half
= SWAP_SHORT(sfpt
.u
.half
);
1962 memcpy(&(fpu
->environ
.tag
), &sfpt
,
1963 sizeof(struct swapped_fp_tag
));
1965 ss
.u
.fields
.index
= fpu
->environ
.cs
.index
;
1966 ss
.u
.fields
.ti
= fpu
->environ
.cs
.ti
;
1967 ss
.u
.fields
.rpl
= fpu
->environ
.cs
.rpl
;
1968 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1969 memcpy(&(fpu
->environ
.cs
), &ss
,
1970 sizeof(struct swapped_sel
));
1972 ss
.u
.fields
.index
= fpu
->environ
.ds
.index
;
1973 ss
.u
.fields
.ti
= fpu
->environ
.ds
.ti
;
1974 ss
.u
.fields
.rpl
= fpu
->environ
.ds
.rpl
;
1975 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1976 memcpy(&(fpu
->environ
.cs
), &ss
,
1977 sizeof(struct swapped_sel
));
1979 for(i
= 0; i
< 8; i
++){
1980 sfpd
.mant
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant
);
1981 sfpd
.mant1
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant1
);
1982 sfpd
.mant2
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant2
);
1983 sfpd
.mant3
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant3
);
1984 sfpd
.u
.fields
.exp
= fpu
->stack
.ST
[i
].exp
;
1985 sfpd
.u
.fields
.sign
= fpu
->stack
.ST
[i
].sign
;
1986 sfpd
.u
.half
= SWAP_SHORT(sfpd
.u
.half
);
1987 memcpy(&(fpu
->stack
.ST
[i
]), &sfpd
,
1988 sizeof(struct swapped_fp_data_reg
));
1995 swap_i386_thread_exceptstate(
1996 i386_thread_exceptstate_t
*exc
,
1997 enum byte_sex target_byte_sex
)
1999 struct swapped_err_code
{
2001 struct err_code_normal
{
2007 struct err_code_pgfault
{
2017 enum byte_sex host_byte_sex
;
2019 host_byte_sex
= get_host_byte_sex();
2021 exc
->trapno
= SWAP_INT(exc
->trapno
);
2022 if(exc
->trapno
== 14){
2023 if(target_byte_sex
== host_byte_sex
){
2024 memcpy(&sec
, &(exc
->err
), sizeof(struct swapped_err_code
));
2025 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2026 exc
->err
.pgfault
.user
= sec
.u
.pgfault
.user
;
2027 exc
->err
.pgfault
.wrtflt
= sec
.u
.pgfault
.wrtflt
;
2028 exc
->err
.pgfault
.prot
= sec
.u
.pgfault
.prot
;
2031 sec
.u
.pgfault
.prot
= exc
->err
.pgfault
.prot
;
2032 sec
.u
.pgfault
.wrtflt
= exc
->err
.pgfault
.wrtflt
;
2033 sec
.u
.pgfault
.user
= exc
->err
.pgfault
.user
;
2034 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2035 memcpy(&(exc
->err
), &sec
, sizeof(struct swapped_err_code
));
2039 if(target_byte_sex
== host_byte_sex
){
2040 memcpy(&sec
, &(exc
->err
), sizeof(struct swapped_err_code
));
2041 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2042 word
= sec
.u
.normal
.index
;
2043 exc
->err
.normal
.index
= SWAP_INT(word
);
2044 exc
->err
.normal
.tbl
= sec
.u
.normal
.tbl
;
2045 exc
->err
.normal
.ext
= sec
.u
.normal
.ext
;
2048 sec
.u
.normal
.ext
= exc
->err
.normal
.ext
;
2049 sec
.u
.normal
.tbl
= exc
->err
.normal
.tbl
;
2050 word
= exc
->err
.normal
.index
;
2051 sec
.u
.normal
.index
= SWAP_INT(word
);
2052 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2053 memcpy(&(exc
->err
), &sec
, sizeof(struct swapped_err_code
));
2060 swap_i386_thread_cthreadstate(
2061 i386_thread_cthreadstate_t
*user
,
2062 enum byte_sex target_byte_sex
)
2065 enum byte_sex dummy
;
2066 dummy
= target_byte_sex
;
2068 user
->self
= SWAP_INT(user
->self
);
2070 #endif /* i386_THREAD_STATE == -1 */
2074 swap_hppa_integer_thread_state(
2075 struct hp_pa_integer_thread_state
*regs
,
2076 enum byte_sex target_byte_sex
)
2079 enum byte_sex dummy
;
2080 dummy
= target_byte_sex
;
2082 regs
->ts_gr1
= SWAP_INT(regs
->ts_gr1
);
2083 regs
->ts_gr2
= SWAP_INT(regs
->ts_gr2
);
2084 regs
->ts_gr3
= SWAP_INT(regs
->ts_gr3
);
2085 regs
->ts_gr4
= SWAP_INT(regs
->ts_gr4
);
2086 regs
->ts_gr5
= SWAP_INT(regs
->ts_gr5
);
2087 regs
->ts_gr6
= SWAP_INT(regs
->ts_gr6
);
2088 regs
->ts_gr7
= SWAP_INT(regs
->ts_gr7
);
2089 regs
->ts_gr8
= SWAP_INT(regs
->ts_gr8
);
2090 regs
->ts_gr9
= SWAP_INT(regs
->ts_gr9
);
2091 regs
->ts_gr10
= SWAP_INT(regs
->ts_gr10
);
2092 regs
->ts_gr11
= SWAP_INT(regs
->ts_gr11
);
2093 regs
->ts_gr12
= SWAP_INT(regs
->ts_gr12
);
2094 regs
->ts_gr13
= SWAP_INT(regs
->ts_gr13
);
2095 regs
->ts_gr14
= SWAP_INT(regs
->ts_gr14
);
2096 regs
->ts_gr15
= SWAP_INT(regs
->ts_gr15
);
2097 regs
->ts_gr16
= SWAP_INT(regs
->ts_gr16
);
2098 regs
->ts_gr17
= SWAP_INT(regs
->ts_gr17
);
2099 regs
->ts_gr18
= SWAP_INT(regs
->ts_gr18
);
2100 regs
->ts_gr19
= SWAP_INT(regs
->ts_gr19
);
2101 regs
->ts_gr20
= SWAP_INT(regs
->ts_gr20
);
2102 regs
->ts_gr21
= SWAP_INT(regs
->ts_gr21
);
2103 regs
->ts_gr22
= SWAP_INT(regs
->ts_gr22
);
2104 regs
->ts_gr23
= SWAP_INT(regs
->ts_gr23
);
2105 regs
->ts_gr24
= SWAP_INT(regs
->ts_gr24
);
2106 regs
->ts_gr25
= SWAP_INT(regs
->ts_gr25
);
2107 regs
->ts_gr26
= SWAP_INT(regs
->ts_gr26
);
2108 regs
->ts_gr27
= SWAP_INT(regs
->ts_gr27
);
2109 regs
->ts_gr28
= SWAP_INT(regs
->ts_gr28
);
2110 regs
->ts_gr29
= SWAP_INT(regs
->ts_gr29
);
2111 regs
->ts_gr30
= SWAP_INT(regs
->ts_gr30
);
2112 regs
->ts_gr31
= SWAP_INT(regs
->ts_gr31
);
2113 regs
->ts_sr0
= SWAP_INT(regs
->ts_sr0
);
2114 regs
->ts_sr1
= SWAP_INT(regs
->ts_sr1
);
2115 regs
->ts_sr2
= SWAP_INT(regs
->ts_sr2
);
2116 regs
->ts_sr3
= SWAP_INT(regs
->ts_sr3
);
2117 regs
->ts_sar
= SWAP_INT(regs
->ts_sar
);
2121 void swap_hppa_frame_thread_state(
2122 struct hp_pa_frame_thread_state
*frame
,
2123 enum byte_sex target_byte_sex
)
2126 enum byte_sex dummy
;
2127 dummy
= target_byte_sex
;
2129 frame
->ts_pcsq_front
= SWAP_INT(frame
->ts_pcsq_front
);
2130 frame
->ts_pcsq_back
= SWAP_INT(frame
->ts_pcsq_back
);
2131 frame
->ts_pcoq_front
= SWAP_INT(frame
->ts_pcoq_front
);
2132 frame
->ts_pcoq_back
= SWAP_INT(frame
->ts_pcoq_back
);
2133 frame
->ts_psw
= SWAP_INT(frame
->ts_psw
);
2134 frame
->ts_unaligned_faults
= SWAP_INT(frame
->ts_unaligned_faults
);
2135 frame
->ts_fault_address
= SWAP_INT(frame
->ts_fault_address
);
2136 frame
->ts_step_range_start
= SWAP_INT(frame
->ts_step_range_start
);
2137 frame
->ts_step_range_stop
= SWAP_INT(frame
->ts_step_range_stop
);
2141 void swap_hppa_fp_thread_state(
2142 struct hp_pa_fp_thread_state
*fp
,
2143 enum byte_sex target_byte_sex
)
2146 enum byte_sex dummy
;
2147 dummy
= target_byte_sex
;
2149 fp
->ts_fp0
= SWAP_DOUBLE(fp
->ts_fp0
);
2150 fp
->ts_fp1
= SWAP_DOUBLE(fp
->ts_fp1
);
2151 fp
->ts_fp2
= SWAP_DOUBLE(fp
->ts_fp2
);
2152 fp
->ts_fp3
= SWAP_DOUBLE(fp
->ts_fp3
);
2153 fp
->ts_fp4
= SWAP_DOUBLE(fp
->ts_fp4
);
2154 fp
->ts_fp5
= SWAP_DOUBLE(fp
->ts_fp5
);
2155 fp
->ts_fp6
= SWAP_DOUBLE(fp
->ts_fp6
);
2156 fp
->ts_fp7
= SWAP_DOUBLE(fp
->ts_fp7
);
2157 fp
->ts_fp8
= SWAP_DOUBLE(fp
->ts_fp8
);
2158 fp
->ts_fp9
= SWAP_DOUBLE(fp
->ts_fp9
);
2159 fp
->ts_fp10
= SWAP_DOUBLE(fp
->ts_fp10
);
2160 fp
->ts_fp11
= SWAP_DOUBLE(fp
->ts_fp11
);
2161 fp
->ts_fp12
= SWAP_DOUBLE(fp
->ts_fp12
);
2162 fp
->ts_fp13
= SWAP_DOUBLE(fp
->ts_fp13
);
2163 fp
->ts_fp14
= SWAP_DOUBLE(fp
->ts_fp14
);
2164 fp
->ts_fp15
= SWAP_DOUBLE(fp
->ts_fp15
);
2165 fp
->ts_fp16
= SWAP_DOUBLE(fp
->ts_fp16
);
2166 fp
->ts_fp17
= SWAP_DOUBLE(fp
->ts_fp17
);
2167 fp
->ts_fp18
= SWAP_DOUBLE(fp
->ts_fp18
);
2168 fp
->ts_fp19
= SWAP_DOUBLE(fp
->ts_fp19
);
2169 fp
->ts_fp20
= SWAP_DOUBLE(fp
->ts_fp20
);
2170 fp
->ts_fp21
= SWAP_DOUBLE(fp
->ts_fp21
);
2171 fp
->ts_fp22
= SWAP_DOUBLE(fp
->ts_fp22
);
2172 fp
->ts_fp23
= SWAP_DOUBLE(fp
->ts_fp23
);
2173 fp
->ts_fp24
= SWAP_DOUBLE(fp
->ts_fp24
);
2174 fp
->ts_fp25
= SWAP_DOUBLE(fp
->ts_fp25
);
2175 fp
->ts_fp26
= SWAP_DOUBLE(fp
->ts_fp26
);
2176 fp
->ts_fp27
= SWAP_DOUBLE(fp
->ts_fp27
);
2177 fp
->ts_fp28
= SWAP_DOUBLE(fp
->ts_fp28
);
2178 fp
->ts_fp29
= SWAP_DOUBLE(fp
->ts_fp29
);
2179 fp
->ts_fp30
= SWAP_DOUBLE(fp
->ts_fp30
);
2180 fp
->ts_fp31
= SWAP_DOUBLE(fp
->ts_fp31
);
2185 swap_sparc_thread_state_regs(
2186 struct sparc_thread_state_regs
*cpu
,
2187 enum byte_sex target_byte_sex
)
2189 struct swapped_psr
{
2193 cwp
:BITS_WIDTH(4,0),
2197 pil
:BITS_WIDTH(11,8),
2200 reserved
:BITS_WIDTH(19,14),
2201 icc
:BITS_WIDTH(23,20),
2202 ver
:BITS_WIDTH(27,24),
2203 impl
:BITS_WIDTH(31,28);
2208 struct p_status
*pr_status
;
2209 enum byte_sex host_byte_sex
;
2211 host_byte_sex
= get_host_byte_sex();
2213 cpu
->regs
.r_pc
= SWAP_INT(cpu
->regs
.r_pc
);
2214 cpu
->regs
.r_npc
= SWAP_INT(cpu
->regs
.r_npc
);
2215 cpu
->regs
.r_y
= SWAP_INT(cpu
->regs
.r_y
);
2216 cpu
->regs
.r_g1
= SWAP_INT(cpu
->regs
.r_g1
);
2217 cpu
->regs
.r_g2
= SWAP_INT(cpu
->regs
.r_g2
);
2218 cpu
->regs
.r_g3
= SWAP_INT(cpu
->regs
.r_g3
);
2219 cpu
->regs
.r_g4
= SWAP_INT(cpu
->regs
.r_g4
);
2220 cpu
->regs
.r_g5
= SWAP_INT(cpu
->regs
.r_g5
);
2221 cpu
->regs
.r_g6
= SWAP_INT(cpu
->regs
.r_g6
);
2222 cpu
->regs
.r_g7
= SWAP_INT(cpu
->regs
.r_g7
);
2223 cpu
->regs
.r_o0
= SWAP_INT(cpu
->regs
.r_o0
);
2224 cpu
->regs
.r_o1
= SWAP_INT(cpu
->regs
.r_o1
);
2225 cpu
->regs
.r_o2
= SWAP_INT(cpu
->regs
.r_o2
);
2226 cpu
->regs
.r_o3
= SWAP_INT(cpu
->regs
.r_o3
);
2227 cpu
->regs
.r_o4
= SWAP_INT(cpu
->regs
.r_o4
);
2228 cpu
->regs
.r_o5
= SWAP_INT(cpu
->regs
.r_o5
);
2229 cpu
->regs
.r_o6
= SWAP_INT(cpu
->regs
.r_o6
);
2230 cpu
->regs
.r_o7
= SWAP_INT(cpu
->regs
.r_o7
);
2232 pr_status
= (struct p_status
*) &(cpu
->regs
.r_psr
);
2233 if(target_byte_sex
== host_byte_sex
){
2234 memcpy(&spsr
, &(cpu
->regs
.r_psr
), sizeof(struct swapped_psr
));
2235 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
2236 pr_status
->PSRREG
.psr_bits
.cwp
= spsr
.u
.fields
.cwp
;
2237 pr_status
->PSRREG
.psr_bits
.ps
= spsr
.u
.fields
.ps
;
2238 pr_status
->PSRREG
.psr_bits
.s
= spsr
.u
.fields
.s
;
2239 pr_status
->PSRREG
.psr_bits
.pil
= spsr
.u
.fields
.pil
;
2240 pr_status
->PSRREG
.psr_bits
.ef
= spsr
.u
.fields
.ef
;
2241 pr_status
->PSRREG
.psr_bits
.ec
= spsr
.u
.fields
.ec
;
2242 pr_status
->PSRREG
.psr_bits
.reserved
= spsr
.u
.fields
.reserved
;
2243 pr_status
->PSRREG
.psr_bits
.icc
= spsr
.u
.fields
.icc
;
2244 pr_status
->PSRREG
.psr_bits
.et
= spsr
.u
.fields
.ver
;
2245 pr_status
->PSRREG
.psr_bits
.impl
= spsr
.u
.fields
.impl
;
2248 spsr
.u
.fields
.cwp
= pr_status
->PSRREG
.psr_bits
.cwp
;
2249 spsr
.u
.fields
.ps
= pr_status
->PSRREG
.psr_bits
.ps
;
2250 spsr
.u
.fields
.s
= pr_status
->PSRREG
.psr_bits
.s
;
2251 spsr
.u
.fields
.pil
= pr_status
->PSRREG
.psr_bits
.pil
;
2252 spsr
.u
.fields
.ef
= pr_status
->PSRREG
.psr_bits
.ef
;
2253 spsr
.u
.fields
.ec
= pr_status
->PSRREG
.psr_bits
.ec
;
2254 spsr
.u
.fields
.reserved
= pr_status
->PSRREG
.psr_bits
.reserved
;
2255 spsr
.u
.fields
.icc
= pr_status
->PSRREG
.psr_bits
.icc
;
2256 spsr
.u
.fields
.ver
= pr_status
->PSRREG
.psr_bits
.et
;
2257 spsr
.u
.fields
.impl
= pr_status
->PSRREG
.psr_bits
.impl
;
2258 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
2259 memcpy(&(cpu
->regs
.r_psr
), &spsr
, sizeof(struct swapped_psr
));
2265 swap_sparc_thread_state_fpu(
2266 struct sparc_thread_state_fpu
*fpu
,
2267 enum byte_sex target_byte_sex
)
2269 struct swapped_fsr
{
2273 cexc
:BITS_WIDTH(4,0),
2274 aexc
:BITS_WIDTH(9,5),
2275 fcc
:BITS_WIDTH(11,10),
2278 ftt
:BITS_WIDTH(16,14),
2279 res
:BITS_WIDTH(22,17),
2280 tem
:BITS_WIDTH(27,23),
2281 rp
:BITS_WIDTH(29,28),
2282 rd
:BITS_WIDTH(31,30);
2288 struct f_status
*fpu_status
;
2289 enum byte_sex host_byte_sex
;
2291 host_byte_sex
= get_host_byte_sex();
2294 /* floating point registers */
2295 for(i
= 0; i
< 16; i
++) /* 16 doubles */
2296 fpu
->fpu
.fpu_fr
.Fpu_dregs
[i
] =
2297 SWAP_DOUBLE(fpu
->fpu
.fpu_fr
.Fpu_dregs
[i
]);
2299 fpu
->fpu
.Fpu_q
[0].FQu
.whole
= SWAP_DOUBLE(fpu
->fpu
.Fpu_q
[0].FQu
.whole
);
2300 fpu
->fpu
.Fpu_q
[1].FQu
.whole
= SWAP_DOUBLE(fpu
->fpu
.Fpu_q
[1].FQu
.whole
);
2301 fpu
->fpu
.Fpu_flags
= SWAP_INT(fpu
->fpu
.Fpu_flags
);
2302 fpu
->fpu
.Fpu_extra
= SWAP_INT(fpu
->fpu
.Fpu_extra
);
2303 fpu
->fpu
.Fpu_qcnt
= SWAP_INT(fpu
->fpu
.Fpu_qcnt
);
2305 fpu_status
= (struct f_status
*) &(fpu
->fpu
.Fpu_fsr
);
2306 if(target_byte_sex
== host_byte_sex
){
2307 memcpy(&sfsr
, &(fpu
->fpu
.Fpu_fsr
), sizeof(unsigned int));
2308 sfsr
.u
.word
= SWAP_INT(sfsr
.u
.word
);
2309 fpu_status
->FPUREG
.Fpu_fsr_bits
.rd
= sfsr
.u
.fields
.rd
;
2310 fpu_status
->FPUREG
.Fpu_fsr_bits
.rp
= sfsr
.u
.fields
.rp
;
2311 fpu_status
->FPUREG
.Fpu_fsr_bits
.tem
= sfsr
.u
.fields
.tem
;
2312 fpu_status
->FPUREG
.Fpu_fsr_bits
.res
= sfsr
.u
.fields
.res
;
2313 fpu_status
->FPUREG
.Fpu_fsr_bits
.ftt
= sfsr
.u
.fields
.ftt
;
2314 fpu_status
->FPUREG
.Fpu_fsr_bits
.qne
= sfsr
.u
.fields
.qne
;
2315 fpu_status
->FPUREG
.Fpu_fsr_bits
.pr
= sfsr
.u
.fields
.pr
;
2316 fpu_status
->FPUREG
.Fpu_fsr_bits
.fcc
= sfsr
.u
.fields
.fcc
;
2317 fpu_status
->FPUREG
.Fpu_fsr_bits
.aexc
= sfsr
.u
.fields
.aexc
;
2318 fpu_status
->FPUREG
.Fpu_fsr_bits
.cexc
= sfsr
.u
.fields
.cexc
;
2321 sfsr
.u
.fields
.rd
= fpu_status
->FPUREG
.Fpu_fsr_bits
.rd
;
2322 sfsr
.u
.fields
.rp
= fpu_status
->FPUREG
.Fpu_fsr_bits
.rp
;
2323 sfsr
.u
.fields
.tem
= fpu_status
->FPUREG
.Fpu_fsr_bits
.tem
;
2324 sfsr
.u
.fields
.res
= fpu_status
->FPUREG
.Fpu_fsr_bits
.res
;
2325 sfsr
.u
.fields
.ftt
= fpu_status
->FPUREG
.Fpu_fsr_bits
.ftt
;
2326 sfsr
.u
.fields
.qne
= fpu_status
->FPUREG
.Fpu_fsr_bits
.qne
;
2327 sfsr
.u
.fields
.pr
= fpu_status
->FPUREG
.Fpu_fsr_bits
.pr
;
2328 sfsr
.u
.fields
.fcc
= fpu_status
->FPUREG
.Fpu_fsr_bits
.fcc
;
2329 sfsr
.u
.fields
.aexc
= fpu_status
->FPUREG
.Fpu_fsr_bits
.aexc
;
2330 sfsr
.u
.fields
.cexc
= fpu_status
->FPUREG
.Fpu_fsr_bits
.cexc
;
2331 sfsr
.u
.word
= SWAP_INT(sfsr
.u
.word
);
2332 memcpy(&(fpu
->fpu
.Fpu_fsr
), &sfsr
, sizeof(struct swapped_fsr
));
2338 swap_arm_thread_state_t(
2339 arm_thread_state_t
*cpu
,
2340 enum byte_sex target_byte_sex
)
2344 for(i
= 0; i
< 13; i
++)
2345 cpu
->__r
[i
] = SWAP_INT(cpu
->__r
[i
]);
2346 cpu
->__sp
= SWAP_INT(cpu
->__sp
);
2347 cpu
->__lr
= SWAP_INT(cpu
->__lr
);
2348 cpu
->__pc
= SWAP_INT(cpu
->__pc
);
2349 cpu
->__cpsr
= SWAP_INT(cpu
->__cpsr
);
2355 struct ident_command
*id_cmd
,
2356 enum byte_sex target_byte_sex
)
2359 enum byte_sex dummy
;
2360 dummy
= target_byte_sex
;
2362 id_cmd
->cmd
= SWAP_INT(id_cmd
->cmd
);
2363 id_cmd
->cmdsize
= SWAP_INT(id_cmd
->cmdsize
);
2368 swap_routines_command(
2369 struct routines_command
*r_cmd
,
2370 enum byte_sex target_byte_sex
)
2373 enum byte_sex dummy
;
2374 dummy
= target_byte_sex
;
2376 r_cmd
->cmd
= SWAP_INT(r_cmd
->cmd
);
2377 r_cmd
->cmdsize
= SWAP_INT(r_cmd
->cmdsize
);
2378 r_cmd
->init_address
= SWAP_INT(r_cmd
->init_address
);
2379 r_cmd
->init_module
= SWAP_INT(r_cmd
->init_module
);
2380 r_cmd
->reserved1
= SWAP_INT(r_cmd
->reserved1
);
2381 r_cmd
->reserved2
= SWAP_INT(r_cmd
->reserved2
);
2382 r_cmd
->reserved3
= SWAP_INT(r_cmd
->reserved3
);
2383 r_cmd
->reserved4
= SWAP_INT(r_cmd
->reserved4
);
2384 r_cmd
->reserved5
= SWAP_INT(r_cmd
->reserved5
);
2385 r_cmd
->reserved6
= SWAP_INT(r_cmd
->reserved6
);
2390 swap_routines_command_64(
2391 struct routines_command_64
*r_cmd
,
2392 enum byte_sex target_byte_sex
)
2395 enum byte_sex dummy
;
2396 dummy
= target_byte_sex
;
2398 r_cmd
->cmd
= SWAP_INT(r_cmd
->cmd
);
2399 r_cmd
->cmdsize
= SWAP_INT(r_cmd
->cmdsize
);
2400 r_cmd
->init_address
= SWAP_LONG_LONG(r_cmd
->init_address
);
2401 r_cmd
->init_module
= SWAP_LONG_LONG(r_cmd
->init_module
);
2402 r_cmd
->reserved1
= SWAP_LONG_LONG(r_cmd
->reserved1
);
2403 r_cmd
->reserved2
= SWAP_LONG_LONG(r_cmd
->reserved2
);
2404 r_cmd
->reserved3
= SWAP_LONG_LONG(r_cmd
->reserved3
);
2405 r_cmd
->reserved4
= SWAP_LONG_LONG(r_cmd
->reserved4
);
2406 r_cmd
->reserved5
= SWAP_LONG_LONG(r_cmd
->reserved5
);
2407 r_cmd
->reserved6
= SWAP_LONG_LONG(r_cmd
->reserved6
);
2412 swap_twolevel_hints_command(
2413 struct twolevel_hints_command
*hints_cmd
,
2414 enum byte_sex target_byte_sex
)
2417 enum byte_sex dummy
;
2418 dummy
= target_byte_sex
;
2420 hints_cmd
->cmd
= SWAP_INT(hints_cmd
->cmd
);
2421 hints_cmd
->cmdsize
= SWAP_INT(hints_cmd
->cmdsize
);
2422 hints_cmd
->offset
= SWAP_INT(hints_cmd
->offset
);
2423 hints_cmd
->nhints
= SWAP_INT(hints_cmd
->nhints
);
2429 struct twolevel_hint
*hints
,
2431 enum byte_sex target_byte_sex
)
2433 struct swapped_twolevel_hint
{
2445 enum byte_sex host_byte_sex
;
2447 host_byte_sex
= get_host_byte_sex();
2449 for(i
= 0; i
< nhints
; i
++){
2450 if(target_byte_sex
== host_byte_sex
){
2451 memcpy(&shint
, hints
+ i
, sizeof(struct swapped_twolevel_hint
));
2452 shint
.u
.word
= SWAP_INT(shint
.u
.word
);
2453 hints
[i
].itoc
= shint
.u
.fields
.itoc
;
2454 hints
[i
].isub_image
= shint
.u
.fields
.isub_image
;
2457 shint
.u
.fields
.isub_image
= hints
[i
].isub_image
;
2458 shint
.u
.fields
.itoc
= hints
[i
].itoc
;
2459 shint
.u
.word
= SWAP_INT(shint
.u
.word
);
2460 memcpy(hints
+ i
, &shint
, sizeof(struct swapped_twolevel_hint
));
2467 swap_prebind_cksum_command(
2468 struct prebind_cksum_command
*cksum_cmd
,
2469 enum byte_sex target_byte_sex
)
2472 enum byte_sex dummy
;
2473 dummy
= target_byte_sex
;
2475 cksum_cmd
->cmd
= SWAP_INT(cksum_cmd
->cmd
);
2476 cksum_cmd
->cmdsize
= SWAP_INT(cksum_cmd
->cmdsize
);
2477 cksum_cmd
->cksum
= SWAP_INT(cksum_cmd
->cksum
);
2483 struct uuid_command
*uuid_cmd
,
2484 enum byte_sex target_byte_sex
)
2486 uuid_cmd
->cmd
= SWAP_INT(uuid_cmd
->cmd
);
2487 uuid_cmd
->cmdsize
= SWAP_INT(uuid_cmd
->cmdsize
);
2492 swap_linkedit_data_command(
2493 struct linkedit_data_command
*ld
,
2494 enum byte_sex target_byte_sex
)
2496 ld
->cmd
= SWAP_INT(ld
->cmd
);
2497 ld
->cmdsize
= SWAP_INT(ld
->cmdsize
);
2498 ld
->dataoff
= SWAP_INT(ld
->dataoff
);
2499 ld
->datasize
= SWAP_INT(ld
->datasize
);
2504 swap_version_min_command(
2505 struct version_min_command
*ver_cmd
,
2506 enum byte_sex target_byte_sex
)
2508 ver_cmd
->cmd
= SWAP_INT(ver_cmd
->cmd
);
2509 ver_cmd
->cmdsize
= SWAP_INT(ver_cmd
->cmdsize
);
2510 ver_cmd
->version
= SWAP_INT(ver_cmd
->version
);
2514 void swap_rpath_command(
2515 struct rpath_command
*rpath_cmd
,
2516 enum byte_sex target_byte_sex
)
2518 rpath_cmd
->cmd
= SWAP_INT(rpath_cmd
->cmd
);
2519 rpath_cmd
->cmdsize
= SWAP_INT(rpath_cmd
->cmdsize
);
2520 rpath_cmd
->path
.offset
= SWAP_INT(rpath_cmd
->path
.offset
);
2525 swap_encryption_command(
2526 struct encryption_info_command
*ec
,
2527 enum byte_sex target_byte_sex
)
2529 ec
->cmd
= SWAP_INT(ec
->cmd
);
2530 ec
->cmdsize
= SWAP_INT(ec
->cmdsize
);
2531 ec
->cryptoff
= SWAP_INT(ec
->cryptoff
);
2532 ec
->cryptsize
= SWAP_INT(ec
->cryptsize
);
2533 ec
->cryptid
= SWAP_INT(ec
->cryptid
);
2538 swap_dyld_info_command(
2539 struct dyld_info_command
*ed
,
2540 enum byte_sex target_byte_sex
)
2542 ed
->cmd
= SWAP_INT(ed
->cmd
);
2543 ed
->cmdsize
= SWAP_INT(ed
->cmdsize
);
2544 ed
->rebase_off
= SWAP_INT(ed
->rebase_off
);
2545 ed
->rebase_size
= SWAP_INT(ed
->rebase_size
);
2546 ed
->bind_off
= SWAP_INT(ed
->bind_off
);
2547 ed
->bind_size
= SWAP_INT(ed
->bind_size
);
2548 ed
->weak_bind_off
= SWAP_INT(ed
->weak_bind_off
);
2549 ed
->weak_bind_size
= SWAP_INT(ed
->weak_bind_size
);
2550 ed
->lazy_bind_off
= SWAP_INT(ed
->lazy_bind_off
);
2551 ed
->lazy_bind_size
= SWAP_INT(ed
->lazy_bind_size
);
2552 ed
->export_off
= SWAP_INT(ed
->export_off
);
2553 ed
->export_size
= SWAP_INT(ed
->export_size
);
2558 swap_entry_point_command(
2559 struct entry_point_command
*ep
,
2560 enum byte_sex target_byte_sex
)
2562 ep
->cmd
= SWAP_INT(ep
->cmd
);
2563 ep
->cmdsize
= SWAP_INT(ep
->cmdsize
);
2564 ep
->entryoff
= SWAP_LONG_LONG(ep
->entryoff
);
2565 ep
->stacksize
= SWAP_LONG_LONG(ep
->stacksize
);
2570 swap_source_version_command(
2571 struct source_version_command
*sv
,
2572 enum byte_sex target_byte_sex
)
2574 sv
->cmd
= SWAP_INT(sv
->cmd
);
2575 sv
->cmdsize
= SWAP_INT(sv
->cmdsize
);
2576 sv
->version
= SWAP_LONG_LONG(sv
->version
);
2582 struct nlist
*symbols
,
2584 enum byte_sex target_byte_sex
)
2588 enum byte_sex dummy
;
2589 dummy
= target_byte_sex
;
2592 for(i
= 0; i
< nsymbols
; i
++){
2593 symbols
[i
].n_un
.n_strx
= SWAP_INT(symbols
[i
].n_un
.n_strx
);
2596 symbols
[i
].n_desc
= SWAP_SHORT(symbols
[i
].n_desc
);
2597 symbols
[i
].n_value
= SWAP_INT(symbols
[i
].n_value
);
2604 struct nlist_64
*symbols
,
2606 enum byte_sex target_byte_sex
)
2610 enum byte_sex dummy
;
2611 dummy
= target_byte_sex
;
2614 for(i
= 0; i
< nsymbols
; i
++){
2615 symbols
[i
].n_un
.n_strx
= SWAP_INT(symbols
[i
].n_un
.n_strx
);
2618 symbols
[i
].n_desc
= SWAP_SHORT(symbols
[i
].n_desc
);
2619 symbols
[i
].n_value
= SWAP_LONG_LONG(symbols
[i
].n_value
);
2626 struct ranlib
*ranlibs
,
2628 enum byte_sex target_byte_sex
)
2632 enum byte_sex dummy
;
2633 dummy
= target_byte_sex
;
2636 for(i
= 0; i
< nranlibs
; i
++){
2637 ranlibs
[i
].ran_un
.ran_strx
= SWAP_INT(ranlibs
[i
].ran_un
.ran_strx
);
2638 ranlibs
[i
].ran_off
= SWAP_INT(ranlibs
[i
].ran_off
);
2644 swap_relocation_info(
2645 struct relocation_info
*relocs
,
2647 enum byte_sex target_byte_sex
)
2650 enum byte_sex host_byte_sex
;
2651 enum bool to_host_byte_sex
, scattered
;
2653 struct swapped_relocation_info
{
2668 struct swapped_scattered_relocation_info
{
2673 host_byte_sex
= get_host_byte_sex();
2674 to_host_byte_sex
= (enum bool)(target_byte_sex
== host_byte_sex
);
2676 for(i
= 0; i
< nrelocs
; i
++){
2677 if(to_host_byte_sex
)
2678 scattered
= (enum bool)(
2679 (SWAP_INT(relocs
[i
].r_address
) & R_SCATTERED
) != 0);
2681 scattered
= (enum bool)
2682 (((relocs
[i
].r_address
) & R_SCATTERED
) != 0);
2683 if(scattered
== FALSE
){
2684 if(to_host_byte_sex
){
2685 memcpy(&sr
, relocs
+ i
, sizeof(struct relocation_info
));
2686 sr
.r_address
= SWAP_INT(sr
.r_address
);
2687 sr
.u
.word
= SWAP_INT(sr
.u
.word
);
2688 relocs
[i
].r_address
= sr
.r_address
;
2689 relocs
[i
].r_symbolnum
= sr
.u
.fields
.r_symbolnum
;
2690 relocs
[i
].r_pcrel
= sr
.u
.fields
.r_pcrel
;
2691 relocs
[i
].r_length
= sr
.u
.fields
.r_length
;
2692 relocs
[i
].r_extern
= sr
.u
.fields
.r_extern
;
2693 relocs
[i
].r_type
= sr
.u
.fields
.r_type
;
2696 sr
.r_address
= relocs
[i
].r_address
;
2697 sr
.u
.fields
.r_symbolnum
= relocs
[i
].r_symbolnum
;
2698 sr
.u
.fields
.r_length
= relocs
[i
].r_length
;
2699 sr
.u
.fields
.r_pcrel
= relocs
[i
].r_pcrel
;
2700 sr
.u
.fields
.r_extern
= relocs
[i
].r_extern
;
2701 sr
.u
.fields
.r_type
= relocs
[i
].r_type
;
2702 sr
.r_address
= SWAP_INT(sr
.r_address
);
2703 sr
.u
.word
= SWAP_INT(sr
.u
.word
);
2704 memcpy(relocs
+ i
, &sr
, sizeof(struct relocation_info
));
2708 ssr
= (struct swapped_scattered_relocation_info
*)(relocs
+ i
);
2709 ssr
->word
= SWAP_INT(ssr
->word
);
2710 ssr
->r_value
= SWAP_INT(ssr
->r_value
);
2717 swap_indirect_symbols(
2718 uint32_t *indirect_symbols
,
2719 uint32_t nindirect_symbols
,
2720 enum byte_sex target_byte_sex
)
2724 enum byte_sex dummy
;
2725 dummy
= target_byte_sex
;
2728 for(i
= 0; i
< nindirect_symbols
; i
++)
2729 indirect_symbols
[i
] = SWAP_INT(indirect_symbols
[i
]);
2734 swap_dylib_reference(
2735 struct dylib_reference
*refs
,
2737 enum byte_sex target_byte_sex
)
2739 struct swapped_dylib_reference
{
2751 enum byte_sex host_byte_sex
;
2753 host_byte_sex
= get_host_byte_sex();
2755 for(i
= 0; i
< nrefs
; i
++){
2756 if(target_byte_sex
== host_byte_sex
){
2757 memcpy(&sref
, refs
+ i
, sizeof(struct swapped_dylib_reference
));
2758 sref
.u
.word
= SWAP_INT(sref
.u
.word
);
2759 refs
[i
].flags
= sref
.u
.fields
.flags
;
2760 refs
[i
].isym
= sref
.u
.fields
.isym
;
2763 sref
.u
.fields
.isym
= refs
[i
].isym
;
2764 sref
.u
.fields
.flags
= refs
[i
].flags
;
2765 sref
.u
.word
= SWAP_INT(sref
.u
.word
);
2766 memcpy(refs
+ i
, &sref
, sizeof(struct swapped_dylib_reference
));
2775 struct dylib_module
*mods
,
2777 enum byte_sex target_byte_sex
)
2781 enum byte_sex dummy
;
2782 dummy
= target_byte_sex
;
2785 for(i
= 0; i
< nmods
; i
++){
2786 mods
[i
].module_name
= SWAP_INT(mods
[i
].module_name
);
2787 mods
[i
].iextdefsym
= SWAP_INT(mods
[i
].iextdefsym
);
2788 mods
[i
].nextdefsym
= SWAP_INT(mods
[i
].nextdefsym
);
2789 mods
[i
].irefsym
= SWAP_INT(mods
[i
].irefsym
);
2790 mods
[i
].nrefsym
= SWAP_INT(mods
[i
].nrefsym
);
2791 mods
[i
].ilocalsym
= SWAP_INT(mods
[i
].ilocalsym
);
2792 mods
[i
].nlocalsym
= SWAP_INT(mods
[i
].nlocalsym
);
2793 mods
[i
].iextrel
= SWAP_INT(mods
[i
].iextrel
);
2794 mods
[i
].nextrel
= SWAP_INT(mods
[i
].nextrel
);
2795 mods
[i
].iinit_iterm
= SWAP_INT(mods
[i
].iinit_iterm
);
2796 mods
[i
].ninit_nterm
= SWAP_INT(mods
[i
].ninit_nterm
);
2797 mods
[i
].objc_module_info_addr
=
2798 SWAP_INT(mods
[i
].objc_module_info_addr
);
2799 mods
[i
].objc_module_info_size
=
2800 SWAP_INT(mods
[i
].objc_module_info_size
);
2806 swap_dylib_module_64(
2807 struct dylib_module_64
*mods
,
2809 enum byte_sex target_byte_sex
)
2813 enum byte_sex dummy
;
2814 dummy
= target_byte_sex
;
2817 for(i
= 0; i
< nmods
; i
++){
2818 mods
[i
].module_name
= SWAP_INT(mods
[i
].module_name
);
2819 mods
[i
].iextdefsym
= SWAP_INT(mods
[i
].iextdefsym
);
2820 mods
[i
].nextdefsym
= SWAP_INT(mods
[i
].nextdefsym
);
2821 mods
[i
].irefsym
= SWAP_INT(mods
[i
].irefsym
);
2822 mods
[i
].nrefsym
= SWAP_INT(mods
[i
].nrefsym
);
2823 mods
[i
].ilocalsym
= SWAP_INT(mods
[i
].ilocalsym
);
2824 mods
[i
].nlocalsym
= SWAP_INT(mods
[i
].nlocalsym
);
2825 mods
[i
].iextrel
= SWAP_INT(mods
[i
].iextrel
);
2826 mods
[i
].nextrel
= SWAP_INT(mods
[i
].nextrel
);
2827 mods
[i
].iinit_iterm
= SWAP_INT(mods
[i
].iinit_iterm
);
2828 mods
[i
].ninit_nterm
= SWAP_INT(mods
[i
].ninit_nterm
);
2829 mods
[i
].objc_module_info_addr
=
2830 SWAP_LONG_LONG(mods
[i
].objc_module_info_addr
);
2831 mods
[i
].objc_module_info_size
=
2832 SWAP_LONG_LONG(mods
[i
].objc_module_info_size
);
2838 swap_dylib_table_of_contents(
2839 struct dylib_table_of_contents
*tocs
,
2841 enum byte_sex target_byte_sex
)
2845 enum byte_sex dummy
;
2846 dummy
= target_byte_sex
;
2849 for(i
= 0; i
< ntocs
; i
++){
2850 tocs
[i
].symbol_index
= SWAP_INT(tocs
[i
].symbol_index
);
2851 tocs
[i
].module_index
= SWAP_INT(tocs
[i
].module_index
);