]> git.cameronkatri.com Git - ldid.git/blobdiff - ldid.cpp
Use the new -A cpu filter when using -r and -S.
[ldid.git] / ldid.cpp
index 6250a7de522f703d39e610824796b6f4e2735485..3845e2c5ebaa4566392114ce9138184b36650c98 100644 (file)
--- a/ldid.cpp
+++ b/ldid.cpp
@@ -819,6 +819,13 @@ int main(int argc, const char *argv[]) {
             uint32_t clip(0); {
                 FatHeader fat_header(Map(path));
                 _foreach (mach_header, fat_header.GetMachHeaders()) {
+                    if (flag_A) {
+                        if (mach_header.GetCPUType() != flag_CPUType)
+                            continue;
+                        if (mach_header.GetCPUSubtype() != flag_CPUSubtype)
+                            continue;
+                    }
+
                     mach_header->flags = mach_header.Swap(mach_header.Swap(mach_header->flags) | MH_DYLDLINK);
 
                     uint32_t size(_not(uint32_t)); {
@@ -865,8 +872,8 @@ int main(int argc, const char *argv[]) {
                 }
             }
 
-            _assert(clip != 0);
-            _syscall(truncate(path, clip));
+            if (clip != 0)
+                _syscall(truncate(path, clip));
         }
 
         if (flag_S) {
@@ -878,6 +885,13 @@ int main(int argc, const char *argv[]) {
             std::vector<CodesignAllocation> allocations; {
                 FatHeader fat_header(Map(path));
                 _foreach (mach_header, fat_header.GetMachHeaders()) {
+                    if (flag_A) {
+                        if (mach_header.GetCPUType() != flag_CPUType)
+                            continue;
+                        if (mach_header.GetCPUSubtype() != flag_CPUSubtype)
+                            continue;
+                    }
+
                     mach_header->flags = mach_header.Swap(mach_header.Swap(mach_header->flags) | MH_DYLDLINK);
 
                     size_t size(_not(size_t)); {
@@ -899,6 +913,8 @@ int main(int argc, const char *argv[]) {
                 }
             }
 
+            if (!allocations.empty()) {
+
             pid_t pid = fork();
             _syscall(pid);
             if (pid == 0) {
@@ -971,6 +987,8 @@ int main(int argc, const char *argv[]) {
             _syscall(waitpid(pid, &status, 0));
             _assert(WIFEXITED(status));
             _assert(WEXITSTATUS(status) == 0);
+
+            }
         }
 
         if (flag_p)