]> git.saurik.com Git - apple/ld64.git/blobdiff - src/other/rebase.cpp
ld64-136.tar.gz
[apple/ld64.git] / src / other / rebase.cpp
index c04fb0a941e29b1fe22992f299563109efff0582..e2776cf0b10c4b9c1007a8f8dab1e6554bf07a3f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*- 
  *
- * Copyright (c) 2006-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2006-2012 Apple Inc. All rights reserved.
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
@@ -32,6 +32,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <vector>
 #include <set>
 
@@ -650,13 +651,7 @@ void Rebaser<ppc>::doLocalRelocation(const macho_relocation_info<P>* reloc)
                }
        }
        else {
-               macho_scattered_relocation_info<P>* sreloc = (macho_scattered_relocation_info<P>*)reloc;
-               if ( sreloc->r_type() == PPC_RELOC_PB_LA_PTR ) {
-                       sreloc->set_r_value( sreloc->r_value() + fSlide );
-               }
-               else {
-                       throw "cannot rebase final linked image with scattered relocations";
-               }
+               throw "cannot rebase final linked image with scattered relocations";
        }
 }
 
@@ -680,6 +675,7 @@ void Rebaser<x86>::doLocalRelocation(const macho_relocation_info<P>* reloc)
        }
 }
 
+#if SUPPORT_ARCH_arm_any
 template <>
 void Rebaser<arm>::doLocalRelocation(const macho_relocation_info<P>* reloc)
 {
@@ -699,6 +695,7 @@ void Rebaser<arm>::doLocalRelocation(const macho_relocation_info<P>* reloc)
                }
        }
 }
+#endif
 
 template <typename A>
 void Rebaser<A>::doLocalRelocation(const macho_relocation_info<P>* reloc)
@@ -1014,21 +1011,18 @@ int main(int argc, const char* argv[])
                                        highAddress = strtoull(argv[++i], &endptr, 16);
                                }
                                else if ( strcmp(arg, "-arch") == 0 ) {
-                                       const char* arch = argv[++i];
-                                       if ( strcmp(arch, "ppc") == 0 ) 
-                                               onlyArchs.insert(CPU_TYPE_POWERPC);
-                                       else if ( strcmp(arch, "ppc64") == 0 )
-                                               onlyArchs.insert(CPU_TYPE_POWERPC64);
-                                       else if ( strcmp(arch, "i386") == 0 )
-                                               onlyArchs.insert(CPU_TYPE_I386);
-                                       else if ( strcmp(arch, "x86_64") == 0 )
-                                               onlyArchs.insert(CPU_TYPE_X86_64);
-                                       else if ( strcmp(arch, "arm") == 0 )
-                                               onlyArchs.insert(CPU_TYPE_ARM);
-                                       else if ( strcmp(arch, "armv6") == 0 )
-                                               onlyArchs.insert(CPU_TYPE_ARM);
-                                       else 
-                                               throwf("unknown architecture %s", arch);
+                                       const char* archName = argv[++i];
+                                       if ( archName == NULL )
+                                               throw "-arch missing architecture name";
+                                       bool found = false;
+                                       for (const ArchInfo* t=archInfoArray; t->archName != NULL; ++t) {
+                                               if ( strcmp(t->archName,archName) == 0 ) {
+                                                       onlyArchs.insert(t->cpuType);
+                                                       found = true;
+                                               }
+                                       }
+                                       if ( !found )
+                                               throwf("unknown architecture %s", archName);
                                }
                                else {
                                        usage();