Commit graph

246 commits

Author SHA1 Message Date
Elliott Hughes
d3920b3a99 Switch to using AT_RANDOM for the stack guards.
Bug: 7959813
Change-Id: I8db4b8912ba649bfe668c6f22aa44690ddd401a2
2013-02-08 11:16:13 -08:00
Elliott Hughes
646e058136 Fix x86 build, remove void* arithmetic.
Change-Id: Idc7f14af2e094ac33de315e808176237af063bb8
2013-02-07 12:16:10 -08:00
Elliott Hughes
42b2c6a5ee Clean up the argc/argv/envp/auxv handling.
There's now only one place where we deal with this stuff, it only needs to
be parsed once by the dynamic linker (rather than by each recipient), and it's
now easier for us to get hold of auxv data early on.

Change-Id: I6314224257c736547aac2e2a650e66f2ea53bef5
2013-02-07 11:44:21 -08:00
Elliott Hughes
d2b1a7311f Remove partial implementation of MIPS non-PIC support.
Change-Id: I3c287e52aae10559508174e73113367aea40e5c2
2013-02-06 11:02:28 -08:00
Elliott Hughes
a6a3ac5924 Use the NetBSD <sys/exec_elf.h>.
Replace a kernel header file dependency with files from NetBSD.
They're more complete, and ELF is ELF, whether you're on Linux or a BSD.

Bug: 7973611
Change-Id: I83ee719e7efdf432ec2ddbe8be271d05b2f558d7
2013-01-29 15:02:50 -08:00
Elliott Hughes
6b8e321e61 Clean up debuggerd-related logging.
Bug: 7291287
Change-Id: Ia7aa386e8b75b8058d7d9e707e11b1da7dc62f00
2013-01-22 14:17:14 -08:00
Elliott Hughes
ca483765bd Merge "Fix the duplication in the debugging code." 2013-01-22 17:44:15 +00: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
Guang Zhu
4df577fef7 Revert "Filter ANDROID_PROPERTY_WORKSPACE"
Temporarily revert the change since DNS resolution seems
broken right now in ping util.

Bug: 8029617

This reverts commit a0f64756a4.
2013-01-18 11:28:47 -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
Nick Kralevich
36bd371e26 Revert "stack protector: use AT_RANDOM"
The AT_RANDOM changes broke setuid / setgid executables
such as "ping". When the linker executes a setuid program,
it cleans the environment, removing any invalid environment
entries, and adding "NULL"s to the end of the environment
array for each removed variable. Later on, we try to determine
the location of the aux environment variable, and get tripped
up by these extra NULLs.

Reverting this patch will get setuid executables working again,
but getauxval() is still broken for setuid programs because of
this bug.

This reverts commit e3a49a8661.

Change-Id: I05c58a896b1fe32cfb5d95d43b096045cda0aa4a
2013-01-16 13:16:42 -08:00
Nick Kralevich
ba117e4172 Merge "stack protector: use AT_RANDOM" 2013-01-16 11:23:26 -08:00
Nick Kralevich
e3a49a8661 stack protector: use AT_RANDOM
Populate the stack canaries from the kernel supplied
AT_RANDOM value, which doesn't involve any system calls.
This is slightly faster (6 fewer syscalls) and avoids
unnecessarily reading /dev/urandom, which depletes entropy.

Bug: 7959813

Change-Id: If2b43100a2a9929666df3de56b6139fed969e0f1
2013-01-16 10:09:52 -08:00
Nick Kralevich
a0f64756a4 Filter ANDROID_PROPERTY_WORKSPACE
When executing a setuid executable, filter out ANDROID_PROPERTY_WORKSPACE
from the environment. Some applications implicitly trust the property
space and don't realize that it's passed by an environment variable
which can be modified by the caller.

Change-Id: I3e3a98941f0a1f249a2ff983ecbcfe1278aa9159
2013-01-15 16:02:03 -08:00
Elliott Hughes
99c32055cb Fix my git mistake.
This was the formatting change that was supposed to be in
cf23905a4b.

Change-Id: Ib79fa031b68f6f541f532507eb589afeaedb831f
2013-01-14 09:56:21 -08:00
Chris Dearman
cf23905a4b [MIPS] Set DT_DEBUG dyntab entry if it is writable
This is primarily for MIPS exutables that do not have a
DT_MIPS_RLD_MAP entry.

Change-Id: I4c221d92debcfed961eeee2515123f3fb21ec8e6
Signed-off-by: Chris Dearman <chris@mips.com>
2013-01-14 09:30:25 -08:00
Elliott Hughes
db492b3ca7 Fix debug malloc.
...which has been broken since the linker data structures went read-only.

Bug: 7941716
Change-Id: If28f6bac0fcb13e371e4d85b064544f561c8d692
2013-01-03 15:44:03 -08:00
Elliott Hughes
918d776f7e Merge "Support System.loadLibrary for libraries with transitive dependencies." 2012-12-21 17:46:22 -08:00
Elliott Hughes
eababde214 Fix format_number.
I broke this the other day when silencing x86 gcc warnings.

Bug: 7904160
Change-Id: I8e60cc1f8cbaff95248c8738d84e515413d839e4
2012-12-20 19:00:48 -08:00
Elliott Hughes
cade4c36e7 Support System.loadLibrary for libraries with transitive dependencies.
Also fix the FLAG_ERROR annoyance --- it's not helpful to cache failures.

Bug: 7896159
Bug: http://code.google.com/p/android/issues/detail?id=34416
Bug: http://code.google.com/p/android/issues/detail?id=22143
Change-Id: I60f235edb4ea4756e1f7ce56f7739f18e8a50789
2012-12-20 14:42:14 -08:00
Elliott Hughes
45288c5ce3 Fix x86 dynamic linker build.
Change-Id: Ia9fc6342e3d409de86dcd187c7402e8ac2ae96c8
2012-12-18 18:13:19 -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
97b70b2bda Merge "Replace .S version of x86 crtfiles with .c version" 2012-11-30 10:07:19 -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
Chris Dearman
20a24403bc Do not include '\0' when writing error messages to stderr
Change-Id: I6adc806c3920e5a4ae61ca55c40613fcf338b18c
Signed-off-by: Chris Dearman <chris@mips.com>
2012-11-26 15:43:17 -08:00
Nick Kralevich
8784709a2c Merge "We should use load_bias. This patch fixes MIPS NDK device exception test failures." 2012-11-19 10:45:18 -08:00
Chao-Ying Fu
c5db969aa4 We should use load_bias. This patch fixes MIPS NDK device exception test failures.
Change-Id: I4b718c36666e66062c1f13e4deea1ec7a7951c54
2012-11-19 10:30:15 -08:00
Nick Kralevich
83697b8b76 Temporarily address gcc 4.7 breakage.
Change-Id: I8ebb2d5df2f8f8aedf252c94ff69505e61ed0a74
2012-11-15 15:48:19 -08:00
Elliott Hughes
ce876bebf2 am a41e6426: Merge "Tone down some of the overly-verbose linker logging."
* commit 'a41e6426073c57881f49bdaec46ca90a5b164401':
  Tone down some of the overly-verbose linker logging.
2012-11-05 09:19:57 -08:00
Elliott Hughes
9c94fc9fbe Tone down some of the overly-verbose linker logging.
We don't need to see every dlopen(3)/dlsym(3) failure unless LD_DEBUG is on.

Change-Id: I1edfe8b72f32ff54dd30e1acf32e20d470d5e9f7
2012-11-05 09:11:43 -08:00
Elliott Hughes
bc35807fc6 am 9df2e000: Merge "Cleaning the linker environment as we initialize it requires less API."
* commit '9df2e000b5d56b2e529656034d684e370aa6a8d1':
  Cleaning the linker environment as we initialize it requires less API.
2012-11-02 13:56:00 -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
9df2e000b5 Merge "Cleaning the linker environment as we initialize it requires less API." 2012-11-02 13:47:50 -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
0894b2c5d3 Cleaning the linker environment as we initialize it requires less API.
Change-Id: I612fd699e46833a411589478564a1f859223c380
2012-11-02 12:40:11 -07:00
Elliott Hughes
cdc5a17cef am ed537239: Merge "Adjust symbol lookup for DT_SYMBOLIC case"
* commit 'ed537239a94ebd11a8c262a319d81fd1f0d3f73f':
  Adjust symbol lookup for DT_SYMBOLIC case
2012-11-02 11:37:40 -07:00
Elliott Hughes
ed537239a9 Merge "Adjust symbol lookup for DT_SYMBOLIC case" 2012-11-02 11:25:49 -07:00
Pavel Chupin
c77c434149 Adjust symbol lookup for DT_SYMBOLIC case
According ELF spec re. DT_SYMBOLIC:
This element's presence in a shared object library alters the dynamic
linker's symbol resolution algorithm for references within the library.
Instead of starting a symbol search with the executable file, the
dynamic linker starts from the shared object itself. If the shared
object fails to supply the referenced symbol, the dynamic linker then
searches the executable file and other shared objects as usual.

This change implements the last part.

Change-Id: Iae95d53d455313a4306f11733941bcd3596ac85f
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
2012-11-02 18:34:22 +04:00
Elliott Hughes
e109930e9f am dc77a228: Merge "Allow dlopen("egl/blah.so")."
* commit 'dc77a22850e31eb369ec9776c13c967566bf61d0':
  Allow dlopen("egl/blah.so").
2012-11-01 23:08:27 -07:00
Elliott Hughes
6971fe4ca5 Allow dlopen("egl/blah.so").
NVIDIA binary blobs construct strings to pass to dlopen(3) that
contain '/' but require that we fall back to LD_LIBRARY_PATH.

Change-Id: Iad831899986baace6962f4b335eeb288250a1e22
2012-11-01 22:59:19 -07:00
Elliott Hughes
6db8f5bb75 am d30116cf: Merge "Keep the dynamic linker\'s soinfo pools mostly read-only."
* commit 'd30116cf4a590e7bea3b73fa49bb27502a920819':
  Keep the dynamic linker's soinfo pools mostly read-only.
2012-11-01 17:00:13 -07:00
Elliott Hughes
d23736e4f2 Keep the dynamic linker's soinfo pools mostly read-only.
We'll need a lot more refactoring of this code before we can reduce
the granularity, but this is a step forward.

Change-Id: I07061720e734b571a8399c1d5b4f2f35cd681307
2012-11-01 16:48:14 -07:00
Elliott Hughes
65ba5b62c5 am 064f862d: Merge "Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too."
* commit '064f862d557ab741575dfae479499a07ca0ab742':
  Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too.
2012-11-01 14:14:00 -07:00
Elliott Hughes
1a6961650c Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too.
Also remove an unnecessary #include and a now-obsolete TODO.

Change-Id: I36d923721e349a286934b9534090a67ce0786e7b
2012-11-01 13:53:26 -07:00
Elliott Hughes
3bb62578be am 0be1819b: Merge "Dynamically allocate soinfo-structs in linker"
* commit '0be1819b22b33fbedcb150f96a196ed096abe2fc':
  Dynamically allocate soinfo-structs in linker
2012-11-01 11:44:29 -07:00
Magnus Malmborn
ba98d9237b Dynamically allocate soinfo-structs in linker
Request memory from the system when needed instead of having a fixed
array for soinfo structs. Note that malloc() et al can't be used in
linker, so use mmap() instead.

Change-Id: I4b495995931d7752b0e8c944e64d1fe41b9f7144
2012-11-01 11:31:39 -07:00
Elliott Hughes
1de3af51d4 am c0ac7eba: Merge "Reject .so files with no sysv hash table."
* commit 'c0ac7eba934fb88f321c75a71312ea482e9a85e9':
  Reject .so files with no sysv hash table.
2012-10-31 15:13:30 -07:00
Elliott Hughes
124fae9eab Reject .so files with no sysv hash table.
Also ensure that dlopen(3) errors always include the name of the library we
failed to open.

Also fix a bug where we'd fall back to searching LD_LIBRARY_PATH and the
built-in paths for names that include slashes.

Bug: http://code.google.com/p/android/issues/detail?id=38479
Change-Id: Ib2c009ed083344a7a012749d58f8679db2f26c78
2012-10-31 14:30:50 -07:00
Elliott Hughes
3cd7a1653a am 084be591: Merge "linker: handle R_ARM_COPY relocations in a proper way"
* commit '084be591923d3d509cea0a0f4b11b073e362d730':
  linker: handle R_ARM_COPY relocations in a proper way
2012-10-30 17:18:04 -07:00
Ard Biesheuvel
5ae44f302b linker: handle R_ARM_COPY relocations in a proper way
If an executable contain copy relocations, other references
to the symbol it points to should be preempted and made to
point to the copy instead.

Also, the linker should make sure the target area has
sufficient space to contain the copy. It also checks
whether the library that supplies the symbol is built
with -Bsymbolic, and errors out if this is the case.

Change-Id: If135c83590092741cfd8f82f54816f363a4a4a3b
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
2012-10-30 17:09:21 -07:00