#endif
#if defined(USE_RELA)
- if (rela != nullptr) {
- DEBUG("[ relocating %s ]", name);
- if (Relocate(rela, rela_count)) {
- return false;
- }
+ if (rela != nullptr) {
+ DEBUG("[ relocating %s ]", name);
+ if (Relocate(rela, rela_count)) {
+ return false;
}
- if (plt_rela != nullptr) {
- DEBUG("[ relocating %s plt ]", name);
- if (Relocate(plt_rela, plt_rela_count)) {
- return false;
- }
+ }
+ if (plt_rela != nullptr) {
+ DEBUG("[ relocating %s plt ]", name);
+ if (Relocate(plt_rela, plt_rela_count)) {
+ return false;
}
+ }
#else
- if (rel != nullptr) {
- DEBUG("[ relocating %s ]", name);
- if (Relocate(rel, rel_count)) {
- return false;
- }
+ if (rel != nullptr) {
+ DEBUG("[ relocating %s ]", name);
+ if (Relocate(rel, rel_count)) {
+ return false;
}
- if (plt_rel != nullptr) {
- DEBUG("[ relocating %s plt ]", name);
- if (Relocate(plt_rel, plt_rel_count)) {
- return false;
- }
+ }
+ if (plt_rel != nullptr) {
+ DEBUG("[ relocating %s plt ]", name);
+ if (Relocate(plt_rel, plt_rel_count)) {
+ return false;
}
+ }
#endif
- // if there are ifuncs, we need to do an additional relocation pass.
- // they cannot be resolved until the rest of the relocations are done
- // because we need to call the resolution function which may be waiting
- // on relocations.
- if(get_has_ifuncs()) {
- #if defined(__i386__)
- soinfo_ifunc_relocate(this, plt_rel, plt_rel_count);
- #elif defined(__x86_64__)
- soinfo_ifunc_relocate(this, plt_rela, plt_rela_count);
- #endif
- }
-
#if defined(__mips__)
- if (!mips_relocate_got(this)) {
- return false;
- }
+ if (!mips_relocate_got(this)) {
+ return false;
+ }
#endif
- DEBUG("[ finished linking %s ]", name);
+ DEBUG("[ finished linking %s ]", name);
#if !defined(__LP64__)
- if (has_text_relocations) {
- // All relocations are done, we can protect our segments back to read-only.
- if (phdr_table_protect_segments(phdr, phnum, load_bias) < 0) {
- DL_ERR("can't protect segments for \"%s\": %s",
- name, strerror(errno));
- return false;
- }
+ if (has_text_relocations) {
+ // All relocations are done, we can protect our segments back to read-only.
+ if (phdr_table_protect_segments(phdr, phnum, load_bias) < 0) {
+ DL_ERR("can't protect segments for \"%s\": %s",
+ name, strerror(errno));
+ return false;
}
+ }
#endif
- /* We can also turn on GNU RELRO protection */
- if (phdr_table_protect_gnu_relro(phdr, phnum, load_bias) < 0) {
- DL_ERR("can't enable GNU RELRO protection for \"%s\": %s",
- name, strerror(errno));
- return false;
- }
+ /* We can also turn on GNU RELRO protection */
+ if (phdr_table_protect_gnu_relro(phdr, phnum, load_bias) < 0) {
+ DL_ERR("can't enable GNU RELRO protection for \"%s\": %s",
+ name, strerror(errno));
+ return false;
+ }
- /* Handle serializing/sharing the RELRO segment */
- if (extinfo && (extinfo->flags & ANDROID_DLEXT_WRITE_RELRO)) {
- if (phdr_table_serialize_gnu_relro(phdr, phnum, load_bias,
- extinfo->relro_fd) < 0) {
- DL_ERR("failed serializing GNU RELRO section for \"%s\": %s",
- name, strerror(errno));
- return false;
- }
- } else if (extinfo && (extinfo->flags & ANDROID_DLEXT_USE_RELRO)) {
- if (phdr_table_map_gnu_relro(phdr, phnum, load_bias,
- extinfo->relro_fd) < 0) {
- DL_ERR("failed mapping GNU RELRO section for \"%s\": %s",
- name, strerror(errno));
- return false;
- }
+ /* Handle serializing/sharing the RELRO segment */
+ if (extinfo && (extinfo->flags & ANDROID_DLEXT_WRITE_RELRO)) {
+ if (phdr_table_serialize_gnu_relro(phdr, phnum, load_bias,
+ extinfo->relro_fd) < 0) {
+ DL_ERR("failed serializing GNU RELRO section for \"%s\": %s",
+ name, strerror(errno));
+ return false;
}
+ } else if (extinfo && (extinfo->flags & ANDROID_DLEXT_USE_RELRO)) {
+ if (phdr_table_map_gnu_relro(phdr, phnum, load_bias,
+ extinfo->relro_fd) < 0) {
+ DL_ERR("failed mapping GNU RELRO section for \"%s\": %s",
+ name, strerror(errno));
+ return false;
+ }
+ }
- notify_gdb_of_load(this);
- return true;
+ notify_gdb_of_load(this);
+ return true;
}
/*