summaryrefslogtreecommitdiffstats
path: root/libc/private
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2012-05-31 11:40:10 -0700
committerNick Kralevich <nnk@google.com>2012-06-01 14:41:27 -0700
commit9d40326830c2bd407427889c554adeb915ee6b4a (patch)
tree17c901c0eb9768711be1c299178cbd891624281b /libc/private
parent857fc9eab912fbb3f27913c3582ed2268420bce9 (diff)
downloadbionic-9d40326830c2bd407427889c554adeb915ee6b4a.zip
bionic-9d40326830c2bd407427889c554adeb915ee6b4a.tar.gz
bionic-9d40326830c2bd407427889c554adeb915ee6b4a.tar.bz2
arm: rewrite crtbegin* as C files.
Rewrite crtbegin.S -> crtbegin.c crtbegin_so.S -> crtbegin_so.c This change allows us to generate PIC code without relying on text relocations. As a consequence of this rewrite, also rewrite __dso_handle.S -> __dso_handle.c __dso_handle_so.S -> __dso_handle_so.c atexit.S -> atexit.c In crtbegin.c _start, place the __PREINIT_ARRAY__, __INIT_ARRAY__, __FINI_ARRAY__, and __CTOR_LIST__ variables onto the stack, instead of passing a pointer to the text section of the binary. This change appears sorta wonky, as I attempted to preserve, as much as possible, the structure of the original assembly. As a result, you have C files including other C files, and other programming uglyness. Result: This change reduces the number of files with text-relocations from 315 to 19 on my Android build. Before: $ scanelf -aR $OUT/system | grep TEXTREL | wc -l 315 After: $ scanelf -aR $OUT/system | grep TEXTREL | wc -l 19 Change-Id: Ib9f98107c0eeabcb606e1ddc7ed7fc4eba01c9c4
Diffstat (limited to 'libc/private')
-rw-r--r--libc/private/__dso_handle.h (renamed from libc/private/__dso_handle.S)16
-rw-r--r--libc/private/__dso_handle_so.c (renamed from libc/private/__dso_handle_so.S)16
2 files changed, 9 insertions, 23 deletions
diff --git a/libc/private/__dso_handle.S b/libc/private/__dso_handle.h
index 3e80128..e67ce7c 100644
--- a/libc/private/__dso_handle.S
+++ b/libc/private/__dso_handle.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2012 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,17 +26,9 @@
* SUCH DAMAGE.
*/
-# The __dso_handle global variable is used by static
-# C++ constructors and destructors in the binary.
-# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
-#
- .section .bss
- .align 4
#ifndef CRT_LEGACY_WORKAROUND
- .hidden __dso_handle
+__attribute__ ((visibility ("hidden")))
#endif
-
- .globl __dso_handle
-__dso_handle:
- .long 0
+__attribute__ ((section (".bss")))
+void *__dso_handle = (void *) 0;
diff --git a/libc/private/__dso_handle_so.S b/libc/private/__dso_handle_so.c
index 77a5d7f..198e64b 100644
--- a/libc/private/__dso_handle_so.S
+++ b/libc/private/__dso_handle_so.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2012 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,13 +26,7 @@
* SUCH DAMAGE.
*/
-# The __dso_handle global variable is used by static
-# C++ constructors and destructors in the binary.
-# See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
-#
- .data
- .align 4
- .hidden __dso_handle
- .globl __dso_handle
-__dso_handle:
- .long __dso_handle
+
+__attribute__ ((visibility ("hidden")))
+__attribute__ ((section (".data")))
+void *__dso_handle;