Commit graph

64 commits

Author SHA1 Message Date
Elliott Hughes
2258347f3b Build the linker with the same -std flags as the rest of bionic.
Change-Id: I5bdb28ecfdf78a90f6b072077a1c5ffd63f5d2ae
2013-10-17 13:06:20 -07:00
Elliott Hughes
d7398f146d Use linker64 for the 64-bit linker.
Change-Id: I13fc7f93274f99e4cf99b077afdf5293e7233f39
2013-10-08 10:05:05 -07:00
Elliott Hughes
c00f2cb587 x86_64 linker.
Based on I8dc3e2cb596f75dc58ae82e4dc58f8c177dd3323 by
Pavel Chupin <pavel.v.chupin@intel.com>.

Change-Id: Icd582d277cbe273477b450f2848343d72c86ec9f
2013-10-08 09:57:01 -07:00
Elliott Hughes
2db16ea38e am 3002d64b: Merge "Everyone has a TLS register."
# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit '3002d64bcd4644456803dd0547d20b39e14be02c':
  Everyone has a TLS register.
2013-02-13 08:11:24 -08:00
Elliott Hughes
91a9925998 Everyone has a TLS register.
Change-Id: Id7cdf67087aa7d5074c9c59b7e595bc391d9f146
2013-02-12 21:56:42 -08:00
Elliott Hughes
16f7b78fd1 am 4cd5703b: am 75b64a1b: am ca483765: Merge "Fix the duplication in the debugging code."
* commit '4cd5703b9eef30a32271819503808576666e1601':
  Fix the duplication in the debugging code.
2013-01-22 10:05:19 -08:00
Elliott Hughes
1e980b6bc8 Fix the duplication in the debugging code.
We had two copies of the backtrace code, and two copies of the
libcorkscrew /proc/pid/maps code. This patch gets us down to one.

We also had hacks so we could log in the malloc debugging code.
This patch pulls the non-allocating "printf" code out of the
dynamic linker so everyone can share.

This patch also makes the leak diagnostics easier to read, and
makes it possible to paste them directly into the 'stack' tool (by
using relative PCs).

This patch also fixes the stdio standard stream leak that was
causing a leak warning every time tf_daemon ran.

Bug: 7291287
Change-Id: I66e4083ac2c5606c8d2737cb45c8ac8a32c7cfe8
2013-01-18 22:20:06 -08:00
Nick Kralevich
dbcf3ed458 am 36c4eb18: am 3a72fe58: am f3fe1945: Merge "linker: add -Wl,--exclude-libs,ALL to LDFLAGS"
* commit '36c4eb188c6594db877bd7b9f46c55264180dc3f':
  linker: add -Wl,--exclude-libs,ALL to LDFLAGS
2013-01-17 11:34:20 -08:00
Nick Kralevich
d89ce40d8e linker: add -Wl,--exclude-libs,ALL to LDFLAGS
The linker is essentially a shared library, and incorporates
it's own copy of libc. Even though it's unnecessary, currently
/system/bin/linker is exporting various libc symbols (only to
apps which explicitly dlopen /system/bin/linker)

Add --exclude-libs,ALL, which tells the static linker to mark
all of the imported libc symbols as hidden. This reduces the
size of /system/bin/linker from 92K to 67K with no obvious
loss in functionality.

  $ adb shell ls -l /system/bin/linker
  -rwxrwxrwx root     root        92260 2013-01-16 16:52 linker

  $ adb shell ls -l /system/bin/linker
  -rwxrwxrwx root     root        67660 2013-01-16 16:49 linker

Documentation on exclude-libs can be found at
http://sourceware.org/binutils/docs-2.21/ld/Options.html

Change-Id: I4508287770e4b7a845def2e6b4af969f9c866c6a
2013-01-16 16:43:58 -08:00
Elliott Hughes
05ab167cf7 am a0edecf3: am a4ebdcf5: Merge "Check for unknown flags passed to dlopen(3)."
* commit 'a0edecf3438d036ee2353076d171ee68939c2a5e':
  Check for unknown flags passed to dlopen(3).
2012-12-18 19:44:10 -08:00
Elliott Hughes
e66190d2a9 Check for unknown flags passed to dlopen(3).
Change-Id: I56f4aab0e5a1487bc32d2c4d231e8bd15c4ac8da
2012-12-18 15:57:55 -08:00
Elliott Hughes
2e51dc444f am 4835e6ef: am 97b70b2b: Merge "Replace .S version of x86 crtfiles with .c version"
* commit '4835e6ef519fc941651bbc13909cff971a6ec81b':
  Replace .S version of x86 crtfiles with .c version
2012-11-30 10:16:06 -08:00
Pavel Chupin
20c4a3a8ee Replace .S version of x86 crtfiles with .c version
This patch replaces .S versions of x86 crtfiles with .c which are much
easier to support. Some of the files are matching .c version of Arm
crtfiles. x86 files required some cleanup anyway and this cleanup actually
led to matching Arm files.

I didn't change anything to share the same crt*.c between x86 and Arm. I
prefer to keep them separate for a while in case any change is required
for one of the arch, but it's good thing to do in the following patches.

Change-Id: Ibcf033f8d15aa5b10c05c879fd4b79a64dfc70f3
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2012-11-30 17:41:25 +04:00
Elliott Hughes
d752fc0286 am cfb47daf: am 01271b18: Merge "Make dynamic linker debugging always available."
* commit 'cfb47daf4eb4741ac462c7350c73ad1cf96cf83f':
  Make dynamic linker debugging always available.
2012-11-02 13:58:47 -07:00
Elliott Hughes
cfb47daf4e am 01271b18: Merge "Make dynamic linker debugging always available."
* commit '01271b1812f2cec8aaf3c105b9f960f027b33a95':
  Make dynamic linker debugging always available.
2012-11-02 13:55:59 -07:00
Elliott Hughes
61a9ccb41e Make dynamic linker debugging always available.
If you need to build your own linker to get debugging, the debugging
is never available when you need it.

Change-Id: I5ff7e55753459d49a2990f25d9aa155e0b8602e0
2012-11-02 13:46:23 -07:00
Elliott Hughes
864d48917a am 914112ea: am 155e8d1d: Merge "More dynamic linker cleanup."
* commit '914112ea21a62c7658dc4b094a369358009be6a9':
  More dynamic linker cleanup.
2012-10-30 16:59:17 -07:00
Elliott Hughes
914112ea21 am 155e8d1d: Merge "More dynamic linker cleanup."
* commit '155e8d1df5b8fdfeabda3e7b61d95beb5b8d1467':
  More dynamic linker cleanup.
2012-10-30 16:56:29 -07:00
Elliott Hughes
18a206c81d More dynamic linker cleanup.
I still want to break linker_format out into its own library so we can reuse
it for malloc debugging and so forth. (There are many similar pieces of code
in bionic, but the linker's one seems to be the most complete/functional.)

Change-Id: If3721853d28937c8e821ca1d23cf200e228a409a
2012-10-30 16:35:38 -07:00
Elliott Hughes
66d71c8f13 am ab4e2ed1: am db4fdf1a: Merge "Fix dlerror(3)."
* commit 'ab4e2ed182011998751ff5d6c321ff5bae20c6cd':
  Fix dlerror(3).
2012-10-12 10:49:08 -07:00
Elliott Hughes
ab4e2ed182 am db4fdf1a: Merge "Fix dlerror(3)."
* commit 'db4fdf1aafb63b09ee967066d9b8107a9812db2d':
  Fix dlerror(3).
2012-10-12 10:47:59 -07:00
Elliott Hughes
3b297c4079 Fix dlerror(3).
Add unit tests for dlerror(3) in various situations. I think We're at least
as good as glibc now.

Also factor out the ScopedPthreadMutexLock and use it here too.

Bug: http://code.google.com/p/android/issues/detail?id=38398
Change-Id: I040938b4366ab836e3df46d1d8055b92f4ea6ed8
2012-10-11 16:08:51 -07:00
Ying Wang
b04598a63c Set up the private variables.
Now we use private variables in transform-o-to-executable to support
build executables against the NDK.

Bug: 7170098
Change-Id: I6e505b33001b76f4b11fcbbb1d35392c4ddf4c70
2012-10-08 14:12:56 -07:00
Ying Wang
f680b0f404 Set up the private variables.
Now we use private variables in transform-o-to-executable to support
build executables against the NDK.

Bug: 7170098
Change-Id: I6e505b33001b76f4b11fcbbb1d35392c4ddf4c70
2012-09-26 10:54:45 -07:00
Elliott Hughes
66c033868f am c64c1b49: am ad8ff472: am c1eb7619: am 440e417d: Merge "Add dependencies on all the makefiles."
* commit 'c64c1b49fd5c51b1b6e87d88b233d23fa172d372':
  Add dependencies on all the makefiles.
2012-08-13 16:10:31 -07:00
Elliott Hughes
ae5c64413b Add dependencies on all the makefiles.
This should help prevent broken builds next time I'm messing with
assembler/compiler/linker flags...

Change-Id: I30f15a3ce3c3f3c60cad7bc59aaba9f42d792224
2012-08-13 14:06:05 -07:00
Ying Wang
c97c5fc788 Split out LOCAL_ASFLAGS.
Bug: 6967574
Change-Id: I5be50d582c1cb8075039b06292cf0745a996c3c4
2012-08-11 14:23:19 -07:00
Elliott Hughes
4688279db5 Clean up the linker a bit, remove prelinking support.
Also make the errors more readable, since none of us seemed to know
what they actually meant. The new style is still as verbose as the
old, but that's probably necessary in the absence of chained exceptions
in C. Here's what you'd see if you try to boot after removing
libsurfaceflinger.so:

  32267 32267 E AndroidRuntime: java.lang.UnsatisfiedLinkError: Cannot load library: (linker.c:1629, pid 32259) soinfo_link_image: could not load library "libsystem_server.so" needed by "libandroid_servers.so"; caused by (linker.c:1629, pid 32259) soinfo_link_image: could not load library "libsurfaceflinger.so" needed by "libsystem_server.so"; caused by (linker.c:709, pid 32259) load_library: library "libsurfaceflinger.so" not found

This patch also fixes almost all of the compiler warnings.

Change-Id: I64bb59aed6d4e039c15ea45be2367f319ef879f8
2012-08-07 11:41:10 -07:00
Raghu Gandham
d7daacb463 MIPS support to the linker
Change-Id: I37ec2d6c51d82bb9e9dbfef4b38c85366bead255
Signed-off-by: Chris Dearman <chris@mips.com>
Signed-off-by: Raghu Gandham <raghu@mips.com>
Signed-off-by: Bhanu Chetlapalli <bhanu@mips.com>
2012-08-02 14:39:50 -07:00
Elliott Hughes
856512ea9c Use std=gnu99 for the dynamic linker as well as libc.
Change-Id: I76dd78576c5af6eb6282555f069647b6260edc31
2012-07-16 09:43:14 -07:00
David 'Digit' Turner
c1bd559d5b linker: New sources to manage the ELF program header table.
This patch introduces two new source files containing a set of functions
to manage the program header table in an ELF binary, including the ability
to load PT_LOAD segments, and apply PT_GNU_RELRO protection.

Note: the files are not used currently, this will appear in a series
      of future patches that will gradually modify linker.c to use
      the phdr_table_xxx functions properly.

Change-Id: Ia3d4c1ff5fc3e265d8258b64b492f4e643f51bdc
2012-06-25 11:52:40 +02:00
Andrew Hsieh
fa136e8ca7 am a5948157: Merge "Define __stack_chk_fail_local.S"
* commit 'a5948157fd34acb2b1d1bfaf129901af865ab5fc':
  Define __stack_chk_fail_local.S
2012-06-20 18:58:18 -07:00
Andrew Hsieh
6973e3da87 Define __stack_chk_fail_local.S
With -fstack-protector, x86 -m32 needs __stack_chk_fail_local
defined in crtbegin_*.o.

Include __stack_chk_fail_local.S in begin.S otherwise linker
(which is built w/o crt*) may not link.

Change-Id: Id242fcf3eff157264afe3b04f27288ab7991220a
2012-06-21 09:26:33 +08:00
Nick Kralevich
dcbc3787bf Make the linker relocatable.
Previously, the linker always loaded itself into the same
location in memory, which inhibited the effectiveness of Android's
ASLR implementation. Modify the linker code so it can be relocatable
and link itself at runtime.

Change-Id: Ia80273d7a00ff648b4da545f4b69debee6343968
2012-05-15 10:41:14 -07:00
Nick Kralevich
e742c1f564 linker: set LOCAL_NO_CRT := true
Use LOCAL_NO_CRT to prevent linking against crtbegin.o, rather than
messing with build rules. This also prevents linking against crtend.o,
which isn't needed for the linker.

Change-Id: I0c5b9999be7e8676560fe145c1c033ffce8db4d1
2012-05-15 10:08:39 -07:00
Nick Kralevich
3a7ea52f17 linker: enable -fvisibility=hidden
Compile the linker with -fvisibility=hidden. This reduces the number
of symbols that show up in the .dynsym section of the linker.
These symbols are never exported to other applications.

In particular, this fixes a problem with setting -DLINKER_DEBUG=1
introduced in 468319ce4f.
Because the symbols "debug_verbosity" and "format_log" have not been
resolved before the linker links itself, any attempt to call
PRINT / INFO / TRACE / WARN / ERROR will result in a segfault.
This change allows the static linker to produce a relative reference
to these symbols rather than relying on relocation.

This also has a nice side effect of making the linker slightly smaller
and slightly more optimized.

The following symbols no longer in the .dynsym section of the linker
after this change:

-addr_to_name
-call_constructors_recursi
-calloc
-debugger_init
-debugger_signal_handler
-debug_verbosity
-dladdr
-dlclose
-dlerror
-dl_lock
-dlopen
-dlsym
-dl_unwind_find_exidx
-find_containing_library
-find_containing_symbol
-find_library
-format_buffer
-free
-libdl_info
-linker_env_get
-linker_env_init
-linker_env_secure
-linker_env_unset
-linker_get_error
-__linker_init
-lookup
-lookup_in_library
-malloc
-notify_gdb_of_libraries
-notify_gdb_of_load
-notify_gdb_of_unload
-realloc
-rtld_db_dlactivity
-unload_library
-vsnprintf

Bug: 5827809
Change-Id: I5e8cd7dcf48c1d6831a970a67f63f24916c5e437
2012-04-04 11:13:51 -07:00
Nick Kralevich
9ec0f03a0d Add relro support
Add support for PT_GNU_RELRO. This allows the static linker to
indicate that certain regions of memory should be marked as
"read-only" after dynamic linking is complete.

See:
  * http://www.akkadia.org/drepper/nonselsec.pdf (section 6)
  * http://tk-blog.blogspot.com/2009/02/relro-not-so-well-known-memory.html

Note that this change has no effect on Android right now, because
we don't compile our code with relro enabled.

Change-Id: I6541f8775367e8558b4388f7d105b1ae6e8f046b
2012-03-05 16:44:42 -08:00
Jean-Baptiste Queru
25b7a16a6e Merge c4cb87f3
Change-Id: I4cc14eba43fde75a7702fdc7ad07d3d949e9c092
2012-02-01 09:46:08 -08:00
David 'Digit' Turner
70b1668a76 remove obsolete SuperH support
We don't have a toolchain anymore, we don't have working original
kernel headers, and nobody is maintaining this so there is really
no point in keeping this here. Details of the patch:

- removed code paths from Android.mk files related to the SuperH
  architecture ("sh")

- removed libc/arch-sh, linker/arch-sh, libc/kernel/arch-sh

- simplified libc/SYSCALLS.TXT

- simplified the scripts in libc/tools/ and libc/kernel/tools

Change-Id: I26b0e1422bdc347489e4573e2fbec0e402f75560

Signed-off-by: David 'Digit' Turner <digit@android.com>
2012-01-31 20:28:23 +01:00
Nick Kralevich
468319ce4f Make the linker relocatable.
Previously, the linker always loaded itself into the same
location in memory, which inhibited the effectiveness of Android's
ASLR implementation. Modify the linker code so it can be relocatable
and link itself at runtime.

Change-Id: Ia80273d7a00ff648b4da545f4b69debee6343968
2011-11-11 18:01:53 -08:00
Nick Kralevich
7939908c83 linker: set LOCAL_NO_CRT := true
Use LOCAL_NO_CRT to prevent linking against crtbegin.o, rather than
messing with build rules. This also prevents linking against crtend.o,
which isn't needed for the linker.

Change-Id: I0c5b9999be7e8676560fe145c1c033ffce8db4d1
2011-11-04 10:22:55 -07:00
Nick Kralevich
8e8a7b1f0f Revert "Make the linker relocatable."
This reverts commit 994e9a5ed1.

Broke x86 build.
2011-11-03 09:25:06 -07:00
Nick Kralevich
994e9a5ed1 Make the linker relocatable.
Previously, the linker always loaded itself into the same
location in memory, which inhibited the effectiveness of Android's
ASLR implementation. Modify the linker code so it can be relocatable
and link itself at runtime.

Change-Id: I90d064743abdd29450ac0482ed28752b2196286c
2011-11-02 16:20:06 -07:00
Shih-wei Liao
48527c3f74 Revert "Revert "linker: get rid of the buddy allocator""
This reverts commit f9a9cda23a.
This revert is promised once b/5039224, b/5036755, b/5036610 are resolved.
2011-07-17 12:32:43 -07:00
Nick Kralevich
f9a9cda23a Revert "linker: get rid of the buddy allocator"
This reverts commit 7059b1f02e.
Bug: 5036610
2011-07-15 16:12:45 -07:00
Nick Kralevich
7059b1f02e linker: get rid of the buddy allocator
Currently, the Android linker is placing shared libraries into
a well-known spot in memory.  This is interfering with the kernel's
ASLR support.

This change stops forcing non-prelinked libraries into a particular
address space.

Also, get rid of FLAG_PRELINKED.  As best I can tell, this flag
is never used.

Change-Id: I527af12fb54f821c2b5ca7693dbf63d022f8f4ae
2011-07-14 13:48:13 -07:00
Martijn Coenen
a903811819 Revert "x86: Enable -fstack-protector"
This reverts commit e0b4844a20,
causes netd to crash.
2011-06-07 17:19:12 +02:00
David Turner
65fb884d28 am 204d1f65: am b2c7e0c1: Merge "x86: Enable -fstack-protector"
* commit '204d1f65dbfc6d5a14a90627d9d1efcfce8261ee':
  x86: Enable -fstack-protector
2011-06-06 12:57:08 -07:00
Bruce Beare
e0b4844a20 x86: Enable -fstack-protector
Change-Id: Ib69514c3afcb4c1f5e5f3f8cd91acfd145a0866c
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
2011-05-24 13:32:14 -07:00
Iliyan Malchev
368070454b bionic: remove LOCAL_PRELINK_MODULE
Change-Id: Iad65ae18446b20d2aace7b8fe19b1a032b616e9c
Signed-off-by: Iliyan Malchev <malchev@google.com>
2011-03-14 14:25:58 -07:00