Skip to content
Browse files

Fixes for classic (<10.5) binaries

- Read LC_DYLD_INFO
- Handle exports before binds
- Check export table even for weak binds
  • Loading branch information...
1 parent 8734f13 commit 578be2bb373ba530a46ad9e095fc98162a312444 Shinichiro Hamaji committed Dec 12, 2011
Showing with 10 additions and 3 deletions.
  1. +9 −3 ld-mac.cc
  2. +1 −0 mach-o.cc
View
12 ld-mac.cc
@@ -534,7 +534,13 @@ class MachOLoader {
if (bind->is_classic) {
*ptr = last_weak_sym = (char*)bind->value;
} else {
- last_weak_sym = (char*)*ptr;
+ const Exports::const_iterator export_found =
+ exports_.find(bind->name);
+ if (export_found != exports_.end()) {
+ *ptr = last_weak_sym = (char*)export_found->second.addr;
+ } else {
+ last_weak_sym = (char*)*ptr;
+ }
}
seen_weak_binds_.push_back(make_pair(name, last_weak_sym));
while (seen_weak_bind_index != seen_weak_binds_orig_size &&
@@ -668,10 +674,10 @@ class MachOLoader {
loadDylibs(mach);
- doBind(mach, slide);
-
loadExports(mach, base, exports);
+ doBind(mach, slide);
+
loadSymbols(mach, slide, base);
}
View
1 mach-o.cc
@@ -581,6 +581,7 @@ MachOImpl::MachOImpl(const char* filename, int fd, size_t offset, size_t len,
break;
}
+ case LC_DYLD_INFO:
case LC_DYLD_INFO_ONLY: {
dyinfo = reinterpret_cast<dyld_info_command*>(cmds_ptr);
LOGF("dyld info: rebase_off=%u rebase_size=%u "

0 comments on commit 578be2b

Please sign in to comment.
Something went wrong with that request. Please try again.