summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-01-23 18:32:40 -0500
committerRich Felker <dalias@aerifal.cx>2012-01-23 18:32:40 -0500
commitfd7015d0c23edb9ae655e5ce3677f980f0cb1143 (patch)
tree9c68685e47eeced2893f5b789cdbd8d8fe87b4c5
parente12fe65c928f038fb8db0caddcf535ab0a980c58 (diff)
downloadmusl-fd7015d0c23edb9ae655e5ce3677f980f0cb1143.tar.gz
musl-fd7015d0c23edb9ae655e5ce3677f980f0cb1143.tar.bz2
musl-fd7015d0c23edb9ae655e5ce3677f980f0cb1143.tar.xz
musl-fd7015d0c23edb9ae655e5ce3677f980f0cb1143.zip
fix broken copy relocations from dynamic linker cleanup
this issue affected programs which use global variables exported by non-libc libraries.
-rw-r--r--src/ldso/dynlink.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index df54230c..28b86bf7 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -563,10 +563,13 @@ void *__dynlink(int argc, char **argv)
ehdr->e_phentsize, ehdr->e_phnum);
/* Load preload/needed libraries, add their symbols to the global
- * namespace, and perform all remaining relocations. */
+ * namespace, and perform all remaining relocations. The main
+ * program must be relocated LAST since it may contain copy
+ * relocations which depend on libraries' relocations. */
if (env_preload) load_preload(env_preload);
load_deps(app);
make_global(app);
+ reloc_all(app->next);
reloc_all(app);
/* Switch to runtime mode: any further failures in the dynamic