OSDN Git Service

arm: rewrite crtbegin* as C files.
authorNick Kralevich <nnk@google.com>
Thu, 31 May 2012 18:40:10 +0000 (11:40 -0700)
committerNick Kralevich <nnk@google.com>
Fri, 1 Jun 2012 21:41:27 +0000 (14:41 -0700)
commit9d40326830c2bd407427889c554adeb915ee6b4a
tree17c901c0eb9768711be1c299178cbd891624281b
parent857fc9eab912fbb3f27913c3582ed2268420bce9
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
libc/Android.mk
libc/arch-arm/bionic/atexit.h [new file with mode: 0644]
libc/arch-arm/bionic/crtbegin.c [moved from libc/arch-arm/bionic/crtbegin.S with 52% similarity]
libc/arch-arm/bionic/crtbegin_so.c [moved from libc/arch-arm/bionic/crtbegin_so.S with 66% similarity]
libc/arch-x86/bionic/__dso_handle.S [moved from libc/private/__dso_handle.S with 100% similarity]
libc/arch-x86/bionic/__dso_handle_so.S [moved from libc/private/__dso_handle_so.S with 100% similarity]
libc/private/__dso_handle.h [moved from libc/arch-arm/bionic/atexit.S with 71% similarity]
libc/private/__dso_handle_so.c [new file with mode: 0644]