linux: fix build
[odcctools-svp.git] / ld64 / Writers / ExecutableFileMachO-all.cpp
blob206503aca1ad705f456b00808190542cbbced7d5
1 /*
2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #include <string.h>
25 #include <stdint.h>
26 #include <stddef.h>
27 #include <fcntl.h>
28 #include <unistd.h>
29 #include <sys/time.h>
30 #include <mach-o/loader.h>
31 #include <mach-o/nlist.h>
32 #include <mach-o/reloc.h>
33 #include <mach-o/ppc/reloc.h>
34 #include <mach-o/stab.h>
36 #include <vector>
37 #include <algorithm>
38 #include <map>
39 #include <set>
41 #include "ObjectFile.h"
42 #include "ExecutableFile.h"
43 #include "Options.h"
45 // buiild Writer for -arch ppc64
46 #undef MACHO_32_SAME_ENDIAN
47 #undef MACHO_32_OPPOSITE_ENDIAN
48 #undef MACHO_64_SAME_ENDIAN
49 #undef MACHO_64_OPPOSITE_ENDIAN
50 #if __ppc__ || __ppc64__
51 #define MACHO_64_SAME_ENDIAN
52 #elif __i386__
53 #define MACHO_64_OPPOSITE_ENDIAN
54 #else
55 #error unknown architecture
56 #endif
57 namespace ppc64 {
58 #undef ARCH_PPC
59 #define ARCH_PPC64
60 #undef ARCH_I386
61 #include "MachOAbstraction.h"
62 #include "ExecutableFileMachO.cpp"
65 // buiild Writer for -arch ppc
66 #undef MACHO_32_SAME_ENDIAN
67 #undef MACHO_32_OPPOSITE_ENDIAN
68 #undef MACHO_64_SAME_ENDIAN
69 #undef MACHO_64_OPPOSITE_ENDIAN
70 #if __ppc__ || __ppc64__
71 #define MACHO_32_SAME_ENDIAN
72 #elif __i386__
73 #define MACHO_32_OPPOSITE_ENDIAN
74 #else
75 #error unknown architecture
76 #endif
77 namespace ppc {
78 #define ARCH_PPC
79 #undef ARCH_PPC64
80 #undef ARCH_I386
81 #include "MachOAbstraction.h"
82 #include "ExecutableFileMachO.cpp"
85 // buiild Writer for -arch i386
86 #undef MACHO_32_SAME_ENDIAN
87 #undef MACHO_32_OPPOSITE_ENDIAN
88 #undef MACHO_64_SAME_ENDIAN
89 #undef MACHO_64_OPPOSITE_ENDIAN
90 #if __ppc__ || __ppc64__
91 #define MACHO_32_OPPOSITE_ENDIAN
92 #elif __i386__
93 #define MACHO_32_SAME_ENDIAN
94 #else
95 #error unknown architecture
96 #endif
97 #undef i386 // compiler sometimes #defines this
98 namespace i386 {
99 #undef ARCH_PPC
100 #undef ARCH_PPC64
101 #define ARCH_I386
102 #include "MachOAbstraction.h"
103 #include "ExecutableFileMachO.cpp"