summaryrefslogtreecommitdiffstats
path: root/linker/linker.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-12-21 16:07:45 -0800
committerElliott Hughes <enh@google.com>2013-12-22 19:38:42 +0000
commitb93702a0463fa0b87bf25d7ae9bdb09a35ea6a50 (patch)
treea7c1748571da9d9831ca5f785a161186a1886b4f /linker/linker.cpp
parent6d929061c36e7929c61c8e6331315b86fe86976f (diff)
downloadbionic-b93702a0463fa0b87bf25d7ae9bdb09a35ea6a50.zip
bionic-b93702a0463fa0b87bf25d7ae9bdb09a35ea6a50.tar.gz
bionic-b93702a0463fa0b87bf25d7ae9bdb09a35ea6a50.tar.bz2
Improve dynamic linker diagnostics for internal errors.
If the linker can't resolve its own internal references to symbols, we currently exit silently (albeit with EXIT_FAILURE). Not very helpful. Change-Id: I1614fc970dee4560b38832ede1987b65a8e53a1e
Diffstat (limited to 'linker/linker.cpp')
-rwxr-xr-xlinker/linker.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 81ca2f5..f4e426d 100755
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2212,6 +2212,7 @@ extern "C" Elf_Addr __linker_init(void* raw_args) {
soinfo linker_so;
memset(&linker_so, 0, sizeof(soinfo));
+ strcpy(linker_so.name, "[dynamic linker]");
linker_so.base = linker_addr;
linker_so.size = phdr_table_get_load_size(phdr, elf_hdr->e_phnum);
linker_so.load_bias = get_elf_exec_load_bias(elf_hdr);
@@ -2223,11 +2224,13 @@ extern "C" Elf_Addr __linker_init(void* raw_args) {
if (!soinfo_link_image(&linker_so)) {
// It would be nice to print an error message, but if the linker
// can't link itself, there's no guarantee that we'll be able to
- // call write() (because it involves a GOT reference).
- //
- // This situation should never occur unless the linker itself
- // is corrupt.
- exit(EXIT_FAILURE);
+ // call write() (because it involves a GOT reference). We may as
+ // well try though...
+ const char* msg = "CANNOT LINK EXECUTABLE: ";
+ write(2, msg, strlen(msg));
+ write(2, __linker_dl_err_buf, strlen(__linker_dl_err_buf));
+ write(2, "\n", 1);
+ _exit(EXIT_FAILURE);
}
// We have successfully fixed our own relocations. It's safe to run