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 #include <mach/arm/thread_status.h>
204 #include <mach-o/nlist.h>
205 #include <mach-o/reloc.h>
206 #include <mach-o/ranlib.h>
207 #include "stuff/bool.h"
208 #include "stuff/bytesex.h"
270 * get_host_byte_sex() returns the enum constant for the byte sex of the host
280 s
= (BIG_ENDIAN_BYTE_SEX
<< 24) | LITTLE_ENDIAN_BYTE_SEX
;
281 return((enum byte_sex
)*((char *)&s
));
287 struct fat_header
*fat_header
,
288 enum byte_sex target_byte_sex
)
292 dummy
= target_byte_sex
;
295 fat_header
->magic
= SWAP_INT(fat_header
->magic
);
296 fat_header
->nfat_arch
= SWAP_INT(fat_header
->nfat_arch
);
302 struct fat_arch
*fat_archs
,
304 enum byte_sex target_byte_sex
)
309 dummy
= target_byte_sex
;
312 for(i
= 0; i
< nfat_arch
; i
++){
313 fat_archs
[i
].cputype
= SWAP_INT(fat_archs
[i
].cputype
);
314 fat_archs
[i
].cpusubtype
= SWAP_INT(fat_archs
[i
].cpusubtype
);
315 fat_archs
[i
].offset
= SWAP_INT(fat_archs
[i
].offset
);
316 fat_archs
[i
].size
= SWAP_INT(fat_archs
[i
].size
);
317 fat_archs
[i
].align
= SWAP_INT(fat_archs
[i
].align
);
324 struct mach_header
*mh
,
325 enum byte_sex target_byte_sex
)
329 dummy
= target_byte_sex
;
331 mh
->magic
= SWAP_INT(mh
->magic
);
332 mh
->cputype
= SWAP_INT(mh
->cputype
);
333 mh
->cpusubtype
= SWAP_INT(mh
->cpusubtype
);
334 mh
->filetype
= SWAP_INT(mh
->filetype
);
335 mh
->ncmds
= SWAP_INT(mh
->ncmds
);
336 mh
->sizeofcmds
= SWAP_INT(mh
->sizeofcmds
);
337 mh
->flags
= SWAP_INT(mh
->flags
);
343 struct mach_header_64
*mh
,
344 enum byte_sex target_byte_sex
)
348 dummy
= target_byte_sex
;
350 mh
->magic
= SWAP_INT(mh
->magic
);
351 mh
->cputype
= SWAP_INT(mh
->cputype
);
352 mh
->cpusubtype
= SWAP_INT(mh
->cpusubtype
);
353 mh
->filetype
= SWAP_INT(mh
->filetype
);
354 mh
->ncmds
= SWAP_INT(mh
->ncmds
);
355 mh
->sizeofcmds
= SWAP_INT(mh
->sizeofcmds
);
356 mh
->flags
= SWAP_INT(mh
->flags
);
357 mh
->reserved
= SWAP_INT(mh
->reserved
);
363 struct load_command
*lc
,
364 enum byte_sex target_byte_sex
)
368 dummy
= target_byte_sex
;
370 lc
->cmd
= SWAP_INT(lc
->cmd
);
371 lc
->cmdsize
= SWAP_INT(lc
->cmdsize
);
376 swap_segment_command(
377 struct segment_command
*sg
,
378 enum byte_sex target_byte_sex
)
382 dummy
= target_byte_sex
;
385 sg
->cmd
= SWAP_INT(sg
->cmd
);
386 sg
->cmdsize
= SWAP_INT(sg
->cmdsize
);
387 sg
->vmaddr
= SWAP_INT(sg
->vmaddr
);
388 sg
->vmsize
= SWAP_INT(sg
->vmsize
);
389 sg
->fileoff
= SWAP_INT(sg
->fileoff
);
390 sg
->filesize
= SWAP_INT(sg
->filesize
);
391 sg
->maxprot
= SWAP_INT(sg
->maxprot
);
392 sg
->initprot
= SWAP_INT(sg
->initprot
);
393 sg
->nsects
= SWAP_INT(sg
->nsects
);
394 sg
->flags
= SWAP_INT(sg
->flags
);
399 swap_segment_command_64(
400 struct segment_command_64
*sg
,
401 enum byte_sex target_byte_sex
)
405 dummy
= target_byte_sex
;
408 sg
->cmd
= SWAP_INT(sg
->cmd
);
409 sg
->cmdsize
= SWAP_INT(sg
->cmdsize
);
410 sg
->vmaddr
= SWAP_LONG_LONG(sg
->vmaddr
);
411 sg
->vmsize
= SWAP_LONG_LONG(sg
->vmsize
);
412 sg
->fileoff
= SWAP_LONG_LONG(sg
->fileoff
);
413 sg
->filesize
= SWAP_LONG_LONG(sg
->filesize
);
414 sg
->maxprot
= SWAP_INT(sg
->maxprot
);
415 sg
->initprot
= SWAP_INT(sg
->initprot
);
416 sg
->nsects
= SWAP_INT(sg
->nsects
);
417 sg
->flags
= SWAP_INT(sg
->flags
);
425 enum byte_sex target_byte_sex
)
430 dummy
= target_byte_sex
;
433 for(i
= 0; i
< nsects
; i
++){
436 s
[i
].addr
= SWAP_INT(s
[i
].addr
);
437 s
[i
].size
= SWAP_INT(s
[i
].size
);
438 s
[i
].offset
= SWAP_INT(s
[i
].offset
);
439 s
[i
].align
= SWAP_INT(s
[i
].align
);
440 s
[i
].reloff
= SWAP_INT(s
[i
].reloff
);
441 s
[i
].nreloc
= SWAP_INT(s
[i
].nreloc
);
442 s
[i
].flags
= SWAP_INT(s
[i
].flags
);
443 s
[i
].reserved1
= SWAP_INT(s
[i
].reserved1
);
444 s
[i
].reserved2
= SWAP_INT(s
[i
].reserved2
);
451 struct section_64
*s
,
453 enum byte_sex target_byte_sex
)
458 dummy
= target_byte_sex
;
461 for(i
= 0; i
< nsects
; i
++){
464 s
[i
].addr
= SWAP_LONG_LONG(s
[i
].addr
);
465 s
[i
].size
= SWAP_LONG_LONG(s
[i
].size
);
466 s
[i
].offset
= SWAP_INT(s
[i
].offset
);
467 s
[i
].align
= SWAP_INT(s
[i
].align
);
468 s
[i
].reloff
= SWAP_INT(s
[i
].reloff
);
469 s
[i
].nreloc
= SWAP_INT(s
[i
].nreloc
);
470 s
[i
].flags
= SWAP_INT(s
[i
].flags
);
471 s
[i
].reserved1
= SWAP_INT(s
[i
].reserved1
);
472 s
[i
].reserved2
= SWAP_INT(s
[i
].reserved2
);
479 struct symtab_command
*st
,
480 enum byte_sex target_byte_sex
)
484 dummy
= target_byte_sex
;
486 st
->cmd
= SWAP_INT(st
->cmd
);
487 st
->cmdsize
= SWAP_INT(st
->cmdsize
);
488 st
->symoff
= SWAP_INT(st
->symoff
);
489 st
->nsyms
= SWAP_INT(st
->nsyms
);
490 st
->stroff
= SWAP_INT(st
->stroff
);
491 st
->strsize
= SWAP_INT(st
->strsize
);
496 swap_dysymtab_command(
497 struct dysymtab_command
*dyst
,
498 enum byte_sex target_byte_sex
)
502 dummy
= target_byte_sex
;
504 dyst
->cmd
= SWAP_INT(dyst
->cmd
);
505 dyst
->cmdsize
= SWAP_INT(dyst
->cmdsize
);
506 dyst
->ilocalsym
= SWAP_INT(dyst
->ilocalsym
);
507 dyst
->nlocalsym
= SWAP_INT(dyst
->nlocalsym
);
508 dyst
->iextdefsym
= SWAP_INT(dyst
->iextdefsym
);
509 dyst
->nextdefsym
= SWAP_INT(dyst
->nextdefsym
);
510 dyst
->iundefsym
= SWAP_INT(dyst
->iundefsym
);
511 dyst
->nundefsym
= SWAP_INT(dyst
->nundefsym
);
512 dyst
->tocoff
= SWAP_INT(dyst
->tocoff
);
513 dyst
->ntoc
= SWAP_INT(dyst
->ntoc
);
514 dyst
->modtaboff
= SWAP_INT(dyst
->modtaboff
);
515 dyst
->nmodtab
= SWAP_INT(dyst
->nmodtab
);
516 dyst
->extrefsymoff
= SWAP_INT(dyst
->extrefsymoff
);
517 dyst
->nextrefsyms
= SWAP_INT(dyst
->nextrefsyms
);
518 dyst
->indirectsymoff
= SWAP_INT(dyst
->indirectsymoff
);
519 dyst
->nindirectsyms
= SWAP_INT(dyst
->nindirectsyms
);
520 dyst
->extreloff
= SWAP_INT(dyst
->extreloff
);
521 dyst
->nextrel
= SWAP_INT(dyst
->nextrel
);
522 dyst
->locreloff
= SWAP_INT(dyst
->locreloff
);
523 dyst
->nlocrel
= SWAP_INT(dyst
->nlocrel
);
529 struct symseg_command
*ss
,
530 enum byte_sex target_byte_sex
)
534 dummy
= target_byte_sex
;
536 ss
->cmd
= SWAP_INT(ss
->cmd
);
537 ss
->cmdsize
= SWAP_INT(ss
->cmdsize
);
538 ss
->offset
= SWAP_INT(ss
->offset
);
539 ss
->size
= SWAP_INT(ss
->size
);
545 struct fvmlib_command
*fl
,
546 enum byte_sex target_byte_sex
)
550 dummy
= target_byte_sex
;
552 fl
->cmd
= SWAP_INT(fl
->cmd
);
553 fl
->cmdsize
= SWAP_INT(fl
->cmdsize
);
554 fl
->fvmlib
.name
.offset
= SWAP_INT(fl
->fvmlib
.name
.offset
);
555 fl
->fvmlib
.minor_version
= SWAP_INT(fl
->fvmlib
.minor_version
);
556 fl
->fvmlib
.header_addr
= SWAP_INT(fl
->fvmlib
.header_addr
);
562 struct dylib_command
*dl
,
563 enum byte_sex target_byte_sex
)
567 dummy
= target_byte_sex
;
569 dl
->cmd
= SWAP_INT(dl
->cmd
);
570 dl
->cmdsize
= SWAP_INT(dl
->cmdsize
);
571 dl
->dylib
.name
.offset
= SWAP_INT(dl
->dylib
.name
.offset
);
572 dl
->dylib
.timestamp
= SWAP_INT(dl
->dylib
.timestamp
);
573 dl
->dylib
.current_version
= SWAP_INT(dl
->dylib
.current_version
);
574 dl
->dylib
.compatibility_version
=
575 SWAP_INT(dl
->dylib
.compatibility_version
);
580 swap_sub_framework_command(
581 struct sub_framework_command
*sub
,
582 enum byte_sex target_byte_sex
)
586 dummy
= target_byte_sex
;
588 sub
->cmd
= SWAP_INT(sub
->cmd
);
589 sub
->cmdsize
= SWAP_INT(sub
->cmdsize
);
590 sub
->umbrella
.offset
= SWAP_INT(sub
->umbrella
.offset
);
595 swap_sub_umbrella_command(
596 struct sub_umbrella_command
*usub
,
597 enum byte_sex target_byte_sex
)
601 dummy
= target_byte_sex
;
603 usub
->cmd
= SWAP_INT(usub
->cmd
);
604 usub
->cmdsize
= SWAP_INT(usub
->cmdsize
);
605 usub
->sub_umbrella
.offset
= SWAP_INT(usub
->sub_umbrella
.offset
);
610 swap_sub_library_command(
611 struct sub_library_command
*lsub
,
612 enum byte_sex target_byte_sex
)
616 dummy
= target_byte_sex
;
618 lsub
->cmd
= SWAP_INT(lsub
->cmd
);
619 lsub
->cmdsize
= SWAP_INT(lsub
->cmdsize
);
620 lsub
->sub_library
.offset
= SWAP_INT(lsub
->sub_library
.offset
);
625 swap_sub_client_command(
626 struct sub_client_command
*csub
,
627 enum byte_sex target_byte_sex
)
631 dummy
= target_byte_sex
;
633 csub
->cmd
= SWAP_INT(csub
->cmd
);
634 csub
->cmdsize
= SWAP_INT(csub
->cmdsize
);
635 csub
->client
.offset
= SWAP_INT(csub
->client
.offset
);
640 swap_prebound_dylib_command(
641 struct prebound_dylib_command
*pbdylib
,
642 enum byte_sex target_byte_sex
)
646 dummy
= target_byte_sex
;
648 pbdylib
->cmd
= SWAP_INT(pbdylib
->cmd
);
649 pbdylib
->cmdsize
= SWAP_INT(pbdylib
->cmdsize
);
650 pbdylib
->name
.offset
= SWAP_INT(pbdylib
->name
.offset
);
651 pbdylib
->nmodules
= SWAP_INT(pbdylib
->nmodules
);
652 pbdylib
->linked_modules
.offset
=
653 SWAP_INT(pbdylib
->linked_modules
.offset
);
658 swap_dylinker_command(
659 struct dylinker_command
*dyld
,
660 enum byte_sex target_byte_sex
)
664 dummy
= target_byte_sex
;
666 dyld
->cmd
= SWAP_INT(dyld
->cmd
);
667 dyld
->cmdsize
= SWAP_INT(dyld
->cmdsize
);
668 dyld
->name
.offset
= SWAP_INT(dyld
->name
.offset
);
673 swap_fvmfile_command(
674 struct fvmfile_command
*ff
,
675 enum byte_sex target_byte_sex
)
679 dummy
= target_byte_sex
;
681 ff
->cmd
= SWAP_INT(ff
->cmd
);
682 ff
->cmdsize
= SWAP_INT(ff
->cmdsize
);
683 ff
->name
.offset
= SWAP_INT(ff
->name
.offset
);
684 ff
->header_addr
= SWAP_INT(ff
->header_addr
);
691 struct thread_command
*ut
,
692 enum byte_sex target_byte_sex
)
696 dummy
= target_byte_sex
;
698 ut
->cmd
= SWAP_INT(ut
->cmd
);
699 ut
->cmdsize
= SWAP_INT(ut
->cmdsize
);
704 swap_m68k_thread_state_regs(
705 struct m68k_thread_state_regs
*cpu
,
706 enum byte_sex target_byte_sex
)
711 dummy
= target_byte_sex
;
714 for(i
= 0; i
< 8; i
++)
715 cpu
->dreg
[i
] = SWAP_INT(cpu
->dreg
[i
]);
716 for(i
= 0; i
< 8; i
++)
717 cpu
->areg
[i
] = SWAP_INT(cpu
->areg
[i
]);
718 cpu
->pad0
= SWAP_SHORT(cpu
->pad0
);
719 cpu
->sr
= SWAP_SHORT(cpu
->sr
);
720 cpu
->pc
= SWAP_INT(cpu
->pc
);
725 swap_m68k_thread_state_68882(
726 struct m68k_thread_state_68882
*fpu
,
727 enum byte_sex target_byte_sex
)
732 dummy
= target_byte_sex
;
735 for(i
= 0; i
< 8; i
++){
736 tmp
= SWAP_INT(fpu
->regs
[i
].fp
[0]);
737 fpu
->regs
[i
].fp
[1] = SWAP_INT(fpu
->regs
[i
].fp
[1]);
738 fpu
->regs
[i
].fp
[0] = SWAP_INT(fpu
->regs
[i
].fp
[2]);
739 fpu
->regs
[i
].fp
[2] = tmp
;
741 fpu
->cr
= SWAP_INT(fpu
->cr
);
742 fpu
->sr
= SWAP_INT(fpu
->sr
);
743 fpu
->iar
= SWAP_INT(fpu
->iar
);
744 fpu
->state
= SWAP_INT(fpu
->state
);
749 swap_m68k_thread_state_user_reg(
750 struct m68k_thread_state_user_reg
*user_reg
,
751 enum byte_sex target_byte_sex
)
755 dummy
= target_byte_sex
;
757 user_reg
->user_reg
= SWAP_INT(user_reg
->user_reg
);
762 swap_ppc_thread_state_t(
763 ppc_thread_state_t
*cpu
,
764 enum byte_sex target_byte_sex
)
766 cpu
->srr0
= SWAP_INT(cpu
->srr0
);
767 cpu
->srr1
= SWAP_INT(cpu
->srr1
);
768 cpu
->r0
= SWAP_INT(cpu
->r0
);
769 cpu
->r1
= SWAP_INT(cpu
->r1
);
770 cpu
->r2
= SWAP_INT(cpu
->r2
);
771 cpu
->r3
= SWAP_INT(cpu
->r3
);
772 cpu
->r4
= SWAP_INT(cpu
->r4
);
773 cpu
->r5
= SWAP_INT(cpu
->r5
);
774 cpu
->r6
= SWAP_INT(cpu
->r6
);
775 cpu
->r7
= SWAP_INT(cpu
->r7
);
776 cpu
->r8
= SWAP_INT(cpu
->r8
);
777 cpu
->r9
= SWAP_INT(cpu
->r9
);
778 cpu
->r10
= SWAP_INT(cpu
->r10
);
779 cpu
->r11
= SWAP_INT(cpu
->r11
);
780 cpu
->r12
= SWAP_INT(cpu
->r12
);
781 cpu
->r13
= SWAP_INT(cpu
->r13
);
782 cpu
->r14
= SWAP_INT(cpu
->r14
);
783 cpu
->r15
= SWAP_INT(cpu
->r15
);
784 cpu
->r16
= SWAP_INT(cpu
->r16
);
785 cpu
->r17
= SWAP_INT(cpu
->r17
);
786 cpu
->r18
= SWAP_INT(cpu
->r18
);
787 cpu
->r19
= SWAP_INT(cpu
->r19
);
788 cpu
->r20
= SWAP_INT(cpu
->r20
);
789 cpu
->r21
= SWAP_INT(cpu
->r21
);
790 cpu
->r22
= SWAP_INT(cpu
->r22
);
791 cpu
->r23
= SWAP_INT(cpu
->r23
);
792 cpu
->r24
= SWAP_INT(cpu
->r24
);
793 cpu
->r25
= SWAP_INT(cpu
->r25
);
794 cpu
->r26
= SWAP_INT(cpu
->r26
);
795 cpu
->r27
= SWAP_INT(cpu
->r27
);
796 cpu
->r28
= SWAP_INT(cpu
->r28
);
797 cpu
->r29
= SWAP_INT(cpu
->r29
);
798 cpu
->r30
= SWAP_INT(cpu
->r30
);
799 cpu
->r31
= SWAP_INT(cpu
->r31
);
800 cpu
->cr
= SWAP_INT(cpu
->cr
);
801 cpu
->xer
= SWAP_INT(cpu
->xer
);
802 cpu
->lr
= SWAP_INT(cpu
->lr
);
803 cpu
->ctr
= SWAP_INT(cpu
->ctr
);
804 cpu
->mq
= SWAP_INT(cpu
->mq
);
805 cpu
->vrsave
= SWAP_INT(cpu
->vrsave
);
810 swap_ppc_thread_state64_t(
811 ppc_thread_state64_t
*cpu
,
812 enum byte_sex target_byte_sex
)
814 cpu
->srr0
= SWAP_LONG_LONG(cpu
->srr0
);
815 cpu
->srr1
= SWAP_LONG_LONG(cpu
->srr1
);
816 cpu
->r0
= SWAP_LONG_LONG(cpu
->r0
);
817 cpu
->r1
= SWAP_LONG_LONG(cpu
->r1
);
818 cpu
->r2
= SWAP_LONG_LONG(cpu
->r2
);
819 cpu
->r3
= SWAP_LONG_LONG(cpu
->r3
);
820 cpu
->r4
= SWAP_LONG_LONG(cpu
->r4
);
821 cpu
->r5
= SWAP_LONG_LONG(cpu
->r5
);
822 cpu
->r6
= SWAP_LONG_LONG(cpu
->r6
);
823 cpu
->r7
= SWAP_LONG_LONG(cpu
->r7
);
824 cpu
->r8
= SWAP_LONG_LONG(cpu
->r8
);
825 cpu
->r9
= SWAP_LONG_LONG(cpu
->r9
);
826 cpu
->r10
= SWAP_LONG_LONG(cpu
->r10
);
827 cpu
->r11
= SWAP_LONG_LONG(cpu
->r11
);
828 cpu
->r12
= SWAP_LONG_LONG(cpu
->r12
);
829 cpu
->r13
= SWAP_LONG_LONG(cpu
->r13
);
830 cpu
->r14
= SWAP_LONG_LONG(cpu
->r14
);
831 cpu
->r15
= SWAP_LONG_LONG(cpu
->r15
);
832 cpu
->r16
= SWAP_LONG_LONG(cpu
->r16
);
833 cpu
->r17
= SWAP_LONG_LONG(cpu
->r17
);
834 cpu
->r18
= SWAP_LONG_LONG(cpu
->r18
);
835 cpu
->r19
= SWAP_LONG_LONG(cpu
->r19
);
836 cpu
->r20
= SWAP_LONG_LONG(cpu
->r20
);
837 cpu
->r21
= SWAP_LONG_LONG(cpu
->r21
);
838 cpu
->r22
= SWAP_LONG_LONG(cpu
->r22
);
839 cpu
->r23
= SWAP_LONG_LONG(cpu
->r23
);
840 cpu
->r24
= SWAP_LONG_LONG(cpu
->r24
);
841 cpu
->r25
= SWAP_LONG_LONG(cpu
->r25
);
842 cpu
->r26
= SWAP_LONG_LONG(cpu
->r26
);
843 cpu
->r27
= SWAP_LONG_LONG(cpu
->r27
);
844 cpu
->r28
= SWAP_LONG_LONG(cpu
->r28
);
845 cpu
->r29
= SWAP_LONG_LONG(cpu
->r29
);
846 cpu
->r30
= SWAP_LONG_LONG(cpu
->r30
);
847 cpu
->r31
= SWAP_LONG_LONG(cpu
->r31
);
848 cpu
->cr
= SWAP_INT(cpu
->cr
);
849 cpu
->xer
= SWAP_LONG_LONG(cpu
->xer
);
850 cpu
->lr
= SWAP_LONG_LONG(cpu
->lr
);
851 cpu
->ctr
= SWAP_LONG_LONG(cpu
->ctr
);
852 cpu
->vrsave
= SWAP_INT(cpu
->vrsave
);
857 swap_ppc_float_state_t(
858 ppc_float_state_t
*fpu
,
859 enum byte_sex target_byte_sex
)
864 dummy
= target_byte_sex
;
867 for(i
= 0; i
< 32; i
++)
868 fpu
->fpregs
[i
] = SWAP_DOUBLE(fpu
->fpregs
[i
]);
870 fpu
->fpscr_pad
= SWAP_INT(fpu
->fpscr_pad
);
871 fpu
->fpscr
= SWAP_INT(fpu
->fpscr
);
876 swap_ppc_exception_state_t(
877 ppc_exception_state_t
*state
,
878 enum byte_sex target_byte_sex
)
883 dummy
= target_byte_sex
;
886 state
->dar
= SWAP_INT(state
->dar
);
887 state
->dsisr
= SWAP_INT(state
->dsisr
);
888 state
->exception
= SWAP_INT(state
->exception
);
889 state
->pad0
= SWAP_INT(state
->pad0
);
891 for(i
= 0; i
< 4; i
++)
892 state
->pad1
[i
] = SWAP_INT(state
->pad1
[i
]);
897 swap_m88k_thread_state_grf_t(
898 m88k_thread_state_grf_t
*cpu
,
899 enum byte_sex target_byte_sex
)
903 dummy
= target_byte_sex
;
905 cpu
->r1
= SWAP_INT(cpu
->r1
);
906 cpu
->r2
= SWAP_INT(cpu
->r2
);
907 cpu
->r3
= SWAP_INT(cpu
->r3
);
908 cpu
->r4
= SWAP_INT(cpu
->r4
);
909 cpu
->r5
= SWAP_INT(cpu
->r5
);
910 cpu
->r6
= SWAP_INT(cpu
->r6
);
911 cpu
->r7
= SWAP_INT(cpu
->r7
);
912 cpu
->r8
= SWAP_INT(cpu
->r8
);
913 cpu
->r9
= SWAP_INT(cpu
->r9
);
914 cpu
->r10
= SWAP_INT(cpu
->r10
);
915 cpu
->r11
= SWAP_INT(cpu
->r11
);
916 cpu
->r12
= SWAP_INT(cpu
->r12
);
917 cpu
->r13
= SWAP_INT(cpu
->r13
);
918 cpu
->r14
= SWAP_INT(cpu
->r14
);
919 cpu
->r15
= SWAP_INT(cpu
->r15
);
920 cpu
->r16
= SWAP_INT(cpu
->r16
);
921 cpu
->r17
= SWAP_INT(cpu
->r17
);
922 cpu
->r18
= SWAP_INT(cpu
->r18
);
923 cpu
->r19
= SWAP_INT(cpu
->r19
);
924 cpu
->r20
= SWAP_INT(cpu
->r20
);
925 cpu
->r21
= SWAP_INT(cpu
->r21
);
926 cpu
->r22
= SWAP_INT(cpu
->r22
);
927 cpu
->r23
= SWAP_INT(cpu
->r23
);
928 cpu
->r24
= SWAP_INT(cpu
->r24
);
929 cpu
->r25
= SWAP_INT(cpu
->r25
);
930 cpu
->r26
= SWAP_INT(cpu
->r26
);
931 cpu
->r27
= SWAP_INT(cpu
->r27
);
932 cpu
->r28
= SWAP_INT(cpu
->r28
);
933 cpu
->r29
= SWAP_INT(cpu
->r29
);
934 cpu
->r30
= SWAP_INT(cpu
->r30
);
935 cpu
->r31
= SWAP_INT(cpu
->r31
);
936 cpu
->xip
= SWAP_INT(cpu
->xip
);
937 cpu
->xip_in_bd
= SWAP_INT(cpu
->xip_in_bd
);
938 cpu
->nip
= SWAP_INT(cpu
->nip
);
943 swap_m88k_thread_state_xrf_t(
944 m88k_thread_state_xrf_t
*fpu
,
945 enum byte_sex target_byte_sex
)
947 enum byte_sex host_byte_sex
;
949 struct swapped_m88k_fpsr
{
952 unsigned afinx
:BIT_WIDTH(0);
953 unsigned afovf
:BIT_WIDTH(1);
954 unsigned afunf
:BIT_WIDTH(2);
955 unsigned afdvz
:BIT_WIDTH(3);
956 unsigned afinv
:BIT_WIDTH(4);
957 unsigned :BITS_WIDTH(15,5);
958 unsigned xmod
:BIT_WIDTH(16);
959 unsigned :BITS_WIDTH(31,17);
964 struct swapped_m88k_fpcr
{
967 unsigned efinx
:BIT_WIDTH(0);
968 unsigned efovf
:BIT_WIDTH(1);
969 unsigned efunf
:BIT_WIDTH(2);
970 unsigned efdvz
:BIT_WIDTH(3);
971 unsigned efinv
:BIT_WIDTH(4);
972 unsigned :BITS_WIDTH(13,5);
973 m88k_fpcr_rm_t rm
:BITS_WIDTH(15,14);
974 unsigned :BITS_WIDTH(31,16);
980 host_byte_sex
= get_host_byte_sex();
982 fpu
->x1
.x
[0] = SWAP_INT(fpu
->x1
.x
[0]);
983 fpu
->x1
.x
[1] = SWAP_INT(fpu
->x1
.x
[1]);
984 fpu
->x1
.x
[2] = SWAP_INT(fpu
->x1
.x
[2]);
985 fpu
->x1
.x
[3] = SWAP_INT(fpu
->x1
.x
[3]);
986 fpu
->x2
.x
[0] = SWAP_INT(fpu
->x2
.x
[0]);
987 fpu
->x2
.x
[1] = SWAP_INT(fpu
->x2
.x
[1]);
988 fpu
->x2
.x
[2] = SWAP_INT(fpu
->x2
.x
[2]);
989 fpu
->x2
.x
[3] = SWAP_INT(fpu
->x2
.x
[3]);
990 fpu
->x3
.x
[0] = SWAP_INT(fpu
->x3
.x
[0]);
991 fpu
->x3
.x
[1] = SWAP_INT(fpu
->x3
.x
[1]);
992 fpu
->x3
.x
[2] = SWAP_INT(fpu
->x3
.x
[2]);
993 fpu
->x3
.x
[3] = SWAP_INT(fpu
->x3
.x
[3]);
994 fpu
->x4
.x
[0] = SWAP_INT(fpu
->x4
.x
[0]);
995 fpu
->x4
.x
[1] = SWAP_INT(fpu
->x4
.x
[1]);
996 fpu
->x4
.x
[2] = SWAP_INT(fpu
->x4
.x
[2]);
997 fpu
->x4
.x
[3] = SWAP_INT(fpu
->x4
.x
[3]);
998 fpu
->x5
.x
[0] = SWAP_INT(fpu
->x5
.x
[0]);
999 fpu
->x5
.x
[1] = SWAP_INT(fpu
->x5
.x
[1]);
1000 fpu
->x5
.x
[2] = SWAP_INT(fpu
->x5
.x
[2]);
1001 fpu
->x5
.x
[3] = SWAP_INT(fpu
->x5
.x
[3]);
1002 fpu
->x6
.x
[0] = SWAP_INT(fpu
->x6
.x
[0]);
1003 fpu
->x6
.x
[1] = SWAP_INT(fpu
->x6
.x
[1]);
1004 fpu
->x6
.x
[2] = SWAP_INT(fpu
->x6
.x
[2]);
1005 fpu
->x6
.x
[3] = SWAP_INT(fpu
->x6
.x
[3]);
1006 fpu
->x7
.x
[0] = SWAP_INT(fpu
->x7
.x
[0]);
1007 fpu
->x7
.x
[1] = SWAP_INT(fpu
->x7
.x
[1]);
1008 fpu
->x7
.x
[2] = SWAP_INT(fpu
->x7
.x
[2]);
1009 fpu
->x7
.x
[3] = SWAP_INT(fpu
->x7
.x
[3]);
1010 fpu
->x8
.x
[0] = SWAP_INT(fpu
->x8
.x
[0]);
1011 fpu
->x8
.x
[1] = SWAP_INT(fpu
->x8
.x
[1]);
1012 fpu
->x8
.x
[2] = SWAP_INT(fpu
->x8
.x
[2]);
1013 fpu
->x8
.x
[3] = SWAP_INT(fpu
->x8
.x
[3]);
1014 fpu
->x9
.x
[0] = SWAP_INT(fpu
->x9
.x
[0]);
1015 fpu
->x9
.x
[1] = SWAP_INT(fpu
->x9
.x
[1]);
1016 fpu
->x9
.x
[2] = SWAP_INT(fpu
->x9
.x
[2]);
1017 fpu
->x9
.x
[3] = SWAP_INT(fpu
->x9
.x
[3]);
1018 fpu
->x10
.x
[0] = SWAP_INT(fpu
->x10
.x
[0]);
1019 fpu
->x10
.x
[1] = SWAP_INT(fpu
->x10
.x
[1]);
1020 fpu
->x10
.x
[2] = SWAP_INT(fpu
->x10
.x
[2]);
1021 fpu
->x10
.x
[3] = SWAP_INT(fpu
->x10
.x
[3]);
1022 fpu
->x11
.x
[0] = SWAP_INT(fpu
->x11
.x
[0]);
1023 fpu
->x11
.x
[1] = SWAP_INT(fpu
->x11
.x
[1]);
1024 fpu
->x11
.x
[2] = SWAP_INT(fpu
->x11
.x
[2]);
1025 fpu
->x11
.x
[3] = SWAP_INT(fpu
->x11
.x
[3]);
1026 fpu
->x12
.x
[0] = SWAP_INT(fpu
->x12
.x
[0]);
1027 fpu
->x12
.x
[1] = SWAP_INT(fpu
->x12
.x
[1]);
1028 fpu
->x12
.x
[2] = SWAP_INT(fpu
->x12
.x
[2]);
1029 fpu
->x12
.x
[3] = SWAP_INT(fpu
->x12
.x
[3]);
1030 fpu
->x13
.x
[0] = SWAP_INT(fpu
->x13
.x
[0]);
1031 fpu
->x13
.x
[1] = SWAP_INT(fpu
->x13
.x
[1]);
1032 fpu
->x13
.x
[2] = SWAP_INT(fpu
->x13
.x
[2]);
1033 fpu
->x13
.x
[3] = SWAP_INT(fpu
->x13
.x
[3]);
1034 fpu
->x14
.x
[0] = SWAP_INT(fpu
->x14
.x
[0]);
1035 fpu
->x14
.x
[1] = SWAP_INT(fpu
->x14
.x
[1]);
1036 fpu
->x14
.x
[2] = SWAP_INT(fpu
->x14
.x
[2]);
1037 fpu
->x14
.x
[3] = SWAP_INT(fpu
->x14
.x
[3]);
1038 fpu
->x15
.x
[0] = SWAP_INT(fpu
->x15
.x
[0]);
1039 fpu
->x15
.x
[1] = SWAP_INT(fpu
->x15
.x
[1]);
1040 fpu
->x15
.x
[2] = SWAP_INT(fpu
->x15
.x
[2]);
1041 fpu
->x15
.x
[3] = SWAP_INT(fpu
->x15
.x
[3]);
1042 fpu
->x16
.x
[0] = SWAP_INT(fpu
->x16
.x
[0]);
1043 fpu
->x16
.x
[1] = SWAP_INT(fpu
->x16
.x
[1]);
1044 fpu
->x16
.x
[2] = SWAP_INT(fpu
->x16
.x
[2]);
1045 fpu
->x16
.x
[3] = SWAP_INT(fpu
->x16
.x
[3]);
1046 fpu
->x17
.x
[0] = SWAP_INT(fpu
->x17
.x
[0]);
1047 fpu
->x17
.x
[1] = SWAP_INT(fpu
->x17
.x
[1]);
1048 fpu
->x17
.x
[2] = SWAP_INT(fpu
->x17
.x
[2]);
1049 fpu
->x17
.x
[3] = SWAP_INT(fpu
->x17
.x
[3]);
1050 fpu
->x18
.x
[0] = SWAP_INT(fpu
->x18
.x
[0]);
1051 fpu
->x18
.x
[1] = SWAP_INT(fpu
->x18
.x
[1]);
1052 fpu
->x18
.x
[2] = SWAP_INT(fpu
->x18
.x
[2]);
1053 fpu
->x18
.x
[3] = SWAP_INT(fpu
->x18
.x
[3]);
1054 fpu
->x19
.x
[0] = SWAP_INT(fpu
->x19
.x
[0]);
1055 fpu
->x19
.x
[1] = SWAP_INT(fpu
->x19
.x
[1]);
1056 fpu
->x19
.x
[2] = SWAP_INT(fpu
->x19
.x
[2]);
1057 fpu
->x19
.x
[3] = SWAP_INT(fpu
->x19
.x
[3]);
1058 fpu
->x20
.x
[0] = SWAP_INT(fpu
->x20
.x
[0]);
1059 fpu
->x20
.x
[1] = SWAP_INT(fpu
->x20
.x
[1]);
1060 fpu
->x20
.x
[2] = SWAP_INT(fpu
->x20
.x
[2]);
1061 fpu
->x20
.x
[3] = SWAP_INT(fpu
->x20
.x
[3]);
1062 fpu
->x21
.x
[0] = SWAP_INT(fpu
->x21
.x
[0]);
1063 fpu
->x21
.x
[1] = SWAP_INT(fpu
->x21
.x
[1]);
1064 fpu
->x21
.x
[2] = SWAP_INT(fpu
->x21
.x
[2]);
1065 fpu
->x21
.x
[3] = SWAP_INT(fpu
->x21
.x
[3]);
1066 fpu
->x22
.x
[0] = SWAP_INT(fpu
->x22
.x
[0]);
1067 fpu
->x22
.x
[1] = SWAP_INT(fpu
->x22
.x
[1]);
1068 fpu
->x22
.x
[2] = SWAP_INT(fpu
->x22
.x
[2]);
1069 fpu
->x22
.x
[3] = SWAP_INT(fpu
->x22
.x
[3]);
1070 fpu
->x23
.x
[0] = SWAP_INT(fpu
->x23
.x
[0]);
1071 fpu
->x23
.x
[1] = SWAP_INT(fpu
->x23
.x
[1]);
1072 fpu
->x23
.x
[2] = SWAP_INT(fpu
->x23
.x
[2]);
1073 fpu
->x23
.x
[3] = SWAP_INT(fpu
->x23
.x
[3]);
1074 fpu
->x24
.x
[0] = SWAP_INT(fpu
->x24
.x
[0]);
1075 fpu
->x24
.x
[1] = SWAP_INT(fpu
->x24
.x
[1]);
1076 fpu
->x24
.x
[2] = SWAP_INT(fpu
->x24
.x
[2]);
1077 fpu
->x24
.x
[3] = SWAP_INT(fpu
->x24
.x
[3]);
1078 fpu
->x25
.x
[0] = SWAP_INT(fpu
->x25
.x
[0]);
1079 fpu
->x25
.x
[1] = SWAP_INT(fpu
->x25
.x
[1]);
1080 fpu
->x25
.x
[2] = SWAP_INT(fpu
->x25
.x
[2]);
1081 fpu
->x25
.x
[3] = SWAP_INT(fpu
->x25
.x
[3]);
1082 fpu
->x26
.x
[0] = SWAP_INT(fpu
->x26
.x
[0]);
1083 fpu
->x26
.x
[1] = SWAP_INT(fpu
->x26
.x
[1]);
1084 fpu
->x26
.x
[2] = SWAP_INT(fpu
->x26
.x
[2]);
1085 fpu
->x26
.x
[3] = SWAP_INT(fpu
->x26
.x
[3]);
1086 fpu
->x27
.x
[0] = SWAP_INT(fpu
->x27
.x
[0]);
1087 fpu
->x27
.x
[1] = SWAP_INT(fpu
->x27
.x
[1]);
1088 fpu
->x27
.x
[2] = SWAP_INT(fpu
->x27
.x
[2]);
1089 fpu
->x27
.x
[3] = SWAP_INT(fpu
->x27
.x
[3]);
1090 fpu
->x28
.x
[0] = SWAP_INT(fpu
->x28
.x
[0]);
1091 fpu
->x28
.x
[1] = SWAP_INT(fpu
->x28
.x
[1]);
1092 fpu
->x28
.x
[2] = SWAP_INT(fpu
->x28
.x
[2]);
1093 fpu
->x28
.x
[3] = SWAP_INT(fpu
->x28
.x
[3]);
1094 fpu
->x29
.x
[0] = SWAP_INT(fpu
->x29
.x
[0]);
1095 fpu
->x29
.x
[1] = SWAP_INT(fpu
->x29
.x
[1]);
1096 fpu
->x29
.x
[2] = SWAP_INT(fpu
->x29
.x
[2]);
1097 fpu
->x29
.x
[3] = SWAP_INT(fpu
->x29
.x
[3]);
1098 fpu
->x30
.x
[0] = SWAP_INT(fpu
->x30
.x
[0]);
1099 fpu
->x30
.x
[1] = SWAP_INT(fpu
->x30
.x
[1]);
1100 fpu
->x30
.x
[2] = SWAP_INT(fpu
->x30
.x
[2]);
1101 fpu
->x30
.x
[3] = SWAP_INT(fpu
->x30
.x
[3]);
1102 fpu
->x31
.x
[0] = SWAP_INT(fpu
->x31
.x
[0]);
1103 fpu
->x31
.x
[1] = SWAP_INT(fpu
->x31
.x
[1]);
1104 fpu
->x31
.x
[2] = SWAP_INT(fpu
->x31
.x
[2]);
1105 fpu
->x31
.x
[3] = SWAP_INT(fpu
->x31
.x
[3]);
1107 if(target_byte_sex
== host_byte_sex
){
1108 memcpy(&ssr
, &(fpu
->fpsr
), sizeof(struct swapped_m88k_fpsr
));
1109 ssr
.u
.word
= SWAP_INT(ssr
.u
.word
);
1110 fpu
->fpsr
.afinx
= ssr
.u
.fields
.afinx
;
1111 fpu
->fpsr
.afovf
= ssr
.u
.fields
.afovf
;
1112 fpu
->fpsr
.afunf
= ssr
.u
.fields
.afunf
;
1113 fpu
->fpsr
.afdvz
= ssr
.u
.fields
.afdvz
;
1114 fpu
->fpsr
.afinv
= ssr
.u
.fields
.afinv
;
1115 fpu
->fpsr
.xmod
= ssr
.u
.fields
.xmod
;
1117 memcpy(&scr
, &(fpu
->fpcr
), sizeof(struct swapped_m88k_fpcr
));
1118 scr
.u
.word
= SWAP_INT(scr
.u
.word
);
1119 fpu
->fpcr
.efinx
= scr
.u
.fields
.efinx
;
1120 fpu
->fpcr
.efovf
= scr
.u
.fields
.efovf
;
1121 fpu
->fpcr
.efunf
= scr
.u
.fields
.efunf
;
1122 fpu
->fpcr
.efdvz
= scr
.u
.fields
.efdvz
;
1123 fpu
->fpcr
.efinv
= scr
.u
.fields
.efinv
;
1124 fpu
->fpcr
.rm
= scr
.u
.fields
.rm
;
1127 ssr
.u
.fields
.afinx
= fpu
->fpsr
.afinx
;
1128 ssr
.u
.fields
.afovf
= fpu
->fpsr
.afovf
;
1129 ssr
.u
.fields
.afunf
= fpu
->fpsr
.afunf
;
1130 ssr
.u
.fields
.afdvz
= fpu
->fpsr
.afdvz
;
1131 ssr
.u
.fields
.afinv
= fpu
->fpsr
.afinv
;
1132 ssr
.u
.fields
.xmod
= fpu
->fpsr
.xmod
;
1133 ssr
.u
.word
= SWAP_INT(ssr
.u
.word
);
1134 memcpy(&(fpu
->fpsr
), &ssr
, sizeof(struct swapped_m88k_fpsr
));
1136 scr
.u
.fields
.efinx
= fpu
->fpcr
.efinx
;
1137 scr
.u
.fields
.efovf
= fpu
->fpcr
.efovf
;
1138 scr
.u
.fields
.efunf
= fpu
->fpcr
.efunf
;
1139 scr
.u
.fields
.efdvz
= fpu
->fpcr
.efdvz
;
1140 scr
.u
.fields
.efinv
= fpu
->fpcr
.efinv
;
1141 scr
.u
.fields
.rm
= fpu
->fpcr
.rm
;
1142 scr
.u
.word
= SWAP_INT(scr
.u
.word
);
1143 memcpy(&(fpu
->fpcr
), &scr
, sizeof(struct swapped_m88k_fpcr
));
1149 swap_m88k_thread_state_user_t(
1150 m88k_thread_state_user_t
*user
,
1151 enum byte_sex target_byte_sex
)
1154 enum byte_sex dummy
;
1155 dummy
= target_byte_sex
;
1157 user
->user
= SWAP_INT(user
->user
);
1162 swap_m88110_thread_state_impl_t(
1163 m88110_thread_state_impl_t
*spu
,
1164 enum byte_sex target_byte_sex
)
1167 enum byte_sex host_byte_sex
;
1169 struct swapped_m88110_bp_ctrl
{
1172 unsigned v
:BIT_WIDTH(0);
1173 m88110_match_t addr_match
:BITS_WIDTH(12,1);
1174 unsigned :BITS_WIDTH(26,13);
1175 unsigned rwm
:BIT_WIDTH(27);
1176 unsigned rw
:BIT_WIDTH(28);
1177 unsigned :BITS_WIDTH(31,29);
1183 struct swap_m88110_psr
{
1186 unsigned :BITS_WIDTH(1,0);
1187 unsigned mxm_dis
:BIT_WIDTH(2);
1188 unsigned sfu1dis
:BIT_WIDTH(3);
1189 unsigned :BITS_WIDTH(22,4);
1190 unsigned trace
:BIT_WIDTH(23);
1191 unsigned :BIT_WIDTH(24);
1192 unsigned sm
:BIT_WIDTH(25);
1193 unsigned sgn_imd
:BIT_WIDTH(26);
1194 unsigned :BIT_WIDTH(27);
1195 unsigned c
:BIT_WIDTH(28);
1196 unsigned se
:BIT_WIDTH(29);
1197 unsigned le
:BIT_WIDTH(30);
1198 unsigned supr
:BIT_WIDTH(31);
1204 struct swapped_m88110_fp_trap_status
{
1207 unsigned efinx
:BIT_WIDTH(0);
1208 unsigned efovf
:BIT_WIDTH(1);
1209 unsigned efunf
:BIT_WIDTH(2);
1210 unsigned efdvz
:BIT_WIDTH(3);
1211 unsigned efinv
:BIT_WIDTH(4);
1212 unsigned priv
:BIT_WIDTH(5);
1213 unsigned unimp
:BIT_WIDTH(6);
1214 unsigned int:BIT_WIDTH(7);
1215 unsigned sfu1_disabled
:BIT_WIDTH(8);
1216 unsigned :BITS_WIDTH(13,9);
1217 m88110_iresult_size_t iresult_size
:BITS_WIDTH(15,14);
1218 unsigned :BITS_WIDTH(31,16);
1224 host_byte_sex
= get_host_byte_sex();
1226 if(target_byte_sex
== host_byte_sex
){
1227 for(i
= 0; i
< M88110_N_DATA_BP
; i
++){
1228 spu
->data_bp
[i
].addr
= SWAP_INT(spu
->data_bp
[i
].addr
);
1229 memcpy(&sbpc
, &(spu
->data_bp
[i
].ctrl
),
1230 sizeof(struct swapped_m88110_bp_ctrl
));
1231 sbpc
.u
.word
= SWAP_INT(sbpc
.u
.word
);
1232 spu
->data_bp
[i
].ctrl
.v
= sbpc
.u
.fields
.v
;
1233 spu
->data_bp
[i
].ctrl
.addr_match
= sbpc
.u
.fields
.addr_match
;
1234 spu
->data_bp
[i
].ctrl
.rwm
= sbpc
.u
.fields
.rwm
;
1235 spu
->data_bp
[i
].ctrl
.rw
= sbpc
.u
.fields
.rw
;
1238 memcpy(&spsr
, &(spu
->psr
), sizeof(struct swap_m88110_psr
));
1239 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
1240 spu
->psr
.mxm_dis
= spsr
.u
.fields
.mxm_dis
;
1241 spu
->psr
.sfu1dis
= spsr
.u
.fields
.sfu1dis
;
1242 spu
->psr
.trace
= spsr
.u
.fields
.trace
;
1243 spu
->psr
.sm
= spsr
.u
.fields
.sm
;
1244 spu
->psr
.sgn_imd
= spsr
.u
.fields
.sgn_imd
;
1245 spu
->psr
.c
= spsr
.u
.fields
.c
;
1246 spu
->psr
.se
= spsr
.u
.fields
.se
;
1247 spu
->psr
.le
= spsr
.u
.fields
.le
;
1248 spu
->psr
.supr
= spsr
.u
.fields
.supr
;
1250 memcpy(&sfps
, &(spu
->fp_trap_status
),
1251 sizeof(struct swapped_m88110_fp_trap_status
));
1252 sfps
.u
.word
= SWAP_INT(sfps
.u
.word
);
1253 spu
->fp_trap_status
.efinx
= sfps
.u
.fields
.efinx
;
1254 spu
->fp_trap_status
.efovf
= sfps
.u
.fields
.efovf
;
1255 spu
->fp_trap_status
.efunf
= sfps
.u
.fields
.efunf
;
1256 spu
->fp_trap_status
.efdvz
= sfps
.u
.fields
.efdvz
;
1257 spu
->fp_trap_status
.efinv
= sfps
.u
.fields
.efinv
;
1258 spu
->fp_trap_status
.priv
= sfps
.u
.fields
.priv
;
1259 spu
->fp_trap_status
.unimp
= sfps
.u
.fields
.unimp
;
1260 spu
->fp_trap_status
.sfu1_disabled
= sfps
.u
.fields
.sfu1_disabled
;
1261 spu
->fp_trap_status
.iresult_size
= sfps
.u
.fields
.iresult_size
;
1264 for(i
= 0; i
< M88110_N_DATA_BP
; i
++){
1265 spu
->data_bp
[i
].addr
= SWAP_INT(spu
->data_bp
[i
].addr
);
1266 sbpc
.u
.fields
.v
= spu
->data_bp
[i
].ctrl
.v
;
1267 sbpc
.u
.fields
.addr_match
= spu
->data_bp
[i
].ctrl
.addr_match
;
1268 sbpc
.u
.fields
.rwm
= spu
->data_bp
[i
].ctrl
.rwm
;
1269 sbpc
.u
.fields
.rw
= spu
->data_bp
[i
].ctrl
.rw
;
1270 sbpc
.u
.word
= SWAP_INT(sbpc
.u
.word
);
1271 memcpy(&(spu
->data_bp
[i
].ctrl
), &sbpc
,
1272 sizeof(struct swapped_m88110_bp_ctrl
));
1275 spsr
.u
.fields
.mxm_dis
= spu
->psr
.mxm_dis
;
1276 spsr
.u
.fields
.sfu1dis
= spu
->psr
.sfu1dis
;
1277 spsr
.u
.fields
.trace
= spu
->psr
.trace
;
1278 spsr
.u
.fields
.sm
= spu
->psr
.sm
;
1279 spsr
.u
.fields
.sgn_imd
= spu
->psr
.sgn_imd
;
1280 spsr
.u
.fields
.c
= spu
->psr
.c
;
1281 spsr
.u
.fields
.se
= spu
->psr
.se
;
1282 spsr
.u
.fields
.le
= spu
->psr
.le
;
1283 spsr
.u
.fields
.supr
= spu
->psr
.supr
;
1284 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
1285 memcpy(&(spu
->psr
), &spsr
, sizeof(struct swap_m88110_psr
));
1287 sfps
.u
.fields
.efinx
= spu
->fp_trap_status
.efinx
;
1288 sfps
.u
.fields
.efovf
= spu
->fp_trap_status
.efovf
;
1289 sfps
.u
.fields
.efunf
= spu
->fp_trap_status
.efunf
;
1290 sfps
.u
.fields
.efdvz
= spu
->fp_trap_status
.efdvz
;
1291 sfps
.u
.fields
.efinv
= spu
->fp_trap_status
.efinv
;
1292 sfps
.u
.fields
.priv
= spu
->fp_trap_status
.priv
;
1293 sfps
.u
.fields
.unimp
= spu
->fp_trap_status
.unimp
;
1294 sfps
.u
.fields
.sfu1_disabled
= spu
->fp_trap_status
.sfu1_disabled
;
1295 sfps
.u
.fields
.iresult_size
= spu
->fp_trap_status
.iresult_size
;
1296 sfps
.u
.word
= SWAP_INT(sfps
.u
.word
);
1297 memcpy(&(spu
->fp_trap_status
), &sfps
,
1298 sizeof(struct swapped_m88110_fp_trap_status
));
1300 spu
->intermediate_result
.x
[0] =
1301 SWAP_INT(spu
->intermediate_result
.x
[0]);
1302 spu
->intermediate_result
.x
[1] =
1303 SWAP_INT(spu
->intermediate_result
.x
[1]);
1304 spu
->intermediate_result
.x
[2] =
1305 SWAP_INT(spu
->intermediate_result
.x
[2]);
1306 spu
->intermediate_result
.x
[3] =
1307 SWAP_INT(spu
->intermediate_result
.x
[3]);
1312 swap_i860_thread_state_regs(
1313 struct i860_thread_state_regs
*cpu
,
1314 enum byte_sex target_byte_sex
)
1318 enum byte_sex dummy
;
1319 dummy
= target_byte_sex
;
1322 for(i
= 0; i
< 31; i
++)
1323 cpu
->ireg
[i
] = SWAP_INT(cpu
->ireg
[i
]);
1324 for(i
= 0; i
< 30; i
++)
1325 cpu
->freg
[i
] = SWAP_INT(cpu
->freg
[i
]);
1326 cpu
->psr
= SWAP_INT(cpu
->psr
);
1327 cpu
->epsr
= SWAP_INT(cpu
->epsr
);
1328 cpu
->db
= SWAP_INT(cpu
->db
);
1329 cpu
->pc
= SWAP_INT(cpu
->pc
);
1330 cpu
->_padding_
= SWAP_INT(cpu
->_padding_
);
1331 cpu
->Mres3
= SWAP_DOUBLE(cpu
->Mres3
);
1332 cpu
->Ares3
= SWAP_DOUBLE(cpu
->Ares3
);
1333 cpu
->Mres2
= SWAP_DOUBLE(cpu
->Mres2
);
1334 cpu
->Ares2
= SWAP_DOUBLE(cpu
->Ares2
);
1335 cpu
->Mres1
= SWAP_DOUBLE(cpu
->Mres1
);
1336 cpu
->Ares1
= SWAP_DOUBLE(cpu
->Ares1
);
1337 cpu
->Ires1
= SWAP_DOUBLE(cpu
->Ires1
);
1338 cpu
->Lres3m
= SWAP_DOUBLE(cpu
->Lres3m
);
1339 cpu
->Lres2m
= SWAP_DOUBLE(cpu
->Lres2m
);
1340 cpu
->Lres1m
= SWAP_DOUBLE(cpu
->Lres1m
);
1341 cpu
->KR
= SWAP_DOUBLE(cpu
->KR
);
1342 cpu
->KI
= SWAP_DOUBLE(cpu
->KI
);
1343 cpu
->T
= SWAP_DOUBLE(cpu
->T
);
1344 cpu
->Fsr3
= SWAP_INT(cpu
->Fsr3
);
1345 cpu
->Fsr2
= SWAP_INT(cpu
->Fsr2
);
1346 cpu
->Fsr1
= SWAP_INT(cpu
->Fsr1
);
1347 cpu
->Mergelo32
= SWAP_INT(cpu
->Mergelo32
);
1348 cpu
->Mergehi32
= SWAP_INT(cpu
->Mergehi32
);
1353 swap_i386_thread_state(
1354 i386_thread_state_t
*cpu
,
1355 enum byte_sex target_byte_sex
)
1358 enum byte_sex dummy
;
1359 dummy
= target_byte_sex
;
1361 cpu
->eax
= SWAP_INT(cpu
->eax
);
1362 cpu
->ebx
= SWAP_INT(cpu
->ebx
);
1363 cpu
->ecx
= SWAP_INT(cpu
->ecx
);
1364 cpu
->edx
= SWAP_INT(cpu
->edx
);
1365 cpu
->edi
= SWAP_INT(cpu
->edi
);
1366 cpu
->esi
= SWAP_INT(cpu
->esi
);
1367 cpu
->ebp
= SWAP_INT(cpu
->ebp
);
1368 cpu
->esp
= SWAP_INT(cpu
->esp
);
1369 cpu
->ss
= SWAP_INT(cpu
->ss
);
1370 cpu
->eflags
= SWAP_INT(cpu
->eflags
);
1371 cpu
->eip
= SWAP_INT(cpu
->eip
);
1372 cpu
->cs
= SWAP_INT(cpu
->cs
);
1373 cpu
->ds
= SWAP_INT(cpu
->ds
);
1374 cpu
->es
= SWAP_INT(cpu
->es
);
1375 cpu
->fs
= SWAP_INT(cpu
->fs
);
1376 cpu
->gs
= SWAP_INT(cpu
->gs
);
1379 #ifdef x86_THREAD_STATE64
1382 swap_x86_thread_state64(
1383 x86_thread_state64_t
*cpu
,
1384 enum byte_sex target_byte_sex
)
1386 cpu
->rax
= SWAP_LONG_LONG(cpu
->rax
);
1387 cpu
->rbx
= SWAP_LONG_LONG(cpu
->rbx
);
1388 cpu
->rcx
= SWAP_LONG_LONG(cpu
->rcx
);
1389 cpu
->rdx
= SWAP_LONG_LONG(cpu
->rdx
);
1390 cpu
->rdi
= SWAP_LONG_LONG(cpu
->rdi
);
1391 cpu
->rsi
= SWAP_LONG_LONG(cpu
->rsi
);
1392 cpu
->rbp
= SWAP_LONG_LONG(cpu
->rbp
);
1393 cpu
->rsp
= SWAP_LONG_LONG(cpu
->rsp
);
1394 cpu
->rflags
= SWAP_LONG_LONG(cpu
->rflags
);
1395 cpu
->rip
= SWAP_LONG_LONG(cpu
->rip
);
1396 cpu
->r8
= SWAP_LONG_LONG(cpu
->r8
);
1397 cpu
->r9
= SWAP_LONG_LONG(cpu
->r9
);
1398 cpu
->r10
= SWAP_LONG_LONG(cpu
->r10
);
1399 cpu
->r11
= SWAP_LONG_LONG(cpu
->r11
);
1400 cpu
->r12
= SWAP_LONG_LONG(cpu
->r12
);
1401 cpu
->r13
= SWAP_LONG_LONG(cpu
->r13
);
1402 cpu
->r14
= SWAP_LONG_LONG(cpu
->r14
);
1403 cpu
->r15
= SWAP_LONG_LONG(cpu
->r15
);
1404 cpu
->cs
= SWAP_LONG_LONG(cpu
->cs
);
1405 cpu
->fs
= SWAP_LONG_LONG(cpu
->fs
);
1406 cpu
->gs
= SWAP_LONG_LONG(cpu
->gs
);
1408 #endif /* x86_THREAD_STATE64 */
1410 /* current i386 thread states */
1411 #if i386_THREAD_STATE == 1
1414 swap_i386_float_state(
1415 struct i386_float_state
*fpu
,
1416 enum byte_sex target_byte_sex
)
1418 #ifndef i386_EXCEPTION_STATE_COUNT
1419 /* this routine does nothing as their are currently no non-byte fields */
1420 #else /* defined(i386_EXCEPTION_STATE_COUNT) */
1421 struct swapped_fp_control
{
1437 unsigned short half
;
1441 struct swapped_fp_status
{
1460 unsigned short half
;
1464 enum byte_sex host_byte_sex
;
1466 host_byte_sex
= get_host_byte_sex();
1468 fpu
->fpu_reserved
[0] = SWAP_INT(fpu
->fpu_reserved
[0]);
1469 fpu
->fpu_reserved
[1] = SWAP_INT(fpu
->fpu_reserved
[1]);
1471 if(target_byte_sex
== host_byte_sex
){
1472 memcpy(&sfpc
, &(fpu
->fpu_fcw
),
1473 sizeof(struct swapped_fp_control
));
1474 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1475 fpu
->fpu_fcw
.rc
= sfpc
.u
.fields
.rc
;
1476 fpu
->fpu_fcw
.pc
= sfpc
.u
.fields
.pc
;
1477 fpu
->fpu_fcw
.precis
= sfpc
.u
.fields
.precis
;
1478 fpu
->fpu_fcw
.undfl
= sfpc
.u
.fields
.undfl
;
1479 fpu
->fpu_fcw
.ovrfl
= sfpc
.u
.fields
.ovrfl
;
1480 fpu
->fpu_fcw
.zdiv
= sfpc
.u
.fields
.zdiv
;
1481 fpu
->fpu_fcw
.denorm
= sfpc
.u
.fields
.denorm
;
1482 fpu
->fpu_fcw
.invalid
= sfpc
.u
.fields
.invalid
;
1484 memcpy(&sfps
, &(fpu
->fpu_fsw
),
1485 sizeof(struct swapped_fp_status
));
1486 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1487 fpu
->fpu_fsw
.busy
= sfps
.u
.fields
.busy
;
1488 fpu
->fpu_fsw
.c3
= sfps
.u
.fields
.c3
;
1489 fpu
->fpu_fsw
.tos
= sfps
.u
.fields
.tos
;
1490 fpu
->fpu_fsw
.c2
= sfps
.u
.fields
.c2
;
1491 fpu
->fpu_fsw
.c1
= sfps
.u
.fields
.c1
;
1492 fpu
->fpu_fsw
.c0
= sfps
.u
.fields
.c0
;
1493 fpu
->fpu_fsw
.errsumm
= sfps
.u
.fields
.errsumm
;
1494 fpu
->fpu_fsw
.stkflt
= sfps
.u
.fields
.stkflt
;
1495 fpu
->fpu_fsw
.precis
= sfps
.u
.fields
.precis
;
1496 fpu
->fpu_fsw
.undfl
= sfps
.u
.fields
.undfl
;
1497 fpu
->fpu_fsw
.ovrfl
= sfps
.u
.fields
.ovrfl
;
1498 fpu
->fpu_fsw
.zdiv
= sfps
.u
.fields
.zdiv
;
1499 fpu
->fpu_fsw
.denorm
= sfps
.u
.fields
.denorm
;
1500 fpu
->fpu_fsw
.invalid
= sfps
.u
.fields
.invalid
;
1503 sfpc
.u
.fields
.rc
= fpu
->fpu_fcw
.rc
;
1504 sfpc
.u
.fields
.pc
= fpu
->fpu_fcw
.pc
;
1505 sfpc
.u
.fields
.precis
= fpu
->fpu_fcw
.precis
;
1506 sfpc
.u
.fields
.undfl
= fpu
->fpu_fcw
.undfl
;
1507 sfpc
.u
.fields
.ovrfl
= fpu
->fpu_fcw
.ovrfl
;
1508 sfpc
.u
.fields
.zdiv
= fpu
->fpu_fcw
.zdiv
;
1509 sfpc
.u
.fields
.denorm
= fpu
->fpu_fcw
.denorm
;
1510 sfpc
.u
.fields
.invalid
= fpu
->fpu_fcw
.invalid
;
1511 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1512 memcpy(&(fpu
->fpu_fcw
), &sfpc
,
1513 sizeof(struct swapped_fp_control
));
1515 sfps
.u
.fields
.busy
= fpu
->fpu_fsw
.busy
;
1516 sfps
.u
.fields
.c3
= fpu
->fpu_fsw
.c3
;
1517 sfps
.u
.fields
.tos
= fpu
->fpu_fsw
.tos
;
1518 sfps
.u
.fields
.c2
= fpu
->fpu_fsw
.c2
;
1519 sfps
.u
.fields
.c1
= fpu
->fpu_fsw
.c1
;
1520 sfps
.u
.fields
.c0
= fpu
->fpu_fsw
.c0
;
1521 sfps
.u
.fields
.errsumm
= fpu
->fpu_fsw
.errsumm
;
1522 sfps
.u
.fields
.stkflt
= fpu
->fpu_fsw
.stkflt
;
1523 sfps
.u
.fields
.precis
= fpu
->fpu_fsw
.precis
;
1524 sfps
.u
.fields
.undfl
= fpu
->fpu_fsw
.undfl
;
1525 sfps
.u
.fields
.ovrfl
= fpu
->fpu_fsw
.ovrfl
;
1526 sfps
.u
.fields
.zdiv
= fpu
->fpu_fsw
.zdiv
;
1527 sfps
.u
.fields
.denorm
= fpu
->fpu_fsw
.denorm
;
1528 sfps
.u
.fields
.invalid
= fpu
->fpu_fsw
.invalid
;
1529 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1530 memcpy(&(fpu
->fpu_fsw
), &sfps
,
1531 sizeof(struct swapped_fp_status
));
1533 fpu
->fpu_fop
= SWAP_SHORT(fpu
->fpu_fop
);
1534 fpu
->fpu_ip
= SWAP_INT(fpu
->fpu_ip
);
1535 fpu
->fpu_cs
= SWAP_SHORT(fpu
->fpu_cs
);
1536 fpu
->fpu_rsrv2
= SWAP_SHORT(fpu
->fpu_rsrv2
);
1537 fpu
->fpu_dp
= SWAP_INT(fpu
->fpu_dp
);
1538 fpu
->fpu_ds
= SWAP_SHORT(fpu
->fpu_ds
);
1539 fpu
->fpu_rsrv3
= SWAP_SHORT(fpu
->fpu_rsrv3
);
1540 fpu
->fpu_mxcsr
= SWAP_INT(fpu
->fpu_mxcsr
);
1541 fpu
->fpu_mxcsrmask
= SWAP_INT(fpu
->fpu_mxcsrmask
);
1542 fpu
->fpu_reserved1
= SWAP_INT(fpu
->fpu_reserved1
);
1544 #endif /* defined(i386_EXCEPTION_STATE_COUNT) */
1549 swap_i386_exception_state(
1550 i386_exception_state_t
*exc
,
1551 enum byte_sex target_byte_sex
)
1553 exc
->trapno
= SWAP_INT(exc
->trapno
);
1554 exc
->err
= SWAP_INT(exc
->err
);
1555 exc
->faultvaddr
= SWAP_INT(exc
->faultvaddr
);
1558 #ifdef x86_THREAD_STATE64
1562 swap_x86_float_state64(
1563 x86_float_state64_t
*fpu
,
1564 enum byte_sex target_byte_sex
)
1566 struct swapped_fp_control
{
1582 unsigned short half
;
1586 struct swapped_fp_status
{
1605 unsigned short half
;
1609 enum byte_sex host_byte_sex
;
1611 host_byte_sex
= get_host_byte_sex();
1613 fpu
->fpu_reserved
[0] = SWAP_INT(fpu
->fpu_reserved
[0]);
1614 fpu
->fpu_reserved
[1] = SWAP_INT(fpu
->fpu_reserved
[1]);
1616 if(target_byte_sex
== host_byte_sex
){
1617 memcpy(&sfpc
, &(fpu
->fpu_fcw
),
1618 sizeof(struct swapped_fp_control
));
1619 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1620 fpu
->fpu_fcw
.rc
= sfpc
.u
.fields
.rc
;
1621 fpu
->fpu_fcw
.pc
= sfpc
.u
.fields
.pc
;
1622 fpu
->fpu_fcw
.precis
= sfpc
.u
.fields
.precis
;
1623 fpu
->fpu_fcw
.undfl
= sfpc
.u
.fields
.undfl
;
1624 fpu
->fpu_fcw
.ovrfl
= sfpc
.u
.fields
.ovrfl
;
1625 fpu
->fpu_fcw
.zdiv
= sfpc
.u
.fields
.zdiv
;
1626 fpu
->fpu_fcw
.denorm
= sfpc
.u
.fields
.denorm
;
1627 fpu
->fpu_fcw
.invalid
= sfpc
.u
.fields
.invalid
;
1629 memcpy(&sfps
, &(fpu
->fpu_fsw
),
1630 sizeof(struct swapped_fp_status
));
1631 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1632 fpu
->fpu_fsw
.busy
= sfps
.u
.fields
.busy
;
1633 fpu
->fpu_fsw
.c3
= sfps
.u
.fields
.c3
;
1634 fpu
->fpu_fsw
.tos
= sfps
.u
.fields
.tos
;
1635 fpu
->fpu_fsw
.c2
= sfps
.u
.fields
.c2
;
1636 fpu
->fpu_fsw
.c1
= sfps
.u
.fields
.c1
;
1637 fpu
->fpu_fsw
.c0
= sfps
.u
.fields
.c0
;
1638 fpu
->fpu_fsw
.errsumm
= sfps
.u
.fields
.errsumm
;
1639 fpu
->fpu_fsw
.stkflt
= sfps
.u
.fields
.stkflt
;
1640 fpu
->fpu_fsw
.precis
= sfps
.u
.fields
.precis
;
1641 fpu
->fpu_fsw
.undfl
= sfps
.u
.fields
.undfl
;
1642 fpu
->fpu_fsw
.ovrfl
= sfps
.u
.fields
.ovrfl
;
1643 fpu
->fpu_fsw
.zdiv
= sfps
.u
.fields
.zdiv
;
1644 fpu
->fpu_fsw
.denorm
= sfps
.u
.fields
.denorm
;
1645 fpu
->fpu_fsw
.invalid
= sfps
.u
.fields
.invalid
;
1648 sfpc
.u
.fields
.rc
= fpu
->fpu_fcw
.rc
;
1649 sfpc
.u
.fields
.pc
= fpu
->fpu_fcw
.pc
;
1650 sfpc
.u
.fields
.precis
= fpu
->fpu_fcw
.precis
;
1651 sfpc
.u
.fields
.undfl
= fpu
->fpu_fcw
.undfl
;
1652 sfpc
.u
.fields
.ovrfl
= fpu
->fpu_fcw
.ovrfl
;
1653 sfpc
.u
.fields
.zdiv
= fpu
->fpu_fcw
.zdiv
;
1654 sfpc
.u
.fields
.denorm
= fpu
->fpu_fcw
.denorm
;
1655 sfpc
.u
.fields
.invalid
= fpu
->fpu_fcw
.invalid
;
1656 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1657 memcpy(&(fpu
->fpu_fcw
), &sfpc
,
1658 sizeof(struct swapped_fp_control
));
1660 sfps
.u
.fields
.busy
= fpu
->fpu_fsw
.busy
;
1661 sfps
.u
.fields
.c3
= fpu
->fpu_fsw
.c3
;
1662 sfps
.u
.fields
.tos
= fpu
->fpu_fsw
.tos
;
1663 sfps
.u
.fields
.c2
= fpu
->fpu_fsw
.c2
;
1664 sfps
.u
.fields
.c1
= fpu
->fpu_fsw
.c1
;
1665 sfps
.u
.fields
.c0
= fpu
->fpu_fsw
.c0
;
1666 sfps
.u
.fields
.errsumm
= fpu
->fpu_fsw
.errsumm
;
1667 sfps
.u
.fields
.stkflt
= fpu
->fpu_fsw
.stkflt
;
1668 sfps
.u
.fields
.precis
= fpu
->fpu_fsw
.precis
;
1669 sfps
.u
.fields
.undfl
= fpu
->fpu_fsw
.undfl
;
1670 sfps
.u
.fields
.ovrfl
= fpu
->fpu_fsw
.ovrfl
;
1671 sfps
.u
.fields
.zdiv
= fpu
->fpu_fsw
.zdiv
;
1672 sfps
.u
.fields
.denorm
= fpu
->fpu_fsw
.denorm
;
1673 sfps
.u
.fields
.invalid
= fpu
->fpu_fsw
.invalid
;
1674 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1675 memcpy(&(fpu
->fpu_fsw
), &sfps
,
1676 sizeof(struct swapped_fp_status
));
1678 fpu
->fpu_fop
= SWAP_SHORT(fpu
->fpu_fop
);
1679 fpu
->fpu_ip
= SWAP_INT(fpu
->fpu_ip
);
1680 fpu
->fpu_cs
= SWAP_SHORT(fpu
->fpu_cs
);
1681 fpu
->fpu_rsrv2
= SWAP_SHORT(fpu
->fpu_rsrv2
);
1682 fpu
->fpu_dp
= SWAP_INT(fpu
->fpu_dp
);
1683 fpu
->fpu_ds
= SWAP_SHORT(fpu
->fpu_ds
);
1684 fpu
->fpu_rsrv3
= SWAP_SHORT(fpu
->fpu_rsrv3
);
1685 fpu
->fpu_mxcsr
= SWAP_INT(fpu
->fpu_mxcsr
);
1686 fpu
->fpu_mxcsrmask
= SWAP_INT(fpu
->fpu_mxcsrmask
);
1687 fpu
->fpu_reserved1
= SWAP_INT(fpu
->fpu_reserved1
);
1692 swap_x86_exception_state64(
1693 x86_exception_state64_t
*exc
,
1694 enum byte_sex target_byte_sex
)
1696 exc
->trapno
= SWAP_INT(exc
->trapno
);
1697 exc
->err
= SWAP_INT(exc
->err
);
1698 exc
->faultvaddr
= SWAP_LONG_LONG(exc
->faultvaddr
);
1703 swap_x86_debug_state32(
1704 x86_debug_state32_t
*debug
,
1705 enum byte_sex target_byte_sex
)
1707 debug
->dr0
= SWAP_INT(debug
->dr0
);
1708 debug
->dr1
= SWAP_INT(debug
->dr1
);
1709 debug
->dr2
= SWAP_INT(debug
->dr2
);
1710 debug
->dr3
= SWAP_INT(debug
->dr3
);
1711 debug
->dr4
= SWAP_INT(debug
->dr4
);
1712 debug
->dr5
= SWAP_INT(debug
->dr5
);
1713 debug
->dr6
= SWAP_INT(debug
->dr6
);
1714 debug
->dr7
= SWAP_INT(debug
->dr7
);
1719 swap_x86_debug_state64(
1720 x86_debug_state64_t
*debug
,
1721 enum byte_sex target_byte_sex
)
1723 debug
->dr0
= SWAP_LONG_LONG(debug
->dr0
);
1724 debug
->dr1
= SWAP_LONG_LONG(debug
->dr1
);
1725 debug
->dr2
= SWAP_LONG_LONG(debug
->dr2
);
1726 debug
->dr3
= SWAP_LONG_LONG(debug
->dr3
);
1727 debug
->dr4
= SWAP_LONG_LONG(debug
->dr4
);
1728 debug
->dr5
= SWAP_LONG_LONG(debug
->dr5
);
1729 debug
->dr6
= SWAP_LONG_LONG(debug
->dr6
);
1730 debug
->dr7
= SWAP_LONG_LONG(debug
->dr7
);
1736 struct x86_state_hdr
*hdr
,
1737 enum byte_sex target_byte_sex
)
1739 hdr
->flavor
= SWAP_INT(hdr
->flavor
);
1740 hdr
->count
= SWAP_INT(hdr
->count
);
1742 #endif /* x86_THREAD_STATE64 */
1744 #endif /* i386_THREAD_STATE == 1 */
1746 /* i386 thread states on older releases */
1747 #if i386_THREAD_STATE == -1
1750 swap_i386_thread_fpstate(
1751 i386_thread_fpstate_t
*fpu
,
1752 enum byte_sex target_byte_sex
)
1754 struct swapped_fp_control
{
1770 unsigned short half
;
1774 struct swapped_fp_status
{
1793 unsigned short half
;
1797 struct swapped_fp_tag
{
1810 unsigned short half
;
1814 struct swapped_fp_data_reg
{
1815 unsigned short mant
;
1816 unsigned short mant1
:16,
1821 unsigned short sign
:1,
1824 unsigned short half
;
1828 struct swapped_sel
{
1836 unsigned short half
;
1840 enum byte_sex host_byte_sex
;
1843 host_byte_sex
= get_host_byte_sex();
1845 fpu
->environ
.ip
= SWAP_INT(fpu
->environ
.ip
);
1846 fpu
->environ
.opcode
= SWAP_SHORT(fpu
->environ
.opcode
);
1847 fpu
->environ
.dp
= SWAP_INT(fpu
->environ
.dp
);
1849 if(target_byte_sex
== host_byte_sex
){
1850 memcpy(&sfpc
, &(fpu
->environ
.control
),
1851 sizeof(struct swapped_fp_control
));
1852 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1853 fpu
->environ
.control
.rc
= sfpc
.u
.fields
.rc
;
1854 fpu
->environ
.control
.pc
= sfpc
.u
.fields
.pc
;
1855 fpu
->environ
.control
.precis
= sfpc
.u
.fields
.precis
;
1856 fpu
->environ
.control
.undfl
= sfpc
.u
.fields
.undfl
;
1857 fpu
->environ
.control
.ovrfl
= sfpc
.u
.fields
.ovrfl
;
1858 fpu
->environ
.control
.zdiv
= sfpc
.u
.fields
.zdiv
;
1859 fpu
->environ
.control
.denorm
= sfpc
.u
.fields
.denorm
;
1860 fpu
->environ
.control
.invalid
= sfpc
.u
.fields
.invalid
;
1862 memcpy(&sfps
, &(fpu
->environ
.status
),
1863 sizeof(struct swapped_fp_status
));
1864 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1865 fpu
->environ
.status
.busy
= sfps
.u
.fields
.busy
;
1866 fpu
->environ
.status
.c3
= sfps
.u
.fields
.c3
;
1867 fpu
->environ
.status
.tos
= sfps
.u
.fields
.tos
;
1868 fpu
->environ
.status
.c2
= sfps
.u
.fields
.c2
;
1869 fpu
->environ
.status
.c1
= sfps
.u
.fields
.c1
;
1870 fpu
->environ
.status
.c0
= sfps
.u
.fields
.c0
;
1871 fpu
->environ
.status
.errsumm
= sfps
.u
.fields
.errsumm
;
1872 fpu
->environ
.status
.stkflt
= sfps
.u
.fields
.stkflt
;
1873 fpu
->environ
.status
.precis
= sfps
.u
.fields
.precis
;
1874 fpu
->environ
.status
.undfl
= sfps
.u
.fields
.undfl
;
1875 fpu
->environ
.status
.ovrfl
= sfps
.u
.fields
.ovrfl
;
1876 fpu
->environ
.status
.zdiv
= sfps
.u
.fields
.zdiv
;
1877 fpu
->environ
.status
.denorm
= sfps
.u
.fields
.denorm
;
1878 fpu
->environ
.status
.invalid
= sfps
.u
.fields
.invalid
;
1880 memcpy(&sfpt
, &(fpu
->environ
.tag
),
1881 sizeof(struct swapped_fp_tag
));
1882 sfpt
.u
.half
= SWAP_SHORT(sfpt
.u
.half
);
1883 fpu
->environ
.tag
.tag7
= sfpt
.u
.fields
.tag7
;
1884 fpu
->environ
.tag
.tag6
= sfpt
.u
.fields
.tag6
;
1885 fpu
->environ
.tag
.tag5
= sfpt
.u
.fields
.tag5
;
1886 fpu
->environ
.tag
.tag4
= sfpt
.u
.fields
.tag4
;
1887 fpu
->environ
.tag
.tag3
= sfpt
.u
.fields
.tag3
;
1888 fpu
->environ
.tag
.tag2
= sfpt
.u
.fields
.tag2
;
1889 fpu
->environ
.tag
.tag1
= sfpt
.u
.fields
.tag1
;
1890 fpu
->environ
.tag
.tag0
= sfpt
.u
.fields
.tag0
;
1892 memcpy(&ss
, &(fpu
->environ
.cs
),
1893 sizeof(struct swapped_sel
));
1894 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1895 fpu
->environ
.cs
.index
= ss
.u
.fields
.index
;
1896 fpu
->environ
.cs
.ti
= ss
.u
.fields
.ti
;
1897 fpu
->environ
.cs
.rpl
= ss
.u
.fields
.rpl
;
1899 memcpy(&ss
, &(fpu
->environ
.ds
),
1900 sizeof(struct swapped_sel
));
1901 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1902 fpu
->environ
.ds
.index
= ss
.u
.fields
.index
;
1903 fpu
->environ
.ds
.ti
= ss
.u
.fields
.ti
;
1904 fpu
->environ
.ds
.rpl
= ss
.u
.fields
.rpl
;
1906 for(i
= 0; i
< 8; i
++){
1907 memcpy(&sfpd
, &(fpu
->stack
.ST
[i
]),
1908 sizeof(struct swapped_fp_data_reg
));
1909 fpu
->stack
.ST
[i
].mant
= SWAP_SHORT(sfpd
.mant
);
1910 fpu
->stack
.ST
[i
].mant1
= SWAP_SHORT(sfpd
.mant1
);
1911 fpu
->stack
.ST
[i
].mant2
= SWAP_SHORT(sfpd
.mant2
);
1912 fpu
->stack
.ST
[i
].mant3
= SWAP_SHORT(sfpd
.mant3
);
1913 sfpd
.u
.half
= SWAP_SHORT(sfpd
.u
.half
);
1914 fpu
->stack
.ST
[i
].exp
= sfpd
.u
.fields
.exp
;
1915 fpu
->stack
.ST
[i
].sign
= sfpd
.u
.fields
.sign
;
1919 sfpc
.u
.fields
.rc
= fpu
->environ
.control
.rc
;
1920 sfpc
.u
.fields
.pc
= fpu
->environ
.control
.pc
;
1921 sfpc
.u
.fields
.precis
= fpu
->environ
.control
.precis
;
1922 sfpc
.u
.fields
.undfl
= fpu
->environ
.control
.undfl
;
1923 sfpc
.u
.fields
.ovrfl
= fpu
->environ
.control
.ovrfl
;
1924 sfpc
.u
.fields
.zdiv
= fpu
->environ
.control
.zdiv
;
1925 sfpc
.u
.fields
.denorm
= fpu
->environ
.control
.denorm
;
1926 sfpc
.u
.fields
.invalid
= fpu
->environ
.control
.invalid
;
1927 sfpc
.u
.half
= SWAP_SHORT(sfpc
.u
.half
);
1928 memcpy(&(fpu
->environ
.control
), &sfpc
,
1929 sizeof(struct swapped_fp_control
));
1931 sfps
.u
.fields
.busy
= fpu
->environ
.status
.busy
;
1932 sfps
.u
.fields
.c3
= fpu
->environ
.status
.c3
;
1933 sfps
.u
.fields
.tos
= fpu
->environ
.status
.tos
;
1934 sfps
.u
.fields
.c2
= fpu
->environ
.status
.c2
;
1935 sfps
.u
.fields
.c1
= fpu
->environ
.status
.c1
;
1936 sfps
.u
.fields
.c0
= fpu
->environ
.status
.c0
;
1937 sfps
.u
.fields
.errsumm
= fpu
->environ
.status
.errsumm
;
1938 sfps
.u
.fields
.stkflt
= fpu
->environ
.status
.stkflt
;
1939 sfps
.u
.fields
.precis
= fpu
->environ
.status
.precis
;
1940 sfps
.u
.fields
.undfl
= fpu
->environ
.status
.undfl
;
1941 sfps
.u
.fields
.ovrfl
= fpu
->environ
.status
.ovrfl
;
1942 sfps
.u
.fields
.zdiv
= fpu
->environ
.status
.zdiv
;
1943 sfps
.u
.fields
.denorm
= fpu
->environ
.status
.denorm
;
1944 sfps
.u
.fields
.invalid
= fpu
->environ
.status
.invalid
;
1945 sfps
.u
.half
= SWAP_SHORT(sfps
.u
.half
);
1946 memcpy(&(fpu
->environ
.status
), &sfps
,
1947 sizeof(struct swapped_fp_status
));
1949 sfpt
.u
.fields
.tag7
= fpu
->environ
.tag
.tag7
;
1950 sfpt
.u
.fields
.tag6
= fpu
->environ
.tag
.tag6
;
1951 sfpt
.u
.fields
.tag5
= fpu
->environ
.tag
.tag5
;
1952 sfpt
.u
.fields
.tag4
= fpu
->environ
.tag
.tag4
;
1953 sfpt
.u
.fields
.tag3
= fpu
->environ
.tag
.tag3
;
1954 sfpt
.u
.fields
.tag2
= fpu
->environ
.tag
.tag2
;
1955 sfpt
.u
.fields
.tag1
= fpu
->environ
.tag
.tag1
;
1956 sfpt
.u
.fields
.tag0
= fpu
->environ
.tag
.tag0
;
1957 sfpt
.u
.half
= SWAP_SHORT(sfpt
.u
.half
);
1958 memcpy(&(fpu
->environ
.tag
), &sfpt
,
1959 sizeof(struct swapped_fp_tag
));
1961 ss
.u
.fields
.index
= fpu
->environ
.cs
.index
;
1962 ss
.u
.fields
.ti
= fpu
->environ
.cs
.ti
;
1963 ss
.u
.fields
.rpl
= fpu
->environ
.cs
.rpl
;
1964 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1965 memcpy(&(fpu
->environ
.cs
), &ss
,
1966 sizeof(struct swapped_sel
));
1968 ss
.u
.fields
.index
= fpu
->environ
.ds
.index
;
1969 ss
.u
.fields
.ti
= fpu
->environ
.ds
.ti
;
1970 ss
.u
.fields
.rpl
= fpu
->environ
.ds
.rpl
;
1971 ss
.u
.half
= SWAP_SHORT(ss
.u
.half
);
1972 memcpy(&(fpu
->environ
.cs
), &ss
,
1973 sizeof(struct swapped_sel
));
1975 for(i
= 0; i
< 8; i
++){
1976 sfpd
.mant
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant
);
1977 sfpd
.mant1
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant1
);
1978 sfpd
.mant2
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant2
);
1979 sfpd
.mant3
= SWAP_SHORT(fpu
->stack
.ST
[i
].mant3
);
1980 sfpd
.u
.fields
.exp
= fpu
->stack
.ST
[i
].exp
;
1981 sfpd
.u
.fields
.sign
= fpu
->stack
.ST
[i
].sign
;
1982 sfpd
.u
.half
= SWAP_SHORT(sfpd
.u
.half
);
1983 memcpy(&(fpu
->stack
.ST
[i
]), &sfpd
,
1984 sizeof(struct swapped_fp_data_reg
));
1991 swap_i386_thread_exceptstate(
1992 i386_thread_exceptstate_t
*exc
,
1993 enum byte_sex target_byte_sex
)
1995 struct swapped_err_code
{
1997 struct err_code_normal
{
2003 struct err_code_pgfault
{
2013 enum byte_sex host_byte_sex
;
2015 host_byte_sex
= get_host_byte_sex();
2017 exc
->trapno
= SWAP_INT(exc
->trapno
);
2018 if(exc
->trapno
== 14){
2019 if(target_byte_sex
== host_byte_sex
){
2020 memcpy(&sec
, &(exc
->err
), sizeof(struct swapped_err_code
));
2021 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2022 exc
->err
.pgfault
.user
= sec
.u
.pgfault
.user
;
2023 exc
->err
.pgfault
.wrtflt
= sec
.u
.pgfault
.wrtflt
;
2024 exc
->err
.pgfault
.prot
= sec
.u
.pgfault
.prot
;
2027 sec
.u
.pgfault
.prot
= exc
->err
.pgfault
.prot
;
2028 sec
.u
.pgfault
.wrtflt
= exc
->err
.pgfault
.wrtflt
;
2029 sec
.u
.pgfault
.user
= exc
->err
.pgfault
.user
;
2030 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2031 memcpy(&(exc
->err
), &sec
, sizeof(struct swapped_err_code
));
2035 if(target_byte_sex
== host_byte_sex
){
2036 memcpy(&sec
, &(exc
->err
), sizeof(struct swapped_err_code
));
2037 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2038 word
= sec
.u
.normal
.index
;
2039 exc
->err
.normal
.index
= SWAP_INT(word
);
2040 exc
->err
.normal
.tbl
= sec
.u
.normal
.tbl
;
2041 exc
->err
.normal
.ext
= sec
.u
.normal
.ext
;
2044 sec
.u
.normal
.ext
= exc
->err
.normal
.ext
;
2045 sec
.u
.normal
.tbl
= exc
->err
.normal
.tbl
;
2046 word
= exc
->err
.normal
.index
;
2047 sec
.u
.normal
.index
= SWAP_INT(word
);
2048 sec
.u
.word
= SWAP_INT(sec
.u
.word
);
2049 memcpy(&(exc
->err
), &sec
, sizeof(struct swapped_err_code
));
2056 swap_i386_thread_cthreadstate(
2057 i386_thread_cthreadstate_t
*user
,
2058 enum byte_sex target_byte_sex
)
2061 enum byte_sex dummy
;
2062 dummy
= target_byte_sex
;
2064 user
->self
= SWAP_INT(user
->self
);
2066 #endif /* i386_THREAD_STATE == -1 */
2070 swap_hppa_integer_thread_state(
2071 struct hp_pa_integer_thread_state
*regs
,
2072 enum byte_sex target_byte_sex
)
2075 enum byte_sex dummy
;
2076 dummy
= target_byte_sex
;
2078 regs
->ts_gr1
= SWAP_INT(regs
->ts_gr1
);
2079 regs
->ts_gr2
= SWAP_INT(regs
->ts_gr2
);
2080 regs
->ts_gr3
= SWAP_INT(regs
->ts_gr3
);
2081 regs
->ts_gr4
= SWAP_INT(regs
->ts_gr4
);
2082 regs
->ts_gr5
= SWAP_INT(regs
->ts_gr5
);
2083 regs
->ts_gr6
= SWAP_INT(regs
->ts_gr6
);
2084 regs
->ts_gr7
= SWAP_INT(regs
->ts_gr7
);
2085 regs
->ts_gr8
= SWAP_INT(regs
->ts_gr8
);
2086 regs
->ts_gr9
= SWAP_INT(regs
->ts_gr9
);
2087 regs
->ts_gr10
= SWAP_INT(regs
->ts_gr10
);
2088 regs
->ts_gr11
= SWAP_INT(regs
->ts_gr11
);
2089 regs
->ts_gr12
= SWAP_INT(regs
->ts_gr12
);
2090 regs
->ts_gr13
= SWAP_INT(regs
->ts_gr13
);
2091 regs
->ts_gr14
= SWAP_INT(regs
->ts_gr14
);
2092 regs
->ts_gr15
= SWAP_INT(regs
->ts_gr15
);
2093 regs
->ts_gr16
= SWAP_INT(regs
->ts_gr16
);
2094 regs
->ts_gr17
= SWAP_INT(regs
->ts_gr17
);
2095 regs
->ts_gr18
= SWAP_INT(regs
->ts_gr18
);
2096 regs
->ts_gr19
= SWAP_INT(regs
->ts_gr19
);
2097 regs
->ts_gr20
= SWAP_INT(regs
->ts_gr20
);
2098 regs
->ts_gr21
= SWAP_INT(regs
->ts_gr21
);
2099 regs
->ts_gr22
= SWAP_INT(regs
->ts_gr22
);
2100 regs
->ts_gr23
= SWAP_INT(regs
->ts_gr23
);
2101 regs
->ts_gr24
= SWAP_INT(regs
->ts_gr24
);
2102 regs
->ts_gr25
= SWAP_INT(regs
->ts_gr25
);
2103 regs
->ts_gr26
= SWAP_INT(regs
->ts_gr26
);
2104 regs
->ts_gr27
= SWAP_INT(regs
->ts_gr27
);
2105 regs
->ts_gr28
= SWAP_INT(regs
->ts_gr28
);
2106 regs
->ts_gr29
= SWAP_INT(regs
->ts_gr29
);
2107 regs
->ts_gr30
= SWAP_INT(regs
->ts_gr30
);
2108 regs
->ts_gr31
= SWAP_INT(regs
->ts_gr31
);
2109 regs
->ts_sr0
= SWAP_INT(regs
->ts_sr0
);
2110 regs
->ts_sr1
= SWAP_INT(regs
->ts_sr1
);
2111 regs
->ts_sr2
= SWAP_INT(regs
->ts_sr2
);
2112 regs
->ts_sr3
= SWAP_INT(regs
->ts_sr3
);
2113 regs
->ts_sar
= SWAP_INT(regs
->ts_sar
);
2117 void swap_hppa_frame_thread_state(
2118 struct hp_pa_frame_thread_state
*frame
,
2119 enum byte_sex target_byte_sex
)
2122 enum byte_sex dummy
;
2123 dummy
= target_byte_sex
;
2125 frame
->ts_pcsq_front
= SWAP_INT(frame
->ts_pcsq_front
);
2126 frame
->ts_pcsq_back
= SWAP_INT(frame
->ts_pcsq_back
);
2127 frame
->ts_pcoq_front
= SWAP_INT(frame
->ts_pcoq_front
);
2128 frame
->ts_pcoq_back
= SWAP_INT(frame
->ts_pcoq_back
);
2129 frame
->ts_psw
= SWAP_INT(frame
->ts_psw
);
2130 frame
->ts_unaligned_faults
= SWAP_INT(frame
->ts_unaligned_faults
);
2131 frame
->ts_fault_address
= SWAP_INT(frame
->ts_fault_address
);
2132 frame
->ts_step_range_start
= SWAP_INT(frame
->ts_step_range_start
);
2133 frame
->ts_step_range_stop
= SWAP_INT(frame
->ts_step_range_stop
);
2137 void swap_hppa_fp_thread_state(
2138 struct hp_pa_fp_thread_state
*fp
,
2139 enum byte_sex target_byte_sex
)
2142 enum byte_sex dummy
;
2143 dummy
= target_byte_sex
;
2145 fp
->ts_fp0
= SWAP_DOUBLE(fp
->ts_fp0
);
2146 fp
->ts_fp1
= SWAP_DOUBLE(fp
->ts_fp1
);
2147 fp
->ts_fp2
= SWAP_DOUBLE(fp
->ts_fp2
);
2148 fp
->ts_fp3
= SWAP_DOUBLE(fp
->ts_fp3
);
2149 fp
->ts_fp4
= SWAP_DOUBLE(fp
->ts_fp4
);
2150 fp
->ts_fp5
= SWAP_DOUBLE(fp
->ts_fp5
);
2151 fp
->ts_fp6
= SWAP_DOUBLE(fp
->ts_fp6
);
2152 fp
->ts_fp7
= SWAP_DOUBLE(fp
->ts_fp7
);
2153 fp
->ts_fp8
= SWAP_DOUBLE(fp
->ts_fp8
);
2154 fp
->ts_fp9
= SWAP_DOUBLE(fp
->ts_fp9
);
2155 fp
->ts_fp10
= SWAP_DOUBLE(fp
->ts_fp10
);
2156 fp
->ts_fp11
= SWAP_DOUBLE(fp
->ts_fp11
);
2157 fp
->ts_fp12
= SWAP_DOUBLE(fp
->ts_fp12
);
2158 fp
->ts_fp13
= SWAP_DOUBLE(fp
->ts_fp13
);
2159 fp
->ts_fp14
= SWAP_DOUBLE(fp
->ts_fp14
);
2160 fp
->ts_fp15
= SWAP_DOUBLE(fp
->ts_fp15
);
2161 fp
->ts_fp16
= SWAP_DOUBLE(fp
->ts_fp16
);
2162 fp
->ts_fp17
= SWAP_DOUBLE(fp
->ts_fp17
);
2163 fp
->ts_fp18
= SWAP_DOUBLE(fp
->ts_fp18
);
2164 fp
->ts_fp19
= SWAP_DOUBLE(fp
->ts_fp19
);
2165 fp
->ts_fp20
= SWAP_DOUBLE(fp
->ts_fp20
);
2166 fp
->ts_fp21
= SWAP_DOUBLE(fp
->ts_fp21
);
2167 fp
->ts_fp22
= SWAP_DOUBLE(fp
->ts_fp22
);
2168 fp
->ts_fp23
= SWAP_DOUBLE(fp
->ts_fp23
);
2169 fp
->ts_fp24
= SWAP_DOUBLE(fp
->ts_fp24
);
2170 fp
->ts_fp25
= SWAP_DOUBLE(fp
->ts_fp25
);
2171 fp
->ts_fp26
= SWAP_DOUBLE(fp
->ts_fp26
);
2172 fp
->ts_fp27
= SWAP_DOUBLE(fp
->ts_fp27
);
2173 fp
->ts_fp28
= SWAP_DOUBLE(fp
->ts_fp28
);
2174 fp
->ts_fp29
= SWAP_DOUBLE(fp
->ts_fp29
);
2175 fp
->ts_fp30
= SWAP_DOUBLE(fp
->ts_fp30
);
2176 fp
->ts_fp31
= SWAP_DOUBLE(fp
->ts_fp31
);
2181 swap_sparc_thread_state_regs(
2182 struct sparc_thread_state_regs
*cpu
,
2183 enum byte_sex target_byte_sex
)
2185 struct swapped_psr
{
2189 cwp
:BITS_WIDTH(4,0),
2193 pil
:BITS_WIDTH(11,8),
2196 reserved
:BITS_WIDTH(19,14),
2197 icc
:BITS_WIDTH(23,20),
2198 ver
:BITS_WIDTH(27,24),
2199 impl
:BITS_WIDTH(31,28);
2204 struct p_status
*pr_status
;
2205 enum byte_sex host_byte_sex
;
2207 host_byte_sex
= get_host_byte_sex();
2209 cpu
->regs
.r_pc
= SWAP_INT(cpu
->regs
.r_pc
);
2210 cpu
->regs
.r_npc
= SWAP_INT(cpu
->regs
.r_npc
);
2211 cpu
->regs
.r_y
= SWAP_INT(cpu
->regs
.r_y
);
2212 cpu
->regs
.r_g1
= SWAP_INT(cpu
->regs
.r_g1
);
2213 cpu
->regs
.r_g2
= SWAP_INT(cpu
->regs
.r_g2
);
2214 cpu
->regs
.r_g3
= SWAP_INT(cpu
->regs
.r_g3
);
2215 cpu
->regs
.r_g4
= SWAP_INT(cpu
->regs
.r_g4
);
2216 cpu
->regs
.r_g5
= SWAP_INT(cpu
->regs
.r_g5
);
2217 cpu
->regs
.r_g6
= SWAP_INT(cpu
->regs
.r_g6
);
2218 cpu
->regs
.r_g7
= SWAP_INT(cpu
->regs
.r_g7
);
2219 cpu
->regs
.r_o0
= SWAP_INT(cpu
->regs
.r_o0
);
2220 cpu
->regs
.r_o1
= SWAP_INT(cpu
->regs
.r_o1
);
2221 cpu
->regs
.r_o2
= SWAP_INT(cpu
->regs
.r_o2
);
2222 cpu
->regs
.r_o3
= SWAP_INT(cpu
->regs
.r_o3
);
2223 cpu
->regs
.r_o4
= SWAP_INT(cpu
->regs
.r_o4
);
2224 cpu
->regs
.r_o5
= SWAP_INT(cpu
->regs
.r_o5
);
2225 cpu
->regs
.r_o6
= SWAP_INT(cpu
->regs
.r_o6
);
2226 cpu
->regs
.r_o7
= SWAP_INT(cpu
->regs
.r_o7
);
2228 pr_status
= (struct p_status
*) &(cpu
->regs
.r_psr
);
2229 if(target_byte_sex
== host_byte_sex
){
2230 memcpy(&spsr
, &(cpu
->regs
.r_psr
), sizeof(struct swapped_psr
));
2231 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
2232 pr_status
->PSRREG
.psr_bits
.cwp
= spsr
.u
.fields
.cwp
;
2233 pr_status
->PSRREG
.psr_bits
.ps
= spsr
.u
.fields
.ps
;
2234 pr_status
->PSRREG
.psr_bits
.s
= spsr
.u
.fields
.s
;
2235 pr_status
->PSRREG
.psr_bits
.pil
= spsr
.u
.fields
.pil
;
2236 pr_status
->PSRREG
.psr_bits
.ef
= spsr
.u
.fields
.ef
;
2237 pr_status
->PSRREG
.psr_bits
.ec
= spsr
.u
.fields
.ec
;
2238 pr_status
->PSRREG
.psr_bits
.reserved
= spsr
.u
.fields
.reserved
;
2239 pr_status
->PSRREG
.psr_bits
.icc
= spsr
.u
.fields
.icc
;
2240 pr_status
->PSRREG
.psr_bits
.et
= spsr
.u
.fields
.ver
;
2241 pr_status
->PSRREG
.psr_bits
.impl
= spsr
.u
.fields
.impl
;
2244 spsr
.u
.fields
.cwp
= pr_status
->PSRREG
.psr_bits
.cwp
;
2245 spsr
.u
.fields
.ps
= pr_status
->PSRREG
.psr_bits
.ps
;
2246 spsr
.u
.fields
.s
= pr_status
->PSRREG
.psr_bits
.s
;
2247 spsr
.u
.fields
.pil
= pr_status
->PSRREG
.psr_bits
.pil
;
2248 spsr
.u
.fields
.ef
= pr_status
->PSRREG
.psr_bits
.ef
;
2249 spsr
.u
.fields
.ec
= pr_status
->PSRREG
.psr_bits
.ec
;
2250 spsr
.u
.fields
.reserved
= pr_status
->PSRREG
.psr_bits
.reserved
;
2251 spsr
.u
.fields
.icc
= pr_status
->PSRREG
.psr_bits
.icc
;
2252 spsr
.u
.fields
.ver
= pr_status
->PSRREG
.psr_bits
.et
;
2253 spsr
.u
.fields
.impl
= pr_status
->PSRREG
.psr_bits
.impl
;
2254 spsr
.u
.word
= SWAP_INT(spsr
.u
.word
);
2255 memcpy(&(cpu
->regs
.r_psr
), &spsr
, sizeof(struct swapped_psr
));
2261 swap_sparc_thread_state_fpu(
2262 struct sparc_thread_state_fpu
*fpu
,
2263 enum byte_sex target_byte_sex
)
2265 struct swapped_fsr
{
2269 cexc
:BITS_WIDTH(4,0),
2270 aexc
:BITS_WIDTH(9,5),
2271 fcc
:BITS_WIDTH(11,10),
2274 ftt
:BITS_WIDTH(16,14),
2275 res
:BITS_WIDTH(22,17),
2276 tem
:BITS_WIDTH(27,23),
2277 rp
:BITS_WIDTH(29,28),
2278 rd
:BITS_WIDTH(31,30);
2284 struct f_status
*fpu_status
;
2285 enum byte_sex host_byte_sex
;
2287 host_byte_sex
= get_host_byte_sex();
2290 /* floating point registers */
2291 for(i
= 0; i
< 16; i
++) /* 16 doubles */
2292 fpu
->fpu
.fpu_fr
.Fpu_dregs
[i
] =
2293 SWAP_DOUBLE(fpu
->fpu
.fpu_fr
.Fpu_dregs
[i
]);
2295 fpu
->fpu
.Fpu_q
[0].FQu
.whole
= SWAP_DOUBLE(fpu
->fpu
.Fpu_q
[0].FQu
.whole
);
2296 fpu
->fpu
.Fpu_q
[1].FQu
.whole
= SWAP_DOUBLE(fpu
->fpu
.Fpu_q
[1].FQu
.whole
);
2297 fpu
->fpu
.Fpu_flags
= SWAP_INT(fpu
->fpu
.Fpu_flags
);
2298 fpu
->fpu
.Fpu_extra
= SWAP_INT(fpu
->fpu
.Fpu_extra
);
2299 fpu
->fpu
.Fpu_qcnt
= SWAP_INT(fpu
->fpu
.Fpu_qcnt
);
2301 fpu_status
= (struct f_status
*) &(fpu
->fpu
.Fpu_fsr
);
2302 if(target_byte_sex
== host_byte_sex
){
2303 memcpy(&sfsr
, &(fpu
->fpu
.Fpu_fsr
), sizeof(unsigned int));
2304 sfsr
.u
.word
= SWAP_INT(sfsr
.u
.word
);
2305 fpu_status
->FPUREG
.Fpu_fsr_bits
.rd
= sfsr
.u
.fields
.rd
;
2306 fpu_status
->FPUREG
.Fpu_fsr_bits
.rp
= sfsr
.u
.fields
.rp
;
2307 fpu_status
->FPUREG
.Fpu_fsr_bits
.tem
= sfsr
.u
.fields
.tem
;
2308 fpu_status
->FPUREG
.Fpu_fsr_bits
.res
= sfsr
.u
.fields
.res
;
2309 fpu_status
->FPUREG
.Fpu_fsr_bits
.ftt
= sfsr
.u
.fields
.ftt
;
2310 fpu_status
->FPUREG
.Fpu_fsr_bits
.qne
= sfsr
.u
.fields
.qne
;
2311 fpu_status
->FPUREG
.Fpu_fsr_bits
.pr
= sfsr
.u
.fields
.pr
;
2312 fpu_status
->FPUREG
.Fpu_fsr_bits
.fcc
= sfsr
.u
.fields
.fcc
;
2313 fpu_status
->FPUREG
.Fpu_fsr_bits
.aexc
= sfsr
.u
.fields
.aexc
;
2314 fpu_status
->FPUREG
.Fpu_fsr_bits
.cexc
= sfsr
.u
.fields
.cexc
;
2317 sfsr
.u
.fields
.rd
= fpu_status
->FPUREG
.Fpu_fsr_bits
.rd
;
2318 sfsr
.u
.fields
.rp
= fpu_status
->FPUREG
.Fpu_fsr_bits
.rp
;
2319 sfsr
.u
.fields
.tem
= fpu_status
->FPUREG
.Fpu_fsr_bits
.tem
;
2320 sfsr
.u
.fields
.res
= fpu_status
->FPUREG
.Fpu_fsr_bits
.res
;
2321 sfsr
.u
.fields
.ftt
= fpu_status
->FPUREG
.Fpu_fsr_bits
.ftt
;
2322 sfsr
.u
.fields
.qne
= fpu_status
->FPUREG
.Fpu_fsr_bits
.qne
;
2323 sfsr
.u
.fields
.pr
= fpu_status
->FPUREG
.Fpu_fsr_bits
.pr
;
2324 sfsr
.u
.fields
.fcc
= fpu_status
->FPUREG
.Fpu_fsr_bits
.fcc
;
2325 sfsr
.u
.fields
.aexc
= fpu_status
->FPUREG
.Fpu_fsr_bits
.aexc
;
2326 sfsr
.u
.fields
.cexc
= fpu_status
->FPUREG
.Fpu_fsr_bits
.cexc
;
2327 sfsr
.u
.word
= SWAP_INT(sfsr
.u
.word
);
2328 memcpy(&(fpu
->fpu
.Fpu_fsr
), &sfsr
, sizeof(struct swapped_fsr
));
2334 swap_arm_thread_state_t(
2335 arm_thread_state_t
*cpu
,
2336 enum byte_sex target_byte_sex
)
2340 for(i
= 0; i
< 13; i
++)
2341 cpu
->__r
[i
] = SWAP_INT(cpu
->__r
[i
]);
2342 cpu
->__sp
= SWAP_INT(cpu
->__sp
);
2343 cpu
->__lr
= SWAP_INT(cpu
->__lr
);
2344 cpu
->__pc
= SWAP_INT(cpu
->__pc
);
2345 cpu
->__cpsr
= SWAP_INT(cpu
->__cpsr
);
2351 struct ident_command
*id_cmd
,
2352 enum byte_sex target_byte_sex
)
2355 enum byte_sex dummy
;
2356 dummy
= target_byte_sex
;
2358 id_cmd
->cmd
= SWAP_INT(id_cmd
->cmd
);
2359 id_cmd
->cmdsize
= SWAP_INT(id_cmd
->cmdsize
);
2364 swap_routines_command(
2365 struct routines_command
*r_cmd
,
2366 enum byte_sex target_byte_sex
)
2369 enum byte_sex dummy
;
2370 dummy
= target_byte_sex
;
2372 r_cmd
->cmd
= SWAP_INT(r_cmd
->cmd
);
2373 r_cmd
->cmdsize
= SWAP_INT(r_cmd
->cmdsize
);
2374 r_cmd
->init_address
= SWAP_INT(r_cmd
->init_address
);
2375 r_cmd
->init_module
= SWAP_INT(r_cmd
->init_module
);
2376 r_cmd
->reserved1
= SWAP_INT(r_cmd
->reserved1
);
2377 r_cmd
->reserved2
= SWAP_INT(r_cmd
->reserved2
);
2378 r_cmd
->reserved3
= SWAP_INT(r_cmd
->reserved3
);
2379 r_cmd
->reserved4
= SWAP_INT(r_cmd
->reserved4
);
2380 r_cmd
->reserved5
= SWAP_INT(r_cmd
->reserved5
);
2381 r_cmd
->reserved6
= SWAP_INT(r_cmd
->reserved6
);
2386 swap_routines_command_64(
2387 struct routines_command_64
*r_cmd
,
2388 enum byte_sex target_byte_sex
)
2391 enum byte_sex dummy
;
2392 dummy
= target_byte_sex
;
2394 r_cmd
->cmd
= SWAP_INT(r_cmd
->cmd
);
2395 r_cmd
->cmdsize
= SWAP_INT(r_cmd
->cmdsize
);
2396 r_cmd
->init_address
= SWAP_LONG_LONG(r_cmd
->init_address
);
2397 r_cmd
->init_module
= SWAP_LONG_LONG(r_cmd
->init_module
);
2398 r_cmd
->reserved1
= SWAP_LONG_LONG(r_cmd
->reserved1
);
2399 r_cmd
->reserved2
= SWAP_LONG_LONG(r_cmd
->reserved2
);
2400 r_cmd
->reserved3
= SWAP_LONG_LONG(r_cmd
->reserved3
);
2401 r_cmd
->reserved4
= SWAP_LONG_LONG(r_cmd
->reserved4
);
2402 r_cmd
->reserved5
= SWAP_LONG_LONG(r_cmd
->reserved5
);
2403 r_cmd
->reserved6
= SWAP_LONG_LONG(r_cmd
->reserved6
);
2408 swap_twolevel_hints_command(
2409 struct twolevel_hints_command
*hints_cmd
,
2410 enum byte_sex target_byte_sex
)
2413 enum byte_sex dummy
;
2414 dummy
= target_byte_sex
;
2416 hints_cmd
->cmd
= SWAP_INT(hints_cmd
->cmd
);
2417 hints_cmd
->cmdsize
= SWAP_INT(hints_cmd
->cmdsize
);
2418 hints_cmd
->offset
= SWAP_INT(hints_cmd
->offset
);
2419 hints_cmd
->nhints
= SWAP_INT(hints_cmd
->nhints
);
2425 struct twolevel_hint
*hints
,
2427 enum byte_sex target_byte_sex
)
2429 struct swapped_twolevel_hint
{
2441 enum byte_sex host_byte_sex
;
2443 host_byte_sex
= get_host_byte_sex();
2445 for(i
= 0; i
< nhints
; i
++){
2446 if(target_byte_sex
== host_byte_sex
){
2447 memcpy(&shint
, hints
+ i
, sizeof(struct swapped_twolevel_hint
));
2448 shint
.u
.word
= SWAP_INT(shint
.u
.word
);
2449 hints
[i
].itoc
= shint
.u
.fields
.itoc
;
2450 hints
[i
].isub_image
= shint
.u
.fields
.isub_image
;
2453 shint
.u
.fields
.isub_image
= hints
[i
].isub_image
;
2454 shint
.u
.fields
.itoc
= hints
[i
].itoc
;
2455 shint
.u
.word
= SWAP_INT(shint
.u
.word
);
2456 memcpy(hints
+ i
, &shint
, sizeof(struct swapped_twolevel_hint
));
2463 swap_prebind_cksum_command(
2464 struct prebind_cksum_command
*cksum_cmd
,
2465 enum byte_sex target_byte_sex
)
2468 enum byte_sex dummy
;
2469 dummy
= target_byte_sex
;
2471 cksum_cmd
->cmd
= SWAP_INT(cksum_cmd
->cmd
);
2472 cksum_cmd
->cmdsize
= SWAP_INT(cksum_cmd
->cmdsize
);
2473 cksum_cmd
->cksum
= SWAP_INT(cksum_cmd
->cksum
);
2479 struct uuid_command
*uuid_cmd
,
2480 enum byte_sex target_byte_sex
)
2482 uuid_cmd
->cmd
= SWAP_INT(uuid_cmd
->cmd
);
2483 uuid_cmd
->cmdsize
= SWAP_INT(uuid_cmd
->cmdsize
);
2488 swap_linkedit_data_command(
2489 struct linkedit_data_command
*ld
,
2490 enum byte_sex target_byte_sex
)
2492 ld
->cmd
= SWAP_INT(ld
->cmd
);
2493 ld
->cmdsize
= SWAP_INT(ld
->cmdsize
);
2494 ld
->dataoff
= SWAP_INT(ld
->dataoff
);
2495 ld
->datasize
= SWAP_INT(ld
->datasize
);
2500 swap_version_min_command(
2501 struct version_min_command
*ver_cmd
,
2502 enum byte_sex target_byte_sex
)
2504 ver_cmd
->cmd
= SWAP_INT(ver_cmd
->cmd
);
2505 ver_cmd
->cmdsize
= SWAP_INT(ver_cmd
->cmdsize
);
2506 ver_cmd
->version
= SWAP_INT(ver_cmd
->version
);
2510 void swap_rpath_command(
2511 struct rpath_command
*rpath_cmd
,
2512 enum byte_sex target_byte_sex
)
2514 rpath_cmd
->cmd
= SWAP_INT(rpath_cmd
->cmd
);
2515 rpath_cmd
->cmdsize
= SWAP_INT(rpath_cmd
->cmdsize
);
2516 rpath_cmd
->path
.offset
= SWAP_INT(rpath_cmd
->path
.offset
);
2521 swap_encryption_command(
2522 struct encryption_info_command
*ec
,
2523 enum byte_sex target_byte_sex
)
2525 ec
->cmd
= SWAP_INT(ec
->cmd
);
2526 ec
->cmdsize
= SWAP_INT(ec
->cmdsize
);
2527 ec
->cryptoff
= SWAP_INT(ec
->cryptoff
);
2528 ec
->cryptsize
= SWAP_INT(ec
->cryptsize
);
2529 ec
->cryptid
= SWAP_INT(ec
->cryptid
);
2534 swap_dyld_info_command(
2535 struct dyld_info_command
*ed
,
2536 enum byte_sex target_byte_sex
)
2538 ed
->cmd
= SWAP_INT(ed
->cmd
);
2539 ed
->cmdsize
= SWAP_INT(ed
->cmdsize
);
2540 ed
->rebase_off
= SWAP_INT(ed
->rebase_off
);
2541 ed
->rebase_size
= SWAP_INT(ed
->rebase_size
);
2542 ed
->bind_off
= SWAP_INT(ed
->bind_off
);
2543 ed
->bind_size
= SWAP_INT(ed
->bind_size
);
2544 ed
->weak_bind_off
= SWAP_INT(ed
->weak_bind_off
);
2545 ed
->weak_bind_size
= SWAP_INT(ed
->weak_bind_size
);
2546 ed
->lazy_bind_off
= SWAP_INT(ed
->lazy_bind_off
);
2547 ed
->lazy_bind_size
= SWAP_INT(ed
->lazy_bind_size
);
2548 ed
->export_off
= SWAP_INT(ed
->export_off
);
2549 ed
->export_size
= SWAP_INT(ed
->export_size
);
2554 swap_entry_point_command(
2555 struct entry_point_command
*ep
,
2556 enum byte_sex target_byte_sex
)
2558 ep
->cmd
= SWAP_INT(ep
->cmd
);
2559 ep
->cmdsize
= SWAP_INT(ep
->cmdsize
);
2560 ep
->entryoff
= SWAP_LONG_LONG(ep
->entryoff
);
2561 ep
->stacksize
= SWAP_LONG_LONG(ep
->stacksize
);
2566 swap_source_version_command(
2567 struct source_version_command
*sv
,
2568 enum byte_sex target_byte_sex
)
2570 sv
->cmd
= SWAP_INT(sv
->cmd
);
2571 sv
->cmdsize
= SWAP_INT(sv
->cmdsize
);
2572 sv
->version
= SWAP_LONG_LONG(sv
->version
);
2578 struct nlist
*symbols
,
2580 enum byte_sex target_byte_sex
)
2584 enum byte_sex dummy
;
2585 dummy
= target_byte_sex
;
2588 for(i
= 0; i
< nsymbols
; i
++){
2589 symbols
[i
].n_un
.n_strx
= SWAP_INT(symbols
[i
].n_un
.n_strx
);
2592 symbols
[i
].n_desc
= SWAP_SHORT(symbols
[i
].n_desc
);
2593 symbols
[i
].n_value
= SWAP_INT(symbols
[i
].n_value
);
2600 struct nlist_64
*symbols
,
2602 enum byte_sex target_byte_sex
)
2606 enum byte_sex dummy
;
2607 dummy
= target_byte_sex
;
2610 for(i
= 0; i
< nsymbols
; i
++){
2611 symbols
[i
].n_un
.n_strx
= SWAP_INT(symbols
[i
].n_un
.n_strx
);
2614 symbols
[i
].n_desc
= SWAP_SHORT(symbols
[i
].n_desc
);
2615 symbols
[i
].n_value
= SWAP_LONG_LONG(symbols
[i
].n_value
);
2622 struct ranlib
*ranlibs
,
2624 enum byte_sex target_byte_sex
)
2628 enum byte_sex dummy
;
2629 dummy
= target_byte_sex
;
2632 for(i
= 0; i
< nranlibs
; i
++){
2633 ranlibs
[i
].ran_un
.ran_strx
= SWAP_INT(ranlibs
[i
].ran_un
.ran_strx
);
2634 ranlibs
[i
].ran_off
= SWAP_INT(ranlibs
[i
].ran_off
);
2640 swap_relocation_info(
2641 struct relocation_info
*relocs
,
2643 enum byte_sex target_byte_sex
)
2646 enum byte_sex host_byte_sex
;
2647 enum bool to_host_byte_sex
, scattered
;
2649 struct swapped_relocation_info
{
2664 struct swapped_scattered_relocation_info
{
2669 host_byte_sex
= get_host_byte_sex();
2670 to_host_byte_sex
= (enum bool)(target_byte_sex
== host_byte_sex
);
2672 for(i
= 0; i
< nrelocs
; i
++){
2673 if(to_host_byte_sex
)
2674 scattered
= (enum bool)(
2675 (SWAP_INT(relocs
[i
].r_address
) & R_SCATTERED
) != 0);
2677 scattered
= (enum bool)
2678 (((relocs
[i
].r_address
) & R_SCATTERED
) != 0);
2679 if(scattered
== FALSE
){
2680 if(to_host_byte_sex
){
2681 memcpy(&sr
, relocs
+ i
, sizeof(struct relocation_info
));
2682 sr
.r_address
= SWAP_INT(sr
.r_address
);
2683 sr
.u
.word
= SWAP_INT(sr
.u
.word
);
2684 relocs
[i
].r_address
= sr
.r_address
;
2685 relocs
[i
].r_symbolnum
= sr
.u
.fields
.r_symbolnum
;
2686 relocs
[i
].r_pcrel
= sr
.u
.fields
.r_pcrel
;
2687 relocs
[i
].r_length
= sr
.u
.fields
.r_length
;
2688 relocs
[i
].r_extern
= sr
.u
.fields
.r_extern
;
2689 relocs
[i
].r_type
= sr
.u
.fields
.r_type
;
2692 sr
.r_address
= relocs
[i
].r_address
;
2693 sr
.u
.fields
.r_symbolnum
= relocs
[i
].r_symbolnum
;
2694 sr
.u
.fields
.r_length
= relocs
[i
].r_length
;
2695 sr
.u
.fields
.r_pcrel
= relocs
[i
].r_pcrel
;
2696 sr
.u
.fields
.r_extern
= relocs
[i
].r_extern
;
2697 sr
.u
.fields
.r_type
= relocs
[i
].r_type
;
2698 sr
.r_address
= SWAP_INT(sr
.r_address
);
2699 sr
.u
.word
= SWAP_INT(sr
.u
.word
);
2700 memcpy(relocs
+ i
, &sr
, sizeof(struct relocation_info
));
2704 ssr
= (struct swapped_scattered_relocation_info
*)(relocs
+ i
);
2705 ssr
->word
= SWAP_INT(ssr
->word
);
2706 ssr
->r_value
= SWAP_INT(ssr
->r_value
);
2713 swap_indirect_symbols(
2714 uint32_t *indirect_symbols
,
2715 uint32_t nindirect_symbols
,
2716 enum byte_sex target_byte_sex
)
2720 enum byte_sex dummy
;
2721 dummy
= target_byte_sex
;
2724 for(i
= 0; i
< nindirect_symbols
; i
++)
2725 indirect_symbols
[i
] = SWAP_INT(indirect_symbols
[i
]);
2730 swap_dylib_reference(
2731 struct dylib_reference
*refs
,
2733 enum byte_sex target_byte_sex
)
2735 struct swapped_dylib_reference
{
2747 enum byte_sex host_byte_sex
;
2749 host_byte_sex
= get_host_byte_sex();
2751 for(i
= 0; i
< nrefs
; i
++){
2752 if(target_byte_sex
== host_byte_sex
){
2753 memcpy(&sref
, refs
+ i
, sizeof(struct swapped_dylib_reference
));
2754 sref
.u
.word
= SWAP_INT(sref
.u
.word
);
2755 refs
[i
].flags
= sref
.u
.fields
.flags
;
2756 refs
[i
].isym
= sref
.u
.fields
.isym
;
2759 sref
.u
.fields
.isym
= refs
[i
].isym
;
2760 sref
.u
.fields
.flags
= refs
[i
].flags
;
2761 sref
.u
.word
= SWAP_INT(sref
.u
.word
);
2762 memcpy(refs
+ i
, &sref
, sizeof(struct swapped_dylib_reference
));
2771 struct dylib_module
*mods
,
2773 enum byte_sex target_byte_sex
)
2777 enum byte_sex dummy
;
2778 dummy
= target_byte_sex
;
2781 for(i
= 0; i
< nmods
; i
++){
2782 mods
[i
].module_name
= SWAP_INT(mods
[i
].module_name
);
2783 mods
[i
].iextdefsym
= SWAP_INT(mods
[i
].iextdefsym
);
2784 mods
[i
].nextdefsym
= SWAP_INT(mods
[i
].nextdefsym
);
2785 mods
[i
].irefsym
= SWAP_INT(mods
[i
].irefsym
);
2786 mods
[i
].nrefsym
= SWAP_INT(mods
[i
].nrefsym
);
2787 mods
[i
].ilocalsym
= SWAP_INT(mods
[i
].ilocalsym
);
2788 mods
[i
].nlocalsym
= SWAP_INT(mods
[i
].nlocalsym
);
2789 mods
[i
].iextrel
= SWAP_INT(mods
[i
].iextrel
);
2790 mods
[i
].nextrel
= SWAP_INT(mods
[i
].nextrel
);
2791 mods
[i
].iinit_iterm
= SWAP_INT(mods
[i
].iinit_iterm
);
2792 mods
[i
].ninit_nterm
= SWAP_INT(mods
[i
].ninit_nterm
);
2793 mods
[i
].objc_module_info_addr
=
2794 SWAP_INT(mods
[i
].objc_module_info_addr
);
2795 mods
[i
].objc_module_info_size
=
2796 SWAP_INT(mods
[i
].objc_module_info_size
);
2802 swap_dylib_module_64(
2803 struct dylib_module_64
*mods
,
2805 enum byte_sex target_byte_sex
)
2809 enum byte_sex dummy
;
2810 dummy
= target_byte_sex
;
2813 for(i
= 0; i
< nmods
; i
++){
2814 mods
[i
].module_name
= SWAP_INT(mods
[i
].module_name
);
2815 mods
[i
].iextdefsym
= SWAP_INT(mods
[i
].iextdefsym
);
2816 mods
[i
].nextdefsym
= SWAP_INT(mods
[i
].nextdefsym
);
2817 mods
[i
].irefsym
= SWAP_INT(mods
[i
].irefsym
);
2818 mods
[i
].nrefsym
= SWAP_INT(mods
[i
].nrefsym
);
2819 mods
[i
].ilocalsym
= SWAP_INT(mods
[i
].ilocalsym
);
2820 mods
[i
].nlocalsym
= SWAP_INT(mods
[i
].nlocalsym
);
2821 mods
[i
].iextrel
= SWAP_INT(mods
[i
].iextrel
);
2822 mods
[i
].nextrel
= SWAP_INT(mods
[i
].nextrel
);
2823 mods
[i
].iinit_iterm
= SWAP_INT(mods
[i
].iinit_iterm
);
2824 mods
[i
].ninit_nterm
= SWAP_INT(mods
[i
].ninit_nterm
);
2825 mods
[i
].objc_module_info_addr
=
2826 SWAP_LONG_LONG(mods
[i
].objc_module_info_addr
);
2827 mods
[i
].objc_module_info_size
=
2828 SWAP_LONG_LONG(mods
[i
].objc_module_info_size
);
2834 swap_dylib_table_of_contents(
2835 struct dylib_table_of_contents
*tocs
,
2837 enum byte_sex target_byte_sex
)
2841 enum byte_sex dummy
;
2842 dummy
= target_byte_sex
;
2845 for(i
= 0; i
< ntocs
; i
++){
2846 tocs
[i
].symbol_index
= SWAP_INT(tocs
[i
].symbol_index
);
2847 tocs
[i
].module_index
= SWAP_INT(tocs
[i
].module_index
);