summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2012-09-06 06:18:18 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2012-09-06 06:23:41 -0700
commit6ab830a5a2968c5b598407bd3753b75123c895f0 (patch)
tree3737635e6607f10999d8d68243b15d3dc928f92b
parent429e34a56273888b7b1b600727aed150f0a91738 (diff)
downloadldid-6ab830a5a2968c5b598407bd3753b75123c895f0.tar.gz
ldid-6ab830a5a2968c5b598407bd3753b75123c895f0.tar.zst
ldid-6ab830a5a2968c5b598407bd3753b75123c895f0.zip
Add the -O flag I used to munge extracted dylibs.
-rw-r--r--ldid.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/ldid.cpp b/ldid.cpp
index 9005c39..bcad71e 100644
--- a/ldid.cpp
+++ b/ldid.cpp
@@ -685,6 +685,8 @@ int main(int argc, const char *argv[]) {
bool flag_S(false);
bool flag_s(false);
+ bool flag_O(false);
+
bool timeh(false);
uint32_t timev(0);
@@ -715,6 +717,7 @@ int main(int argc, const char *argv[]) {
case 'u': flag_u = true; break;
case 'p': flag_p = true; break;
case 'e': flag_e = true; break;
+ case 'O': flag_O = true; break;
case 's':
_assert(!flag_S);
@@ -936,7 +939,7 @@ int main(int argc, const char *argv[]) {
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)));
+ FatHeader fat_header(Map(temp == NULL ? path : temp, !(flag_R | flag_T | flag_s | flag_S | flag_O)));
struct linkedit_data_command *signature(NULL);
_foreach (mach_header, fat_header.GetMachHeaders()) {
@@ -951,6 +954,11 @@ int main(int argc, const char *argv[]) {
if (noffset != _not(uintptr_t))
printf("%s\n", &*mach_header.GetPointer<char>(noffset));
+ if (flag_O) {
+ _foreach(section, mach_header.GetSections("__TEXT", "__text"))
+ section->addr = mach_header.Swap(0);
+ }
+
_foreach (load_command, mach_header.GetLoadCommands()) {
uint32_t cmd(mach_header.Swap(load_command->cmd));