|
1 // Copyright (c) 2012, Google Inc. |
|
2 // All rights reserved. |
|
3 // |
|
4 // Redistribution and use in source and binary forms, with or without |
|
5 // modification, are permitted provided that the following conditions are |
|
6 // met: |
|
7 // |
|
8 // * Redistributions of source code must retain the above copyright |
|
9 // notice, this list of conditions and the following disclaimer. |
|
10 // * Redistributions in binary form must reproduce the above |
|
11 // copyright notice, this list of conditions and the following disclaimer |
|
12 // in the documentation and/or other materials provided with the |
|
13 // distribution. |
|
14 // * Neither the name of Google Inc. nor the names of its |
|
15 // contributors may be used to endorse or promote products derived from |
|
16 // this software without specific prior written permission. |
|
17 // |
|
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
29 |
|
30 #include "common/mac/arch_utilities.h" |
|
31 |
|
32 #include <mach-o/arch.h> |
|
33 #include <stdio.h> |
|
34 #include <string.h> |
|
35 |
|
36 #ifndef CPU_TYPE_ARM |
|
37 #define CPU_TYPE_ARM (static_cast<cpu_type_t>(12)) |
|
38 #endif // CPU_TYPE_ARM |
|
39 |
|
40 #ifndef CPU_SUBTYPE_ARM_V7 |
|
41 #define CPU_SUBTYPE_ARM_V7 (static_cast<cpu_subtype_t>(9)) |
|
42 #endif // CPU_SUBTYPE_ARM_V7 |
|
43 |
|
44 #ifndef CPU_SUBTYPE_ARM_V7S |
|
45 #define CPU_SUBTYPE_ARM_V7S (static_cast<cpu_subtype_t>(11)) |
|
46 #endif // CPU_SUBTYPE_ARM_V7S |
|
47 |
|
48 namespace { |
|
49 |
|
50 const NXArchInfo* ArchInfo_armv7s() { |
|
51 NXArchInfo* armv7s = new NXArchInfo; |
|
52 *armv7s = *NXGetArchInfoFromCpuType(CPU_TYPE_ARM, |
|
53 CPU_SUBTYPE_ARM_V7); |
|
54 armv7s->name = "armv7s"; |
|
55 armv7s->cpusubtype = CPU_SUBTYPE_ARM_V7S; |
|
56 armv7s->description = "arm v7s"; |
|
57 return armv7s; |
|
58 } |
|
59 |
|
60 } // namespace |
|
61 |
|
62 namespace google_breakpad { |
|
63 |
|
64 const NXArchInfo* BreakpadGetArchInfoFromName(const char* arch_name) { |
|
65 // TODO: Remove this when the OS knows about armv7s. |
|
66 if (!strcmp("armv7s", arch_name)) |
|
67 return BreakpadGetArchInfoFromCpuType(CPU_TYPE_ARM, CPU_SUBTYPE_ARM_V7S); |
|
68 return NXGetArchInfoFromName(arch_name); |
|
69 } |
|
70 |
|
71 const NXArchInfo* BreakpadGetArchInfoFromCpuType(cpu_type_t cpu_type, |
|
72 cpu_subtype_t cpu_subtype) { |
|
73 // TODO: Remove this when the OS knows about armv7s. |
|
74 if (cpu_type == CPU_TYPE_ARM && cpu_subtype == CPU_SUBTYPE_ARM_V7S) { |
|
75 static const NXArchInfo* armv7s = ArchInfo_armv7s(); |
|
76 return armv7s; |
|
77 } |
|
78 return NXGetArchInfoFromCpuType(cpu_type, cpu_subtype); |
|
79 } |
|
80 |
|
81 } // namespace google_breakpad |