]> git.saurik.com Git - ldid.git/blobdiff - ldid.cpp
Update copyright and description.
[ldid.git] / ldid.cpp
index 8700e7e16dd0ff27a70e5acee7552855d3482ca0..ff9358d23917bc83843f5fd18bc8e7168267a718 100644 (file)
--- a/ldid.cpp
+++ b/ldid.cpp
@@ -1,5 +1,5 @@
-/* JocStrap - Java/Objective-C Bootstrap
- * Copyright (C) 2007  Jay Freeman (saurik)
+/* ldid - (Mach-O) Link-Loader Identity Editor
+ * Copyright (C) 2007-2010  Jay Freeman (saurik)
 */
 
 /*
@@ -178,12 +178,14 @@ int32_t Swap_(int32_t value) {
     return Swap_(static_cast<uint32_t>(value));
 }
 
+bool little_(true);
+
 uint16_t Swap(uint16_t value) {
-    return true ? Swap_(value) : value;
+    return little_ ? Swap_(value) : value;
 }
 
 uint32_t Swap(uint32_t value) {
-    return true ? Swap_(value) : value;
+    return little_ ? Swap_(value) : value;
 }
 
 int16_t Swap(int16_t value) {
@@ -463,6 +465,13 @@ void sha1(uint8_t *hash, uint8_t *data, size_t size) {
 }
 
 int main(int argc, const char *argv[]) {
+    union {
+        uint16_t word;
+        uint8_t byte[2];
+    } endian = {1};
+
+    little_ = endian.byte[0];
+
     bool flag_R(false);
     bool flag_t(false);
     bool flag_p(false);
@@ -571,7 +580,7 @@ int main(int argc, const char *argv[]) {
             size_t size = _not(size_t);
             const char *arch; {
                 Framework framework(path);
-                framework->flags |= MH_DYLDLINK;
+                framework->flags = framework.Swap(framework.Swap(framework->flags) | MH_DYLDLINK);
 
                 _foreach (load_command, framework.GetLoadCommands()) {
                     uint32_t cmd(framework.Swap((*load_command)->cmd));