* Copyright (C) 2007-2012 Jay Freeman (saurik)
*/
-/* GNU Lesser General Public License, Version 3 {{{ */
-/* This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+/* GNU Affero General Public License, Version 3 {{{ */
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
- *
+
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
/* }}} */
#define MH_DYLDLINK 0x4
+#define MH_OBJECT 0x1
#define MH_EXECUTE 0x2
#define MH_DYLIB 0x6
#define MH_BUNDLE 0x8
uint32_t cryptid;
} _packed;
+#define BIND_OPCODE_MASK 0xf0
+#define BIND_IMMEDIATE_MASK 0x0f
+#define BIND_OPCODE_DONE 0x00
+#define BIND_OPCODE_SET_DYLIB_ORDINAL_IMM 0x10
+#define BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB 0x20
+#define BIND_OPCODE_SET_DYLIB_SPECIAL_IMM 0x30
+#define BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM 0x40
+#define BIND_OPCODE_SET_TYPE_IMM 0x50
+#define BIND_OPCODE_SET_ADDEND_SLEB 0x60
+#define BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB 0x70
+#define BIND_OPCODE_ADD_ADDR_ULEB 0x80
+#define BIND_OPCODE_DO_BIND 0x90
+#define BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB 0xa0
+#define BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED 0xb0
+#define BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB 0xc0
+
uint16_t Swap_(uint16_t value) {
return
((value >> 8) & 0x00ff) |
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)); {
}
}
- _assert(clip != 0);
- _syscall(truncate(path, clip));
+ if (clip != 0)
+ _syscall(truncate(path, clip));
}
if (flag_S) {
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)); {
}
}
+ if (!allocations.empty()) {
+
pid_t pid = fork();
_syscall(pid);
if (pid == 0) {
_syscall(waitpid(pid, &status, 0));
_assert(WIFEXITED(status));
_assert(WEXITSTATUS(status) == 0);
+
+ }
}
if (flag_p)
printf("path%zu='%s'\n", filei, file.c_str());
- FatHeader fat_header(Map(temp == NULL ? path : temp, !(flag_R | flag_T | flag_s | flag_S | flag_O | flag_D)));
+ FatHeader fat_header(Map(temp == NULL ? path : temp, !(flag_R || flag_T || flag_s || flag_S || flag_O || flag_D)));
struct linkedit_data_command *signature(NULL);
_foreach (mach_header, fat_header.GetMachHeaders()) {