OSDN Git Service

Fix linker crash on trying to unload main executable
authorDimitry Ivanov <dimitry@google.com>
Thu, 5 May 2016 00:19:14 +0000 (17:19 -0700)
committerDimitry Ivanov <dimitry@google.com>
Fri, 6 May 2016 23:06:00 +0000 (16:06 -0700)
commitbee8572ca373f626ebe6cbcdd490808c054feb49
treebfe1b35417bcbdb833a603797205663320f38a41
parentcd0a8fa09d284b49adbb2345821ce481fe369972
Fix linker crash on trying to unload main executable

Linker crashed if linking of the main executable fails
instead of aborting with readable error message.

This patch modifies unload to soinfo_unload it all at once
in this particular case. This helps avoid situations when
one of the libraries on the DT_NEEDED list of main executable
has gotten unloaded by previous library unload because it
DT_NEEDED it too.

Example (consider following dependency tree):
main_executable
|-> liba.so
  |-> libb.so
|-> libb.so

The list of the libraries need to be unloaded in this case
is [liba.so, libb.so], but if linker does unload one by one
by the time it gets to libb.so - the soinfo for the library
is already unloaded (and the segments were unmapped).

Passing everything as an array helps soinfo_unload to check
if a library was already unloaded by looking into local_unload_list.

Bug: http://b/28565608
Change-Id: I7199290e10a186057dcf3b7b68dbce954af7dba1
(cherry picked from commit 83fcb542088db7874a387f4f41caac2019821fd2)
linker/linker.cpp