Permalink
Browse files

Use values in classic weak binds

  • Loading branch information...
1 parent f61b3e1 commit 8734f13fa114e3d3675213d1a5fc3b2c17cafe98 @shinh committed Dec 7, 2011
Showing with 17 additions and 7 deletions.
  1. +5 −1 ld-mac.cc
  2. +7 −5 mach-o.cc
  3. +5 −1 mach-o.h
View
@@ -531,7 +531,11 @@ class MachOLoader {
seen_weak_binds_[seen_weak_bind_index].second;
seen_weak_bind_index++;
} else {
- last_weak_sym = (char*)*ptr;
+ if (bind->is_classic) {
+ *ptr = last_weak_sym = (char*)bind->value;
+ } 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 &&
strcmp(
View
@@ -145,13 +145,15 @@ class MachOImpl : public MachO {
MachO::Bind* bind = new MachO::Bind();
bind->name = symstrtab + sym->n_strx;
bind->vmaddr = sec.addr + i * ptrsize_;
- bind->addend = 0;
+ bind->value = sym->n_value;
bind->type = BIND_TYPE_POINTER;
bind->ordinal = 1;
+ bind->is_weak = ((sym->n_desc & N_WEAK_DEF) != 0);
+ bind->is_classic = true;
LOGF("add classic bind! %s type=%d sect=%d desc=%d value=%lld "
- "vmaddr=%p\n",
+ "vmaddr=%p is_weak=%d\n",
bind->name, sym->n_type, sym->n_sect, sym->n_desc, (ll)sym->n_value,
- (void*)(bind->vmaddr));
+ (void*)(bind->vmaddr), bind->is_weak);
binds_.push_back(bind);
}
}
@@ -431,9 +433,9 @@ struct MachOImpl::BindState {
vmaddr = mach->segments_[seg_index]->vmaddr;
}
LOGF("add bind! %s seg_index=%d seg_offset=%llu "
- "type=%d ordinal=%d addend=%lld vmaddr=%p\n",
+ "type=%d ordinal=%d addend=%lld vmaddr=%p is_weak=%d\n",
sym_name, seg_index, (ull)seg_offset,
- type, ordinal, (ll)addend, (void*)(vmaddr + seg_offset));
+ type, ordinal, (ll)addend, (void*)(vmaddr + seg_offset), is_weak);
bind->name = sym_name;
bind->vmaddr = vmaddr + seg_offset;
bind->addend = addend;
View
@@ -47,10 +47,14 @@ class MachO {
struct Bind {
uint64_t vmaddr;
const char* name;
- int64_t addend;
+ union {
+ int64_t addend;
+ uint64_t value;
+ };
uint8_t type;
uint8_t ordinal;
bool is_weak;
+ bool is_classic;
};
struct Export {

0 comments on commit 8734f13

Please sign in to comment.