summaryrefslogtreecommitdiffstats
path: root/linker
diff options
context:
space:
mode:
authorDmitriy Ivanov <dimitry@google.com>2014-08-26 14:16:52 -0700
committerDmitriy Ivanov <dimitry@google.com>2014-08-26 15:44:18 -0700
commit14241402de0faa4b244b1bd6b1f0799ce169b880 (patch)
tree0308dd630e83a0640ad43bf0496c0733e7708366 /linker
parentc764fb24ccb47e05d8e140cde5b4111225790ef1 (diff)
downloadbionic-14241402de0faa4b244b1bd6b1f0799ce169b880.zip
bionic-14241402de0faa4b244b1bd6b1f0799ce169b880.tar.gz
bionic-14241402de0faa4b244b1bd6b1f0799ce169b880.tar.bz2
Enable __cxa_atexit && __cxa_finalize for linker
This allows adding destructors to classes used for global variables. Change-Id: I5e1cd63fe3bf8f66de88cc4f7437cafb350f49b5
Diffstat (limited to 'linker')
-rw-r--r--linker/Android.mk1
-rw-r--r--linker/linked_list.h3
-rw-r--r--linker/linker.cpp13
-rw-r--r--linker/linker_libc_support.c17
4 files changed, 23 insertions, 11 deletions
diff --git a/linker/Android.mk b/linker/Android.mk
index 5853c90..4298032 100644
--- a/linker/Android.mk
+++ b/linker/Android.mk
@@ -8,6 +8,7 @@ LOCAL_SRC_FILES:= \
linker.cpp \
linker_allocator.cpp \
linker_environ.cpp \
+ linker_libc_support.c \
linker_phdr.cpp \
rt.cpp \
diff --git a/linker/linked_list.h b/linker/linked_list.h
index 8096e62..e51eb9c 100644
--- a/linker/linked_list.h
+++ b/linker/linked_list.h
@@ -32,6 +32,9 @@ template<typename T, typename Allocator>
class LinkedList {
public:
LinkedList() : head_(nullptr), tail_(nullptr) {}
+ ~LinkedList() {
+ clear();
+ }
void push_front(T* const element) {
LinkedListEntry<T>* new_entry = Allocator::alloc();
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 6a55571..aaa653f 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -2167,16 +2167,6 @@ static void init_linker_info_for_gdb(ElfW(Addr) linker_base) {
* and other non-local data at this point.
*/
static ElfW(Addr) __linker_init_post_relocation(KernelArgumentBlock& args, ElfW(Addr) linker_base) {
- /* NOTE: we store the args pointer on a special location
- * of the temporary TLS area in order to pass it to
- * the C Library's runtime initializer.
- *
- * The initializer must clear the slot and reset the TLS
- * to point to a different location to ensure that no other
- * shared library constructor can access it.
- */
- __libc_init_tls(args);
-
#if TIMING
struct timeval t0, t1;
gettimeofday(&t0, 0);
@@ -2403,6 +2393,8 @@ extern "C" ElfW(Addr) __linker_init(void* raw_args) {
_exit(EXIT_FAILURE);
}
+ __libc_init_tls(args);
+
// Initialize the linker's own global variables
linker_so.CallConstructors();
@@ -2412,7 +2404,6 @@ extern "C" ElfW(Addr) __linker_init(void* raw_args) {
solist = get_libdl_info();
sonext = get_libdl_info();
-
// We have successfully fixed our own relocations. It's safe to run
// the main part of the linker now.
args.abort_message_ptr = &g_abort_message;
diff --git a/linker/linker_libc_support.c b/linker/linker_libc_support.c
new file mode 100644
index 0000000..17db6d4
--- /dev/null
+++ b/linker/linker_libc_support.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../libc/arch-common/bionic/__dso_handle.h"