History log of /bionic/linker/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
05e190c093ad5b04691ed87100a711ef91f380b0 29-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Look into ld_preloads before current library

Change lookup order during relocation so that
ld_preloads always precede caller (unless caller
is main executable).

Asan needs this change in order to intercept libc->libc
calls.

Bug: 15432753
Change-Id: If69aa16efe59aa35bb30e96feb83d08f1efbec86
inker.cpp
172955a4e30b88ce8239a7ef426b4e8903e9923c 27-Aug-2014 Christopher Ferris <cferris@google.com> Replace snprintf calls in linker.

When enabling debug malloc, the snprintf calls in the linker fails to
update the buffer.

The problem is that snprintf makes a call to pthread_getspecific that
returns a valid pointer, but the data it points to is zero. This should
never happen and causes the snprintf to stop and do nothing.

Temporarily replace snprintf with a different implementation to work
around this issue.

Bug: 16874447
Bug: 17302493
Change-Id: I7a500f28adf153150cf2812fae745ff41f1c48d3
ebugger.cpp
inker.cpp
9419420919ea846bbad5510850c7aaec95021648 19-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Add support for protected local symbol lookup."

This reverts commit d97e9f546ea195686a78e539315b273393609b9e.

Bug: 17107521
Change-Id: I2b81ce2b5a4a2d166133a2626e49d81b6aef3672
lfcn.cpp
inker.cpp
inker.h
be4348e7c73841766208f4eb771dde1455b26449 15-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Keep symbols for linker

Bug: 17011146

(cherry picked from commit ad5e8b50737144833233d47fe04deb3fa0284df2)

Change-Id: Ib1d3f8d6d38af98586658e01ed1ec79d2c5b4d42
ndroid.mk
4bea4c631f747cc6b570ecd42c744a9b1103bf28 09-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Label pages mapped by linker_allocator

(cherry picked from commit 51a22a12ab370933a35463f5c81223132ec64dcb)

Bug: 17013324
Change-Id: I345c9d0fecc29d3626c5be01cc3c0ed1583ac361
inker_allocator.cpp
8a84d383fb74135e928d341baa180c55854f2f42 13-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Optimize symbol lookup

Do not run symbol lookup on already visited soinfos
Not taking into account already visited libraries
dramatically slows down dlsym in cases when there
are multiple occurrences of a large library in
dependency tree.

Bug: 16977077

(cherry picked from commit 042426ba6375f5c145379e598486ec6d675533c9)

Change-Id: I69d59e395e8112f119343e8a4d72fe31cd449f31
inked_list.h
inker.cpp
db7a17d4ff56a05af01ee2fee1f3c55245bfc630 05-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Revert "Fix dlsym(3) to do breadth first search.""

This reverts commit 1b1966d9448e979d1503a3d8843708bfa8880dc6.

Change-Id: I05d6d3481aaf8f3e260d2e5e950248519a1d347f
lfcn.cpp
inked_list.h
inker.cpp
inker.h
ests/linked_list_test.cpp
1b1966d9448e979d1503a3d8843708bfa8880dc6 04-Aug-2014 Dmitriy Ivanov <dimitry@google.com> Revert "Fix dlsym(3) to do breadth first search."

This reverts commit 422106a24d620af4be58e8d92a2e9b7b6167b72d.

Change-Id: I9e26a6933d10eb30438b521450f2010997ca5aee
lfcn.cpp
inked_list.h
inker.cpp
inker.h
ests/linked_list_test.cpp
422106a24d620af4be58e8d92a2e9b7b6167b72d 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Fix dlsym(3) to do breadth first search.

dlsym(3) with handle != RTLD_DEFAULT|RTLD_NEXT performs
breadth first search through the dependency tree.

Bug: 16653281

(cherry picked from commit aa0f2bdbc22d4b7aec5d3f8f5f01eaeaa13414c2)

Change-Id: I0ba8c2034ab341f8a279cdb4e2e7e47f1aef7897
lfcn.cpp
inked_list.h
inker.cpp
inker.h
ests/linked_list_test.cpp
1a5db57d5a0f633a83f20e667a4698757a63413e 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Fix mips/mips64 build

Add _start entry label to mips/mips64 linker begin.S

(cherry picked from commit ed485347189e3dfe04a38207c416bdd8c8fac4bc)

Change-Id: Id1b6bb3258f3bfbe3b7ec9491a977f56e44bed14
rch/mips/begin.S
rch/mips64/begin.S
5febb0da6f6d7106c403e6809917d89d6ee081ad 29-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Fix 'adb shell /system/bin/linker' crash

Bug: https://code.google.com/p/android/issues/detail?id=63174

(cherry picked from commit efe13832dccf2cec2898b89ca4418a6aac29d3eb)

Change-Id: I43629e4a14870f67abc2dd5ff2e3040c47b2168d
inker.cpp
65549969488bbce7f5d1b57714ba32c466943470 25-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Fix global variable initialization for linker

Linker now calls init functions for itself.

(cherry picked from commit 4151ea73b75e274d1ff80b42d9d457a783208516)

Change-Id: I3300fe22de8ad8466a5b1c2d551429769a42852d
inker.cpp
inker_allocator.cpp
inker_allocator.h
ests/linker_allocator_test.cpp
92d8b2320a4c3911452227f560ae4a39e83b0abf 23-Jul-2014 Nick Kralevich <nnk@google.com> debuggerd: if PR_GET_DUMPABLE=0, don't ask for dumping

PR_GET_DUMPABLE is used by an application to indicate whether or
not core dumps / PTRACE_ATTACH should work.

Security sensitive applications often set PR_SET_DUMPABLE to 0 to
disable core dumps, to avoid leaking sensitive memory to persistent
storage. Similarly, they also set PR_SET_DUMPABLE to zero to prevent
PTRACE_ATTACH from working, again to avoid leaking the contents
of sensitive memory.

Honor PR_GET_DUMPABLE when connecting to debuggerd. If an application
has said it doesn't want its memory dumped, then we shouldn't
ask debuggerd to dump memory on its behalf.

FORTIFY_SOURCE tests: Modify the fortify_source tests to set
PR_SET_DUMPABLE=0. This reduces the total runtime of
/data/nativetest/bionic-unit-tests/bionic-unit-tests32 from approx
53 seconds to 25 seconds. There's no need to connect to debuggerd
when running these tests.

Bug: 16513137

(cherry picked from commit be0e43b77676338fd5e6a82c9cc2b6302d579de2)

Change-Id: I6e1a9bce564e94fc19893d639b15f38c549cabfa
ebugger.cpp
4ac83fad3cdc486c00199eef9ea2a95d354839c4 23-Jul-2014 Elliott Hughes <enh@google.com> Fix a couple of bugs in generate-NOTICE and regenerate the NOTICE files.

(cherry picked from commit 3758a244cf758046b40f630a11aed41e68c9cfc2)

Change-Id: I6ffb83b4a7b7746b095205c664cf025a72ead179
OTICE
3002131da33401cf1b45abbdbec58b7c751fc43a 16-Jul-2014 Elliott Hughes <enh@google.com> Use VDSO for clock_gettime(2) and gettimeofday(2).

Bug: 15387103

(cherry picked from commit 625993dfbb085a3cde7492eda8ec1cdc1ee39a78)

Change-Id: I0e156d7049ba1495902259071a96936592e74025
inker_phdr.cpp
3139f6fdd7f9bec3b53be3da62314ae8ba24ceb4 09-Jul-2014 Elliott Hughes <enh@google.com> Merge "Remove __CTOR_LIST__ from mips/mips64."
40ad229b25671b43dc1cef29ecd5a7807aed5192 09-Jul-2014 Elliott Hughes <enh@google.com> Remove __CTOR_LIST__ from mips/mips64.

Change-Id: I3486b09e30b32ddb67da602cbc2b5fb0402f9764
rch/mips/begin.S
rch/mips64/begin.S
996524383f99cf513c181205cf61937faab85352 09-Jul-2014 Elliott Hughes <enh@google.com> Don't zero r1 on entry to the dynamic linker.

There's no need: __linker_init only takes one argument.

Also remove the arm __CTOR_LIST__; we use .init_array and .fini_array instead
of .ctor and .dtor anyway, and I don't think we've ever supported the latter.

Change-Id: Ifc91a5a90c6aa39d674bf0509a7af2e1ff0beddd
rch/arm/begin.S
rch/arm64/begin.S
rch/x86_64/begin.S
3a8646fc5d9f1a9304251a1d1c8ff9e523d81b40 08-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Change android_dlextinfo flags to uint64_t

Change-Id: Id27e8f8e58dbcf6ae79644f2ad3af3dd0aef9ae7
inker.cpp
15581383153c5da29befb7f5cdc30bc21e9da54b 08-Jul-2014 Elliott Hughes <enh@google.com> Regenerate the bionic NOTICE files.

Also fix a few formatting issues in copyright headers that were confusing
the script (though obviously it would be better if the script were smarter).

Change-Id: I7f561bef4f84fdcbd84f375ee226bd65db0e507b
OTICE
76e289c026f11126fc88841b3019fd5bb419bb67 03-Jul-2014 Nick Kralevich <nnk@google.com> Revert "Reenable support for non-PIE executables"

/system/bin/tf_daemon on Nakasi has been updated so it's
a PIE executable. We can now drop non-PIE support.

This reverts commit d81b3b275dff99561cbe5905ca63a1c72fa54a17.

Bug: 15086752
Bug: 15732002
Bug: 14566672
Change-Id: I832c4de01a8fa050754ea64da317d1639990265e
inker.cpp
d38306694179962f2d784fd1828afd4af1d8a4ec 03-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Build fix

Change-Id: Ib43e0f055e3c5f07b50393bfcab9738454835ac3
inker.cpp
04dc91ae763adc403a14c88b4c46f77b3d2d71a3 01-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Load library using file handle.

* This patch enables dlopen by file descriptor
instead of path/name.

Bug: 15984217
Change-Id: Ib39051e00567fb97070bf96d8ce63993877c0a01
inker.cpp
inker_phdr.cpp
fcac81ef04ade6f31eddb71bfc9a30a1ecf47840 02-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Native tests are now multilib=both by default

Change-Id: I788ac0b871703c137727a65e017c4466127c0190
ests/Android.mk
12bf3bcdeeaa0dcdc7a4f4e4d11bc2fc3bf6bd7a 01-Jul-2014 Dmitriy Ivanov <dimitry@google.com> Write message to stderr on __libc_fatal()

Change-Id: Ia8d6e256768fa51786d0139d3f3b6e9e4bebe027
inker.cpp
d97e9f546ea195686a78e539315b273393609b9e 29-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Add support for protected local symbol lookup.

Bug: http://code.google.com/p/android/issues/detail?id=66048
Change-Id: Ib334223df27adad9477fb241ab099c5e26df4a7d
lfcn.cpp
inker.cpp
inker.h
aa836f731016f7f1099d6a6ce47a35f1ec17dd4e 30-Jun-2014 Elliott Hughes <enh@google.com> Reinstate the x86 dynamic linker warning for text relocations.

Bug: 11358761
Change-Id: I4fc56ce7d76c9703a307ddd4d371d5e98bc6f51d
inker.cpp
e43c4a7a665032a29cb5ec15d4adbf81ea199220 29-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Disallow dlopen("egl/blah.so") on LP64

Bug: 7465467
Change-Id: Ibd3a4f1a6095f4397bde4f656e3c11b67f7edd47
inker.cpp
ddc449748bc3ff0ba574be00f4bbac9fba242e33 28-Jun-2014 Colin Cross <ccross@android.com> Merge "Revert "HACK: linker: check for handle==0xffffffff on LP64""
d81b3b275dff99561cbe5905ca63a1c72fa54a17 19-Jun-2014 Nick Kralevich <nnk@google.com> Reenable support for non-PIE executables

On Nakasi builds, /system/bin/tf_daemon is a pre-compiled
vendor supplied binary. When support for non-PIE executables
was removed, that daemon failed to start, which induced
a number of bugs.

* keystore is broken
* CTS runs will hang after a certain period of time

Temporarily reenable non-PIE support for 32-bit platforms
until Nakasi is fixed.

This rolls back the following commits:

Cleanup: updated comments
* 6275f2083415d22a6ce0de55645079cd47e0cc80
Cleanup: remove AARCH/ARM_COPY relocation support
* b906e13c55c9fe9b4157ba548534a0230434882b

And restricts the following patch to 64 bit only:

Remove support for non-PIE executables
* 2aebf5429bb1241a3298b5b642d38f73124c2026

Bug: 14566672
Bug: 15086752
Bug: 15732002
Change-Id: Ia2501aa14bd30feb4a6ce66bdb7c9f066dba0b5f
inker.cpp
ce44166c737b6737c3a0820bef10b074a5e36cf8 18-Jun-2014 Dmitriy Ivanov <dimitry@google.com> Fix weak function lookups

* Linker now correctly resolves function defined
with __attribute__((weak)).

Bug: https://code.google.com/p/android/issues/detail?id=70206
Change-Id: I82efb905676c25fefb1b11a13f5fecb0f1384657
lfcn.cpp
acfc63760eef50cd451b80df8860d17bbab1ca33 17-Jun-2014 Colin Cross <ccross@android.com> Revert "HACK: linker: check for handle==0xffffffff on LP64"

This reverts commit 346fea0805b8c2a20171c9b4ab1aac5f66ede5de.

Change-Id: Id3fd79451e4218e68e39ce22f21408cbf93255ee
lfcn.cpp
9d98ee17feb63d8bba2c115a0e3228c2558166d4 13-Jun-2014 Chris Dearman <chris.dearman@imgtec.com> [MIPS64] linker64 requires startup code

Change-Id: Iff2cd7d4dc40a67978bd9fc585b86e5a87afdbdd
ndroid.mk
1a586293400d0e1d73e6eb82f7dfe9d2d9ed3c4b 04-Jun-2014 Elliott Hughes <enh@google.com> Remove an unused parameter from the dlopen implementation.

Change-Id: I9297913a743bb570b48ebbe594ff711a481e89e0
lfcn.cpp
inker.cpp
inker.h
d286796fce1e6fff407b719a53eb2afbeb96c327 04-Jun-2014 Elliott Hughes <enh@google.com> Turn on -Wunused and fix the mistakes it uncovers.

Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501
ndroid.mk
inked_list.h
inker.cpp
ests/Android.mk
ce00354fec9dfad87090aad4ec79c418e42e92f4 23-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Do not add arcs to the soinfo graph on dlopen"
3c005d60194aadd92584258118c06782c9deab11 23-May-2014 Bjorn Andersson <bjorn.andersson@sonymobile.com> Do not add arcs to the soinfo graph on dlopen

While introducing RTLD_NOLOAD in b648a8a5 a change in how soinfo structs are
connected was also introduced. When calling dlopen the library that is loaded
is added as a child to the soinfo from which the caller comes - i.e. building a
dependency graph.

Unfortunately this shows issues upon unloading, such as blowing the stack if
there are loops in the graph.

This change reverts that part of b648a8a5, keeping everything as a child of the
root soinfo.

Change-Id: I604ee9210613b19f693a568158e69707620a95db
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
inker.cpp
2ea60ff0b415ad5b135f498a38c4b56ea75215aa 22-May-2014 Elliott Hughes <enh@google.com> Remove unnecessary #includes of <sys/atomics.h>.

Bug: 14903517
Change-Id: I7b5bcebe58774a441da986cc02376dd88e00ea0e
inker.cpp
ca1c80220e9b16fde7a761ca1c2c63dbe8071e0f 22-May-2014 Dmitriy Ivanov <dimitry@google.com> Removed dlsym handle != NULL check for lp64

* Removed unnecessary NULL check in dlsym
* Fixed dlsym_failure test to account for
correct RTLD_DEFAULT value
* Added temporary check for legacy RTLD_DEFAULT
value for non-yet-recompiled binaries

Bug: 15146875
Change-Id: I089fa673762629f5724b6e4fbca019d9cfc39905
lfcn.cpp
346fea0805b8c2a20171c9b4ab1aac5f66ede5de 21-May-2014 Colin Cross <ccross@android.com> HACK: linker: check for handle==0xffffffff on LP64

bionic RTLD_NEXT was changed from 0xffffffff to -1L, which breaks
existing binaries compiled. Temporarily look either until we can
get recompiled binaries.

Bug: 15113039
Change-Id: I1568fa0e4a832c5e6df21da74a33b22bde7f16f6
lfcn.cpp
f092feb81b36d024a3da4318a340e069ca1c2d3d 20-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Add R_X86_64_64 to the list of possible weak relocs"
b648a8a57ee42533a5bf127225a252f73ca2cbbc 20-May-2014 Dmitriy Ivanov <dimitry@google.com> Add RTLD_NOLOAD support and some related changes.

* Aligned RTLD_ values with glibc for lp64
* dlopen supports RTLD_NOLOAD flag
* soinfo_unload calls find_library(.., RTLD_NOLOAD)
instead of naive find_loaded_library_by_name()
* dlopen changed to add child to caller soinfo instead
of somain.

Bug: https://code.google.com/p/android/issues/detail?id=64069
Change-Id: I1a65f2c34f3e0edc6d2c41a2e408b58195feb640
lfcn.cpp
inker.cpp
inker.h
bb5bb2046fa0759d94995cbfb4f41137cd0b2a91 16-May-2014 Pavel Chupin <pavel.v.chupin@intel.com> Add R_X86_64_64 to the list of possible weak relocs

Change-Id: I768a5948d89701a1719734954a3524d3c7187e6a
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
inker.cpp
489e498434f53269c44e3c13039eb630e86e1fd9 20-May-2014 Dmitriy Ivanov <dimitry@google.com> Fix lookup-by-base-name for lp64

Bug:https://code.google.com/p/android/issues/detail?id=6670
Change-Id: I5b70e7cde7f40799148aca0a91fb2bb08e0f2b54
inker.cpp
00c855eb3d56a683e7c3c2d08b7be0451f74bb83 17-May-2014 Elliott Hughes <enh@google.com> Rethrow SIGTRAP too.

Bug: 15024256
Change-Id: I0347da9698a6ccd317ce6e6f7916d710d66e0f8a
ebugger.cpp
62e35755eb09caa6cf4892150fb87a6347afef6e 17-May-2014 Elliott Hughes <enh@google.com> debugger.cpp should know the names of the signals it catches.

Change-Id: I37908b07739ad465652f143848c52bc1ef19e421
ebugger.cpp
d59e50063ad708509f3ad83350be33f5612c4f54 09-May-2014 Dmitriy Ivanov <dimitry@google.com> Improve detection of already loaded libraries

Linker is now able to resolve symlinked libraries correctly.

soinfo is extended to save the graph of dependencies during
load/unload. Dependencies are used only in CallConstructor.

Bug: 9741592
Change-Id: Id9c48a74c46aa89bcdf3d54ec2f8ba3d398130b1
lfcn.cpp
inked_list.h
inker.cpp
inker.h
inker_allocator.cpp
inker_allocator.h
ests/Android.mk
ests/linked_list_test.cpp
6897b7b8b95beae120fd53e6fd15921d6420bea7 14-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Fix for linker allocator"
1079406cab09090cc11e26d4ac2f1ba9c4930cdb 14-May-2014 Dmitriy Ivanov <dimitry@google.com> Fix for linker allocator

Change-Id: I18a3f1a8515657f0deb69266184fb516a27f90e8
inker_allocator.cpp
ests/linker_allocator_test.cpp
1728b2396591853345507a063ed6075dfd251706 14-May-2014 Elliott Hughes <enh@google.com> Switch to g_ for globals.

That's what the Google style guide recommends, and we're starting
to get a mix.

Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
ebugger.cpp
lfcn.cpp
inker.cpp
inker.h
inker_debug.h
c6b5834ceb3df72608a8fe3526a2db337e504512 14-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Remove page level mprotects"
bc23e530c4db5175a065eeef36553c9c2c78fcf4 14-May-2014 Dmitriy Ivanov <dimitry@google.com> Remove page level mprotects

Freeing block mprotects on the page which it turn
may lead to application crash if linker subsequently
tries to modify another block on the page.

Bug: 14895266
Change-Id: I8ff7f5df467d7be184242de652032b3c84e24b76
inker_allocator.cpp
inker_allocator.h
ests/linker_allocator_test.cpp
d44927b8e9f4b2bcd376d1f84bad46f3ba9094de 13-May-2014 Dmitriy Ivanov <dimitry@google.com> Merge "Refactor linker allocator"
d597d263bc32422402d4810ce4ec070f0227c2f7 06-May-2014 Dmitriy Ivanov <dimitry@google.com> Refactor linker allocator

Makes it reusable for different fixed sized and not very
big structures (<PAGE_SIZE).

Change-Id: Id5ec13fc6541b1935ef7fe3671c22b98685abbae
ndroid.mk
inker.cpp
inker_allocator.cpp
inker_allocator.h
ests/Android.mk
ests/linker_allocator_test.cpp
6275f2083415d22a6ce0de55645079cd47e0cc80 12-May-2014 Dmitriy Ivanov <dimitry@google.com> Cleanup: updated comments

Bug: 14566672
Change-Id: I49ad28e3914b7d559db1e98542fee919db768f49
inker.cpp
b906e13c55c9fe9b4157ba548534a0230434882b 12-May-2014 Dmitriy Ivanov <dimitry@google.com> Cleanup: remove AARCH/ARM_COPY relocation support

They are only legal for ET_EXEC binaries and these are no
longer supported.

Bug: 14566672
Change-Id: I99e0ff47e8c572db474bc5e52df870a72269abb3
inker.cpp
2aebf5429bb1241a3298b5b642d38f73124c2026 07-May-2014 Nick Kralevich <nnk@google.com> Remove support for non-PIE executables

Don't support the dynamic linker loading ET_EXEC executables. Only
support ET_DYN executables.

Bug: 14566672
Change-Id: Ia1f2bfffe7ea867c1cd62e67d7fd637c60c0728d
inker.cpp
9b5ee4aa85cf55467eb9a749b6602f6f2ba1cfc6 06-May-2014 Torne (Richard Coles) <torne@google.com> Merge "Handle empty relro segment or incorrectly sized file."
5ca7ed9005ea16733d7c87d7154473b7a500be0c 03-May-2014 Dmitriy Ivanov <dimitry@google.com> Disallow dlopen("egl/blah.so") on LP64

Change-Id: I9a563a9dada6522129b1890bc1292667230e80a5
inker.cpp
26ec9679ff01fb155ae21015f31cc95bed24f670 30-Apr-2014 Torne (Richard Coles) <torne@google.com> Handle empty relro segment or incorrectly sized file.

If the file has no relro segment, the generated relro file will have
length 0, which caused mmap to fail. If the relro file has nonzero size,
but is too short (e.g. because it's for the wrong version of the
library), the linker would segfault while comparing the data. Fix both
these issues: don't try to map a zero length file, and don't try to
compare data that would be beyond the end of the file.

Improve test to explicitly generate two versions of the library: one
with -z relro, and one with -z norelro, so we can test both cases; also
explicitly test the case where the relro file has length 0.

Bug: 14299541
Change-Id: Id8b95585edda90e8bb5de452a35b70ed2d224934
inker_phdr.cpp
b7e289ed028ee73fda4c044e07d3ec6f783a0ef4 26-Apr-2014 Elliott Hughes <enh@google.com> Pass si_code through to debuggerd.

Because we re-raise various signals, we corrupt the si_code that debuggerd
sees when it ptraces our siginfo. One possible solution (shown here) is to
pass the original si_code value in the message we send to debuggerd.

Change-Id: I76f9aa2c0442e5cab611d132532409e700383907
ebugger.cpp
0dcf06f976670b5d05286b184d150f61b71c1184 22-Apr-2014 Torne (Richard Coles) <torne@google.com> Fix arm64/x86 build.

Add missing second param to soinfo_link_image in a section that's not
compiled on ARM.

Bug: 13005501
Change-Id: Id0ede8e03da4e05b25c0aeb24a840f868031d4e8
inker.cpp
b1bfa7956c56c28b8c914e6606df191e094e7b42 22-Apr-2014 Torne (Richard Coles) <torne@google.com> Merge "Allow sharing the RELRO section via a file."
c363e5dd0a15aac9036b453f655a3a0ae5cd32cd 22-Apr-2014 Torne (Richard Coles) <torne@google.com> Merge "Support loading libraries to a reserved address."
16f6429c38c24236418cf127a4c11c5d8a2fd47b 22-Apr-2014 Torne (Richard Coles) <torne@google.com> Merge "Add android_dlopen_ext() interface to linker."
8abf44c415bb3b02b6a3198196c92266442a0c32 19-Apr-2014 Elliott Hughes <enh@google.com> Merge "Make libc signal handler output more like debuggerd."
17e6a98b48c4f228adb37c8d37bbf71dd2a1c513 19-Apr-2014 Elliott Hughes <enh@google.com> Make libc signal handler output more like debuggerd.

This has been annoying me for a while, because it's often quite misleading.

Today, for example, I saw:

Fatal signal 13 (SIGPIPE) at 0x6573 (code=0), thread 25971 (top)

where the apparent address is actually the pid of the signal source (in this
case the kernel on behalf of the thread itself).

This patch isn't as fancy as strace, but it at least means we never say
anything misleading. We could decode the si_code field like strace and
debuggerd, but I'm reluctant to do that without some way to share the code
between at least bionic and debuggerd.

Examples after:

Fatal signal 13 (SIGPIPE), code 0 in tid 9157 (top)
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 9142 (crasher64)
Fatal signal 6 (SIGABRT), code -6 in tid 9132 (crasher64)

(Note that the code still shows as 0 for SIGPIPE in the signal handler itself
but as -6 (SI_TKILL) in debuggerd; this is actually correct --- debuggerd is
showing the re-raised signal sent at the end of the signal handler that
initially showed the correct code 0.)

Change-Id: I71cad4ab61f422a4f6687a60ac770371790278e0
ebugger.cpp
865119efd47ae3cae5a0c09c6a9cc184a10614c1 18-Apr-2014 Du Chenyang <chenyang.du@intel.com> Temporarily disable text relocation warnings for x86 libraries

Too many such warnings will cause CTS failed. This issue still exists
in some x86 version libraries: libdvm.so/libart.so.

$scanelf -qT out/target/product/generic_x86/system/lib/libdvm.so
libdvm.so: (memory/data?) [0x2BAC7] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8]
libdvm.so: (memory/data?) [0x2BB98] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8]
libdvm.so: (memory/data?) [0x2EB28] in (optimized out: previous dvmAsmInstructionStartCode) [0x2B2F8]
libdvm.so: (memory/data?) [0x2EF87] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
libdvm.so: (memory/data?) [0x2EFAF] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
libdvm.so: (memory/data?) [0x2EFD7] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
libdvm.so: (memory/data?) [0x2EFFF] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]
libdvm.so: (memory/data?) [0x2F027] in (optimized out: previous dvmAsmInstructionEndCode) [0x2EF63]

Bug: https://code.google.com/p/android/issues/detail?id=68431
Change-Id: I11ecac282f1163e49a82156fce2a76cc2d619960
inker.cpp
183ad9df536ab04ef35a397a1f4724e4e401d11f 27-Feb-2014 Torne (Richard Coles) <torne@google.com> Allow sharing the RELRO section via a file.

Add flags and a file descriptor to android_dlopen_ext() to allow writing
the RELRO section of the loaded library to a file after relocation
processing, and to allow mapping identical pages from the file over the
top of relocated memory in another process. Explicitly comparing the
pages is required in case a page contains a reference to a symbol
defined in another library loaded at a random base address.

Bug: 13005501
Change-Id: Ibb5b2d384edfaa5acf3e97a5f8b6115c10497a1e
inker.cpp
inker_phdr.cpp
inker_phdr.h
12bbb9164578b6512b8b07a3fb093858244b7c7b 06-Feb-2014 Torne (Richard Coles) <torne@google.com> Support loading libraries to a reserved address.

Add flags and parameters to android_dlopen_ext() to allow loading a
library at an already-reserved fixed address. If the library to be
loaded will not fit within the space reserved, then the linker will
either fail, or allocate its own address space as usual, according to
which flag has been specified. This behaviour only applies to the
specific library requested; any other libraries loaded as dependencies
will be loaded in the normal fashion.

There is a new gtest included to cover the functionality added.

Bug: 13005501
Change-Id: I5d1810375b20fc51ba6a9b3191a25f9792c687f1
inker.cpp
inker_phdr.cpp
inker_phdr.h
012cb4583a5f8564059142bb1900ea3a31e7cfa9 06-Feb-2014 Torne (Richard Coles) <torne@google.com> Add android_dlopen_ext() interface to linker.

Add a function "android_dlopen_ext()", defined in <android/dlext.h>.
This is an extended version of dlopen() which takes a struct for passing
additional parameters for Android-specific functionality. This will be
used to support RELRO section sharing between separate processes.

Bug: 13005501
Change-Id: I9c99b2f2a02ee329dedaeba09ef3a1113b17b2d6
lfcn.cpp
inker.cpp
inker.h
88b44feb7dd792348f2755c30cc7356509929917 01-Apr-2014 Elliott Hughes <enh@google.com> Remove duplicate line in linker/Android.mk.

Change-Id: I7b4d5fcdfacc840bbda4ffd965e5315c4651cfe5
ndroid.mk
c19972a4ca24512e017ad501bf446a489d4236e7 31-Mar-2014 Christopher Ferris <cferris@google.com> Merge "Use __unused instead of UNUSED in linker.cpp"
406a75d371361388fe179950a3de459ae7e16f33 27-Mar-2014 Colin Cross <ccross@android.com> linker: use LOCAL_MULTILIB := both style to build linker64

Use LOCAL_MODULE_STEM_32 and LOCAL_MODULE_STEM_64 to build
linker and linker64. Set LOCAL_MULTILIB := both for consistency
with other rules of this type, although LOCAL_MULTILIB := both is
only consumed by executable.mk which is skipped by
linker_executable.mk. Duplicate the necessary new parts of
executable.mk.

Change-Id: I888e87cf125cfbcfdee6a55b6377d8bc5ce402ea
ndroid.mk
inker.mk
812fd4263a005b88f3b4222baa910114f938d594 25-Mar-2014 Kito Cheng <kito@0xlab.org> Use __unused instead of UNUSED in linker.cpp

- sys/cdefs.h already define __unused, just use it
instead of define a local one.

Change-Id: Iacf3da9193e65e1f34b12760b28bcb64b67cb790
inker.cpp
851e68a2402fa414544e66650e09dfdaac813e51 20-Feb-2014 Elliott Hughes <enh@google.com> Unify our assembler macros.

Our <machine/asm.h> files were modified from upstream, to the extent
that no architecture was actually using the upstream ENTRY or END macros,
assuming that architecture even had such a macro upstream. This patch moves
everyone to the same macros, with just a few tweaks remaining in the
<machine/asm.h> files, which no one should now use directly.

I've removed most of the unused cruft from the <machine/asm.h> files, though
there's still rather a lot in the mips/mips64 ones.

Bug: 12229603
Change-Id: I2fff287dc571ac1087abe9070362fb9420d85d6d
rch/arm64/begin.S
rch/mips64/begin.S
rch/x86_64/begin.S
006f9ad8910c945cd50e54f6c34d8c27b11c1193 19-Feb-2014 Benjamin Adolphi <b.adolphi@gmail.com> Linker writes to wrong memory location when processing DT_MIPS_RLD_MAP

When bionic's dynamic linker processes the .dynamic section of a MIPS ELF binary and encounters the DT_MIPS_RLD_MAP dynamic array tag, it calculates the address of where to write a pointer to the _r_debug structure. The current implementation simply reads the value given in the d_ptr field and writes the pointer address to that location. However, this value has to be adjusted to reflect the real load address of the binary. Otherwise the linker will write to a faulty location possibly resulting in a crash when linking a MIPS binary that includes DT_MIPS_RLD_MAP. This change corrects that problem.

Change-Id: I1a91874f7ab47289001fe72d9016660c14c70362
Signed-off-by: Benjamin Adolphi <b.adolphi@gmail.com>
inker.cpp
36ee4ab243427ce20549914fef85b5ca2ac75cda 13-Feb-2014 Colin Cross <ccross@android.com> build linker and linker64 on 64-bit architectures

Change-Id: I400bbaf5a779fc427de4c3d86c66548b0179b10d
ndroid.mk
inker.mk
inker_executable.mk
c62b8a4d3f73b070099d9aa594a261b5250d6cc9 13-Feb-2014 Elliott Hughes <enh@google.com> Remove unused variables not spotted by GCC.

Change-Id: I49a16096bc0f41f3ad0007249161e8bdfcf3438c
inker.cpp
faf05bacd45719291b371f24b1b89543881b37f6 12-Feb-2014 Elliott Hughes <enh@google.com> Clean up all the lint cpplint can find in the dynamic linker.

Change-Id: Ic9ee7153817c22a252cc4b309283e355b623cab9
lfcn.cpp
inker.cpp
inker_debug.h
inker_phdr.cpp
9918665a45095ad135576f005c0e5307feb366a1 07-Feb-2014 Chris Dearman <chris.dearman@imgtec.com> [MIPS64] Dynamic linker

Change-Id: I937c7c776cae3d66e214798d5217a922cd106bfc
Signed-off-by: Chris Dearman <chris.dearman@imgtec.com>
Signed-off-by: Duane Sand <duane.sand@imgtec.com>
rch/mips64/begin.S
lfcn.cpp
inker.cpp
inker.h
0266ae5f884d72da58f33a072e865ba131234a5e 11-Feb-2014 Elliott Hughes <enh@google.com> Switch <elf.h> over to linux uapi under the covers.

Remove the linker's reliance on BSD cruft and use the glibc-style
ElfW macro. (Other code too, but the linker contains the majority
of the code that needs to work for Elf32 and Elf64.)

All platforms need dl_iterate_phdr_static, so it doesn't make sense
to have that part of the per-architecture configuration.

Bug: 12476126
Change-Id: I1d7f918f1303a392794a6cd8b3512ff56bd6e487
lfcn.cpp
inker.cpp
inker.h
inker_phdr.cpp
inker_phdr.h
3a9c5d66dc8d41272f51482b713717af7049697e 10-Feb-2014 Elliott Hughes <enh@google.com> Fix <link.h>.

Also move some of the stuff that should be in <link.h> out of the
private "linker.h", to make it clearer that these are public API
known to gdb that we can't change.

Bug: 12554197
Change-Id: I830e1260d3d8b833ed99bc1518f1c6b6102be8af
inker.cpp
inker.h
62e9c76ee89effccfbbff08167dbaa5e52618be3 01-Feb-2014 Elliott Hughes <enh@google.com> Clean up debugger.cpp slightly.

In particular, don't do weird things with 'int tid'.

Change-Id: I0fd9158a452967163508ada8987de9494ad5f9af
ebugger.cpp
f858bd1c6eec7eb6bbfc8844e0de096be011e99a 01-Feb-2014 Elliott Hughes <enh@google.com> LP64 binaries should talk to debuggerd64.

Change-Id: I7eb30f9d04f80b6b45d3148757970d3f1117493c
ebugger.cpp
5ceb889ac9a36e74e4e00c34c57cbb58d73e228c 03-Dec-2013 Weiwu Chen <weiwu.chen@intel.com> bionic: Change the type of soinfo's size to size_t

Some system functions like munmap expect soinfo's size to be size_t, but currently
it is unsigned. Change it to size_t to fit 64bit's portability.

Change-Id: I0bf6d522b38b0cd9bf1db05b004b5326217412a2
Signed-off-by: Weiwu Chen <weiwu.chen@intel.com>
Signed-off-by: Qiming Shi <qiming.shi@intel.com>
inker.cpp
inker.h
4041b13c204fc1e2fc799b67ce15347d9ad6c8d9 26-Jan-2014 Qiming Shi <qiming.shi@intel.com> bionic: Do not use magic number for portability

Do not use the magic number 0xFFFFFFFFU to represent the max value of an address
as it's not correct on 64bit platform. We should use UINTPTR_MAX instead.

Change-Id: I1fc6f5864a651b2eddea2333cb0788f9d9223270
Signed-off-by: Qiming Shi <qiming.shi@intel.com>
Signed-off-by: Weiwu Chen <weiwu.chen@intel.com>
inker_phdr.cpp
d1973ca51325393f304e82a4d79874f33e54ac16 22-Jan-2014 Colin Cross <ccross@android.com> bionic: rename aarch64 target to arm64

Rename aarch64 build targets to arm64. The gcc toolchain is still
aarch64.

Change-Id: Ia92d8a50824e5329cf00fd6f4f92eae112b7f3a3
rch/aarch64/begin.S
rch/arm64/begin.S
lfcn.cpp
a4aafd156068ee174012f28cd894dbecf0e4ab90 14-Jan-2014 Elliott Hughes <enh@google.com> Make it possible for code to query the dynamic linker's default search path.

We're not going to have init(1) set LD_LIBRARY_PATH globally on 64-bit.
This patch makes it possible for libnativehelper to set LD_LIBRARY_PATH
in each Java VM (to support System.loadLibrary) without also hard-coding
the default search path there.

Change-Id: If13961fae976e06dd80d5ef522f31e8b7eb01154
lfcn.cpp
inker.cpp
inker.h
7ff07ad3213f3342678d2d03047b2e51d8b81748 13-Jan-2014 Elliott Hughes <enh@google.com> Add -Bsymbolic to the ld flags when linking the dynamic linker.

We don't need this on architectures other than aarch64, and
we're still investigating why we need it on aarch64, but it
doesn't seem unreasonable to have this flag set when linking
the dynamic linker anyway; it's clearly the intended behavior.

Change-Id: I4fa1b4ae543a818979934bf818eabac03bb9154f
ndroid.mk
1272dbd1d76c979358fff3beae9de0c1462345af 10-Jan-2014 Elliott Hughes <enh@google.com> Add NT_PRSTATUS to <elf.h>.

Needed by aarch64.

Bug: 12476126
Change-Id: I7764664459a06cf4f2a60e707bd968d321a78430
inker.h
54a7494f17f80d6c548a58434bcb5579a26cc125 04-Jan-2014 Elliott Hughes <enh@google.com> Regenerate the NOTICE files.

Also standardize the orthography in a few places to reduce near-duplicates
in the NOTICE files.

Change-Id: I347c75e817be61ec1b9c5b4b96226feedc8d09ab
OTICE
b93702a0463fa0b87bf25d7ae9bdb09a35ea6a50 22-Dec-2013 Elliott Hughes <enh@google.com> Improve dynamic linker diagnostics for internal errors.

If the linker can't resolve its own internal references to symbols,
we currently exit silently (albeit with EXIT_FAILURE). Not very helpful.

Change-Id: I1614fc970dee4560b38832ede1987b65a8e53a1e
inker.cpp
e365f9d6543bc6607864ef61257505239dde15d1 10-Oct-2013 Marcus Oakland <marcus.oakland@arm.com> AArch64: Linker64 support for AArch64

Addition of support for AArch64 in the linker64 target.

Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
ndroid.mk
rch/aarch64/begin.S
ebugger.cpp
lfcn.cpp
inker.cpp
inker_phdr.cpp
5407eed84b98056a5af7d95007d8d511ebad60e4 09-Dec-2013 Pavel Chupin <pavel.v.chupin@intel.com> Fix debugging issues in vdso handling

Under valgrind ehdr_vdso is null and causing segfault.
Adding debug info for vdso producing plenty of issues on debugging
through gdbserver, removing it. It doesn't seem it should be here.

Unwinding through vdso test still works.

Change-Id: I1a7e233c493f2268d725fa8d7279822d07decc49
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
inker.cpp
ebd506c69e12b6dcaf5be94cc8ed1b53af299f9f 31-Oct-2013 Sergey Melnikov <sergey.melnikov@intel.com> Fix linker crashes during unknown symbol lookup

Integration of kernel VDSO into internal bionic data structures using
common functions.
Fix for dl_iterate_phdr function: the function provides incorrect
address of object in case of nonzero virtual and base addresses.
Location in address space of a particular program header should be
calculated using the formula: addr = base_addr + virtual_addr.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ie2ab4257fd456242aab8afed0bd5bd6b29e81d6d
inker.cpp
74ce45972d88604aa759040cfd2570674cfb439d 28-Oct-2013 Elliott Hughes <enh@google.com> Update <sys/exec_elf.h> to get the DF_* flags.

Change-Id: Ia9e785f6b95122f94ee3b01a312db1d5bb91a72e
inker.h
e4d792adb8d6f9228b9ac9dc1ad7f43b271f085f 28-Oct-2013 Elliott Hughes <enh@google.com> Don't allow text relocations on 64-bit.

I've also updated our <sys/exec_elf.h> to match upstream.

Change-Id: I52f9fce3167541811208d273ff23ceaa112f7135
lfcn.cpp
inker.cpp
inker.h
4eeb1f12a8b63afc0d0ad4d466b16fbffb21cd5a 26-Oct-2013 Elliott Hughes <enh@google.com> Clean up linker architecture macros.

We don't need our own architecture macros; the standard ones will do.

This patch also fixes some __x86_64__ tests to be USE_RELA tests instead,
because they're not actually x86_64-specific.

I've cleaned up architecture-specific code slightly so where possible
all the code corresponding to a particular architecture is together.

This patch also fixes a bug in LP64 DT_PLTGOT handling, which should be
an error rather than falling through into DT_DEBUG! There was another #ifdef
bug where we'd only report unexpected DT_ entries on MIPS.

Change-Id: Id1d04e372611f641c1aa278a18e379f28af9eaf5
ndroid.mk
ebugger.cpp
lfcn.cpp
inker.cpp
inker.h
inker_phdr.cpp
inker_phdr.h
60d5b06eceeef9a21168f1c9f5264e4fc8ed0566 25-Oct-2013 Elliott Hughes <enh@google.com> Simplify defining the linker architecture macro.

Like the new TODO says, though, do we need this at all? Wouldn't we be better
off just using the regular architecture-specific macros? This is a dynamic
linker, so there's never a possibility of cross-linking.

Change-Id: I7be6b8663f5e585c4024a49aae383430c86a3c1b
ndroid.mk
b8b0b6b412267e514c99a6d3636aefa3c7715673 25-Oct-2013 Elliott Hughes <enh@google.com> Revert "Don't warn about x86 text relocations. They're too prevalent."

This reverts commit 5be2c5998c996ff9d5efb94c127d9b832a295822.

Change-Id: I3fc8ca530cdbd74c834fb9cfabe812c9386419fc
inker.cpp
5be2c5998c996ff9d5efb94c127d9b832a295822 23-Oct-2013 Elliott Hughes <enh@google.com> Don't warn about x86 text relocations. They're too prevalent.

We should fix this (and disallow it for x86_64), but for now let's get CTS
running again.

libdvm.so and libcutils.so are the main problems.

$ scanelf -qT out/target/product/generic_x86/symbols/system/lib/libcutils.so
libcutils.so: (memory/data?) [0x4125] in (optimized out: previous android_memset16) [0x4100]
libcutils.so: (memory/data?) [0x424F] in (optimized out: previous android_memset16) [0x4100]
libcutils.so: (memory/data?) [0x42F8] in (optimized out: previous android_memset16) [0x4100]
libcutils.so: (memory/data?) [0x4349] in (optimized out: previous android_memset16) [0x4100]
libcutils.so: (memory/data?) [0x4406] in (optimized out: previous android_memset16) [0x4100]
libcutils.so: (memory/data?) [0x45AC] in (optimized out: previous android_memset32) [0x4590]
libcutils.so: (memory/data?) [0x4650] in (optimized out: previous android_memset32) [0x4590]
libcutils.so: (memory/data?) [0x46F9] in (optimized out: previous android_memset32) [0x4590]
libcutils.so: (memory/data?) [0x474A] in (optimized out: previous android_memset32) [0x4590]
libcutils.so: (memory/data?) [0x4807] in (optimized out: previous android_memset32) [0x4590]

Bug: 11353056
Change-Id: Id4a76b310be7fe858a8a60d0d260b09913b66be9
inker.cpp
3d4470c14a57b0b9ae74060370be53469e95d6a1 22-Oct-2013 Nick Kralevich <nnk@google.com> change wording on text relocation message.

The current message is too alarmist.

Change-Id: I53e8eadca239f867b4e6b9c193eba96e267950c3
inker.cpp
2258347f3bb770641a7d8fe311911ace8f69cb20 17-Oct-2013 Elliott Hughes <enh@google.com> Build the linker with the same -std flags as the rest of bionic.

Change-Id: I5bdb28ecfdf78a90f6b072077a1c5ffd63f5d2ae
ndroid.mk
41b87c651280d1a9a98a309c5a5e77e240920d4e 17-Oct-2013 Elliott Hughes <enh@google.com> Merge "x86_64: Add R_X86_64_64 relocation handling"
c7e9b2331771e5e87c34a8ee3dc6cc41d35b02fe 17-Oct-2013 Elliott Hughes <enh@google.com> Fix sigaction(3) for 64-bit.

Also clean up <signal.h> and revert the hacks that were necessary
for 64-bit in linker/debugger.cpp until now.

Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
ebugger.cpp
c075c18537d18ccb6760ba1f5727ce2c0890285a 16-Oct-2013 Pavel Chupin <pavel.v.chupin@intel.com> x86_64: Add R_X86_64_64 relocation handling

Change-Id: I86ffc56fa6a9053bed44e92a579530c2beb8eb2c
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
inker.cpp
1a57f9f75c5752d990a2749b000ec4ceace94b54 06-Feb-2013 Pavel Chupin <pavel.v.chupin@intel.com> x86_64: Rename 64-bit linker to linker64

That's for having both on the same system.

Change-Id: Ic2bc2c015e6486e8b6a7576f7b28d2d027534368
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
inker.cpp
eb847bc8666842a3cfc9c06e8458ad1abebebaf0 10-Oct-2013 Elliott Hughes <enh@google.com> Fix x86_64 build, clean up intermediate libraries.

The x86_64 build was failing because clone.S had a call to __thread_entry which
was being added to a different intermediate .a on the way to making libc.so,
and the linker couldn't guarantee statically that such a relocation would be
possible.

ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC

This patch addresses that by ensuring that the caller and callee end up in the
same intermediate .a. While I'm here, I've tried to clean up some of the mess
that led to this situation too. In particular, this removes libc/private/ from
the default include path (except for the DNS code), and splits out the DNS
code into its own library (since it's a weird special case of upstream NetBSD
code that's diverged so heavily it's unlikely ever to get back in sync).

There's more cleanup of the DNS situation possible, but this is definitely a
step in the right direction, and it's more than enough to get x86_64 building
cleanly.

Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
lfcn.cpp
inker.cpp
inker_environ.cpp
2a0b873065edb304fa2d1c54f8de663ea638b8ab 09-Oct-2013 Elliott Hughes <enh@google.com> Fix __errno for LP64 and clean up __get_tls.

If __get_tls has the right type, a lot of confusing casting can disappear.

It was probably a mistake that __get_tls was exposed as a function for mips
and x86 (but not arm), so let's (a) ensure that the __get_tls function
always matches the macro, (b) that we have the function for arm too, and
(c) that we don't have the function for any 64-bit architecture.

Change-Id: Ie9cb989b66e2006524ad7733eb6e1a65055463be
lfcn.cpp
011bc0ba45a8b7766a205cb21269dbafb32294b6 08-Oct-2013 Elliott Hughes <enh@google.com> Use /system/lib64 and /vendor/lib64 for 64-bit libraries.

Change-Id: I4886aeb3070bf97b4cfe8053388ecb1bda288017
inker.cpp
0f395b7ba056ccec3915737cfece81ca2161e980 08-Oct-2013 Elliott Hughes <enh@google.com> Make logging fall back to /dev/stderr if we're on the host.

Otherwise you get no logging, which sucks.

Change-Id: Iea1e8f996461afbb217a55711b7967005c39cfcb
inker_debug.h
d7398f146dad064dece704db9e13912f65da0acc 08-Oct-2013 Elliott Hughes <enh@google.com> Use linker64 for the 64-bit linker.

Change-Id: I13fc7f93274f99e4cf99b077afdf5293e7233f39
ndroid.mk
afac15d686460267ff20ce4786b9a7c5796a1ea8 08-Oct-2013 Elliott Hughes <enh@google.com> Use C99 structure initializer designator style.

clang warns about using the GCC style of designator.

Change-Id: I86ec79f06c8774618082859f48d7d1f576520e32
lfcn.cpp
c00f2cb587630d5e954c7f548749f1e3170b3cb1 05-Oct-2013 Elliott Hughes <enh@google.com> x86_64 linker.

Based on I8dc3e2cb596f75dc58ae82e4dc58f8c177dd3323 by
Pavel Chupin <pavel.v.chupin@intel.com>.

Change-Id: Icd582d277cbe273477b450f2848343d72c86ec9f
ndroid.mk
rch/x86_64/begin.S
ebugger.cpp
lfcn.cpp
inker.cpp
inker.h
inker_phdr.cpp
inker_phdr.h
99f0e1a329aa8e05bbd5a5d4b90ec87a8549cfd2 08-Oct-2013 Stephen Hines <srhines@google.com> Fix Clang warning since KernelArgumentBlock is actually a class.

Change-Id: Id72868d80feffbbc5f7d1e43beaed5d4e4d95f52
inker_environ.h
c620059479c47a78d57086d73726c9adc2f337ad 01-Oct-2013 Elliott Hughes <enh@google.com> Remove 32-bit assumptions from the ELF code.

Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
ebugger.cpp
lfcn.cpp
inker.cpp
inker.h
inker_phdr.cpp
inker_phdr.h
24053a461e7a20f34002262c1bb122023134989d 20-Aug-2013 Christopher Ferris <cferris@google.com> Add the dl_iterate_phdr function to libdl for arm.

Bug: 8410085

Merge from internal master.

(cherry-picked from cb491bc66dc0abc145930b09086eb9189a30f6c2)

Change-Id: I94ed51bc5d4c626df7552c0e85c31ccee2d6568f
lfcn.cpp
inker.cpp
87c358524e479235aa6241736d2ce325f89daafc 21-Aug-2013 Brian Carlstrom <bdc@google.com> Make mips_relocate_got tolerate a missing got

Bug: 10094803

(cherry picked from commit 7ee26878065abb494600595349ce58b2b2db3709)

Change-Id: Ib15bccecaee421dc463d46a3956b054051708759
inker.cpp
0e79b9196254cdd210a59cc00d07b88a796a3a0d 14-Aug-2013 Brian Carlstrom <bdc@google.com> Add more information to error due to truncated Elf32_Ehdr

Change-Id: I24f30bd0c1120bcf85d77f5c4e69f0fefe9a2478
inker_phdr.cpp
cbf07a25149cd924a348e4dc0395c5d08f86fd7f 17-Jul-2013 Elliott Hughes <enh@google.com> am 2be511d4: Merge "Improve stack overflow diagnostics (take 2)."

* commit '2be511d405d47eccc61a6e3c338d1877bf33b4fa':
Improve stack overflow diagnostics (take 2).
84114c8dd5b17efecf7988f263ce431208d7be5a 17-Jul-2013 Elliott Hughes <enh@google.com> Improve stack overflow diagnostics (take 2).

This reverts commits eb1b07469f2b5a392dc1bfd8adc211aea8c72bc5 and
d14dc3b87fbf80553f1cafa453816b7f11366627, and fixes the bug where
we were calling mmap (which might cause errno to be set) before
__set_tls (which is required to implement errno).

Bug: 8557703
Change-Id: I2c36d00240c56e156e1bb430d8c22a73a068b70c
ebugger.cpp
6f08b8659a3682b7e774af6ed68b1b613e147f1b 17-Jul-2013 Guang Zhu <guangzhu@google.com> am 2cf5a6f6: Merge "Revert "Improve stack overflow diagnostics.""

* commit '2cf5a6f6627549842c0c840ff3615ae942a90ea3':
Revert "Improve stack overflow diagnostics."
d14dc3b87fbf80553f1cafa453816b7f11366627 17-Jul-2013 Guang Zhu <guangzhu@google.com> Revert "Improve stack overflow diagnostics."

This reverts commit aa754dca90487356cabf07ade0e8d88c2630b784.

Change-Id: Ifa76eee31f7f44075eb3a48554315b2693062f44
ebugger.cpp
10a954dea6732232ed6cf56d3aa6ca38673dacbf 17-Jul-2013 Elliott Hughes <enh@google.com> am 026867c7: Merge "Improve stack overflow diagnostics."

* commit '026867c7dcce7828212dcd4a61806146908e9039':
Improve stack overflow diagnostics.
aa754dca90487356cabf07ade0e8d88c2630b784 16-Jul-2013 Elliott Hughes <enh@google.com> Improve stack overflow diagnostics.

We notify debuggerd of problems by installing signal handlers. That's
fine except for when the signal is caused by us running off the end of
a thread's stack and into the guard page.

Bug: 8557703
Change-Id: I1ef65b4bb3bbca7e9a9743056177094921e60ed3
ebugger.cpp
d31287d6017475209cfee2fea0532bdc8c0f4aac 25-Jun-2013 Elliott Hughes <enh@google.com> am 7d624e9a: Merge "Kernel dso support for \'dl_iterate_phdr\' function"

* commit '7d624e9aff4c6addea7f2275fe58ff0815d95c70':
Kernel dso support for 'dl_iterate_phdr' function
c45087bffa528c0809f0df2e0a3708eba7018b33 25-Jan-2013 Sergey Melnikov <sergey.melnikov@intel.com> Kernel dso support for 'dl_iterate_phdr' function

Kernel provides virtual DSO for stack unwinding/exception handlind info for
signal usage case. Stack unwinding routines use 'dl_iterate_phdr' function
for additional DWARF info gathering from DSOs. Patch enables virtual DSO
enumeration via dl_iterate_phdr function.

Signed-off-by: Sergey Melnikov <sergey.melnikov@intel.com>
Change-Id: Ic2882b28f40b456a088bc1e63c50cbfda7e4a102
inker.cpp
100d678438f222ad6ef8f3dc0646911b218c50a9 22-Jun-2013 Nick Kralevich <nnk@google.com> am 53ddcc90: Merge "linker: Emit a warning on text relocations"

* commit '53ddcc90701d86c7d809a84cf4710c651066e3c7':
linker: Emit a warning on text relocations
c9084427aa15259c8bfb9b13b979597a4abd1805 21-Jun-2013 Nick Kralevich <nnk@google.com> linker: Emit a warning on text relocations

Text relocations unnecessarily mark pages as dirty, preventing them
from being swapped out, wasting memory. Also, text relocations
prevent the code from running on certain hardened systems.

Print a message in logcat and stderr when we see a text relocation,
to encourage developers to fix their code.

Change-Id: I6051a7463911e090ae5727a355397d539669d5b9
inker.cpp
45ef218bde353df455062aa3c9a9f84ffed769fc 18-Jun-2013 Elliott Hughes <enh@google.com> am 6807af77: Merge "Make LD_PRELOAD failures just warnings."

* commit '6807af773f862750efb6860e00402580a5f463f3':
Make LD_PRELOAD failures just warnings.
7e5a8cc5230dcc027686813e51a1b001cee4c602 18-Jun-2013 Elliott Hughes <enh@google.com> Make LD_PRELOAD failures just warnings.

This matches glibc and makes life easier for developers who want to
sometimes preload a library from init (which has no conditionals); they
can simply move/remove the library to disable.

Change-Id: I579b8633f958235af6e46bb53b378b9e363afb1f
inker.cpp
inker.h
d978d21d195976fa3f257b8d17ec2fe18fb436a7 11-Jun-2013 Brian Carlstrom <bdc@google.com> am 8252b8e4: Merge "Honor p_vaddr if set"

* commit '8252b8e4b730b13623f31dc66396e000586d1c58':
Honor p_vaddr if set
e7dffe150b3c1c835c669ec03965e37fead13de7 11-Jan-2013 Brian Carlstrom <bdc@google.com> Honor p_vaddr if set

(cherry picked from commit 88ff15c2c279d2bbe3569101b36cd2aa0931a0a9)

Change-Id: I4aabbe911d30aea8ace69e29bb6e980a4e89de90
inker_phdr.cpp
inker_phdr.h
81bfade818f1b76cf822f0e7e0862fe61e7c580a 04-Jun-2013 Brian Carlstrom <bdc@google.com> am 06713930: Merge "Small cleanup of soinfo_elf_lookup."

* commit '0671393072a78e75a726c58aa3ca718e55eeac3e':
Small cleanup of soinfo_elf_lookup.
6bec5b792a5f034089a942cb28cab26d36408235 04-Jun-2013 Christopher Ferris <cferris@google.com> Small cleanup of soinfo_elf_lookup.

- Remove unnecessary line.
- Move declarations to first use.

Change-Id: I1d8398d6c13f7cb86bffe0b68af849e35a4b234d
inker.cpp
46bf467a151eafaf37f6e3578d8d9bad705b8e44 22-May-2013 Brian Carlstrom <bdc@google.com> am f5f29de6: Merge "Fix bionic linker to support segments with zero p_filesz"

* commit 'f5f29de6ae5a0b74234f111b5691a1e5588671cb':
Fix bionic linker to support segments with zero p_filesz
82dcc7910d9c25c4fdf635d6132fa86ae3677363 22-May-2013 Brian Carlstrom <bdc@google.com> Fix bionic linker to support segments with zero p_filesz

(cherry picked from commit 96362fb9d11beef6233aa03db396f25688e70860)

Change-Id: Ib075a6dfc45d5d0746d8b278f317dd9b8d772f2a
inker_phdr.cpp
58f3dbdacd496838661affce358518e0b3a4f7f6 10-May-2013 Elliott Hughes <enh@google.com> am 98f7659d: Merge "Don\'t fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors."

* commit '98f7659d7e3a7d75c68a41299f6ee55d7d35c27b':
Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.
8147d3c284932896ab6095232b355979b9eb33d3 09-May-2013 Elliott Hughes <enh@google.com> Don't fail to run DT_INIT and DT_INIT_ARRAY constructors if a shared library has DT_PREINIT_ARRAY constructors.

The GNU dynamic linker silently ignores a DT_PREINIT_ARRAY section
in a shared library. We had ineffectual code that tried to report
an error, which I tried to fix but got wrong --- my version still
wouldn't report the error to the caller, but would prevent us from
continuing to call constructors.

Bug: 8825226
Change-Id: I4fd8450ecc44d8767a1cb808aeecfbfbfc77c070
inker.cpp
ed572aaa0d275eed753afd4b92e05991310e76ac 26-Apr-2013 Nick Kralevich <nnk@google.com> am 5f28fde8: Merge "linker: only re-open std* for setuid programs."

* commit '5f28fde8aeee047a70e344c9da937695dc51a3ba':
linker: only re-open std* for setuid programs.
8d3e91d4f842911366155845afb3cfbdad0b4cad 25-Apr-2013 Nick Kralevich <nnk@google.com> linker: only re-open std* for setuid programs.

get_AT_SECURE() was getting called before linker_env_init() had
been called, and returning the default value ("true"). This was
causing us to reopen closed stdin, stdout, and stderr for ALL
processes, not just privileged (setuid) processes.

Calling path:
- __linker_init
- soinfo_link_image
- get_AT_SECURE
- __linker_init_post_relocation
- linker_env_init

This change restores the intended behavior of only re-opening
stdin, stdout, and stderr for privileged processes.

Change-Id: I8b085ea6597710ac4c1a3c93f1bf8b81eecb08c0
inker.cpp
9c7b510a408740b5b53f8d14b8f43bf2f2d36ae6 05-Apr-2013 Elliott Hughes <enh@google.com> am 240fb862: Merge "Make abort messages available to debuggerd."

* commit '240fb8623b1fe027d0d33a9d4c41d99ceb385b58':
Make abort messages available to debuggerd.
0d787c1fa18c6a1f29ef9840e28a68cf077be1de 04-Apr-2013 Elliott Hughes <enh@google.com> Make abort messages available to debuggerd.

This adds __libc_fatal, cleans up the internal logging code a bit more,
and switches suitable callers over to __libc_fatal. In addition to logging,
__libc_fatal stashes the message somewhere that the debuggerd signal handler
can find it before calling abort.

In the debuggerd signal handler, we pass this address to debuggerd so that
it can come back with ptrace to read the message and present it to the user.

Bug: 8531731
Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
ebugger.cpp
inker.cpp
inker.h
3077d88347f4b120ee93e73efdbfb017e0e968ec 22-Mar-2013 Elliott Hughes <enh@google.com> am c48968d2: am 4453c51c: Merge "Drop unnecessary execution permission for .cpp/.c/.h"

* commit 'c48968d268820ee64986f738e227910b29290eab':
Drop unnecessary execution permission for .cpp/.c/.h
8f7120bbacb0bb7a8aca1102f76f64a462f40231 22-Mar-2013 Kito Cheng <kito@0xlab.org> Drop unnecessary execution permission for .cpp/.c/.h

Change-Id: I9ac2b9d8f6bdb4fab8962210c5ec8f9c3e8c0ebf
rch/x86/begin.c
inker.cpp
12ea8005665085ae82c1b233ae93d12855e04b8b 16-Mar-2013 Elliott Hughes <enh@google.com> am 5f829205: am c1416647: Merge "Clean up internal libc logging."

* commit '5f8292050fc07f4bf9e70f37a807ad028e3cfc87':
Clean up internal libc logging.
8f2a5a0b40fc82126c691d5c30131d908772aab7 15-Mar-2013 Elliott Hughes <enh@google.com> Clean up internal libc logging.

We only need one logging API, and I prefer the one that does no
allocation and is thus safe to use in any context.

Also use O_CLOEXEC when opening the /dev/log files.

Move everything logging-related into one header file.

Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
ebugger.cpp
inker.cpp
inker.h
inker_debug.h
746f128602772997b57e24fc8546473d01d6f955 12-Mar-2013 Elliott Hughes <enh@google.com> am 5d998b4a: am f21aa3b6: Merge "Use more types than just \'unsigned\' in the linker."

* commit '5d998b4a21aab09da750e8e43cb608f5ee6b1f3d':
Use more types than just 'unsigned' in the linker.
ca0c11bd823f37f03cc8067cb182876827d5275a 12-Mar-2013 Elliott Hughes <enh@google.com> Use more types than just 'unsigned' in the linker.

Still chipping away at the situation where every variable in the
linker was of type 'unsigned'. This patch switches counts over to
being size_t and adds an explicit type for init/fini function pointers
and arrays of function pointers.

Also improve logging from CallArray.

Also remove trailing "\n"s from log messages.

Change-Id: Ie036d2622caac50f4d29f0570888bb527661d77e
lfcn.cpp
inker.cpp
inker.h
inker_debug.h
e9cdce33f398e43952d11ef38027e2d255f16531 12-Mar-2013 Elliott Hughes <enh@google.com> am 3c9afb5e: am 6b4c77f8: Merge "Use Elf32_Addr instead of unsigned in linker"

* commit '3c9afb5e17eaa2ed5a12d71a1a09fe85f06fcb48':
Use Elf32_Addr instead of unsigned in linker
fa8c05dc00bb41ae8fe5cb5e4f82816e30f7f7b2 12-Mar-2013 Kito Cheng <kito@0xlab.org> Use Elf32_Addr instead of unsigned in linker

Change-Id: I52dcbb4b0ff0a4052e0ad7a9bbeb2df65c9d2f66
inker.cpp
inker.h
8a0157227242eeb7917f064e0d81014bcda6d8f7 07-Mar-2013 Elliott Hughes <enh@google.com> resolved conflicts for merge of 4706606c to jb-mr2-dev

Change-Id: Ibf6340df901c870cd05a2ab56536ad23b6fd491c
0493a6f7be42e22d68e1d6ddb8eb2edaf818756f 07-Mar-2013 Elliott Hughes <enh@google.com> Regenerate NOTICE files.

Also clean up some obsolete cruft.

Change-Id: Iec3b36f6607f7a08b72de99294ed5b6cd910dd5f
EADME.TXT
inker_debug.h
c7b9f954a5278115333516a40c0d2839648a6877 07-Mar-2013 Brian Carlstrom <bdc@google.com> am 91392116: am 33031fed: Merge "Fix typo of DT_NEEDED for DT_NULL"

* commit '91392116ff859b2e7656ded729b8c758107241aa':
Fix typo of DT_NEEDED for DT_NULL
2d4b9b7cff78b9a378d7fc0f28c702dc43002020 07-Mar-2013 Brian Carlstrom <bdc@google.com> Fix typo of DT_NEEDED for DT_NULL

(cherry-pick of 138b205ea9efc117fe522c2d7191378023a6e2cd)

Change-Id: Ia895cb3018df55554627f1f61dcdfdada4a961ce
inker.cpp
bac72abae4578bf2df9227a9c3d2c7233c83a06b 06-Mar-2013 Elliott Hughes <enh@google.com> am 50a2cd86: am 0b4a85bf: Merge "Fix TIMING/STATS/COUNT_PAGES dynamic linker build"

* commit '50a2cd865e7cc8c72d926548ed5d64e269003055':
Fix TIMING/STATS/COUNT_PAGES dynamic linker build
5e2492eb89b778ee71e37e7406fe290d986ece70 06-Mar-2013 Kito Cheng <kito@0xlab.org> Fix TIMING/STATS/COUNT_PAGES dynamic linker build

Change-Id: I6432ac378816da253b83d1c7fb1d3fb64647b89e
inker.cpp
2527a8b5a652d7f88b662fe3788e29b6bc2bbe78 06-Mar-2013 Brian Carlstrom <bdc@google.com> am 9043202b: am 20958207: Merge "Fix MIPS linker build"

* commit '9043202b5bb8e0725b0302e9da9d3a57c837e798':
Fix MIPS linker build
43cc7f795b48e9c13a54e15af829369805f11652 06-Mar-2013 Brian Carlstrom <bdc@google.com> Fix MIPS linker build

(cherry-picked from 8c7d8c2057e303985f78eab96da747ddaa013c78)

Change-Id: Idcf62ab95f8fccbc2d7c3e771a4cfbe768a1555e
inker.cpp
c1a5d20d08118bb778f99b14ca74d6654e4f4eba 06-Mar-2013 Elliott Hughes <enh@google.com> am 9a0b658c: am c41dcad0: Merge "More linker cleanup."

* commit '9a0b658c9c1f8f4492f61a75909e5ca2f05c3ac1':
More linker cleanup.
650be4e584eeab3591b9e273bfd6d169eea60853 06-Mar-2013 Elliott Hughes <enh@google.com> More linker cleanup.

Change-Id: I9fb3c7c0d4b4ffef0eeaf092d4e30ffe63a08671
lfcn.cpp
inker.cpp
inker.h
inker_debug.h
inker_phdr.cpp
inker_phdr.h
8c65a1e466dae62217700065256921ba86290faa 06-Mar-2013 Brian Carlstrom <bdc@google.com> am a2517de3: am 036f9097: Merge "Minor linker cleanup, primarily to use Elf32_Dyn"

* commit 'a2517de3844d95b5f00a4666b8dae00ef893ac24':
Minor linker cleanup, primarily to use Elf32_Dyn
d4ee82dfa3ba01baa10e3ca48fcb31a27b8a4e81 01-Mar-2013 Brian Carlstrom <bdc@google.com> Minor linker cleanup, primarily to use Elf32_Dyn

Change-Id: Ifa9408e9859c6f79444715bed4808b7c13fdced5
ebugger.cpp
lfcn.cpp
inker.cpp
inker.h
inker_phdr.cpp
inker_phdr.h
6f55284103c146369a37bbabd3d36991e8372114 19-Feb-2013 Elliott Hughes <enh@google.com> am b5862d4d: Merge "Update linker README."

* commit 'b5862d4d8a1246dc1e21695cf3bacafefedf0428':
Update linker README.
aa772a33ba31151c2d74c61600db9da42bc663e4 19-Feb-2013 Elliott Hughes <enh@google.com> Update linker README.

Change-Id: Icaa353e9cf1848c86e7445f4ad590bdab44f7941
EADME.TXT
2db16ea38ebed0bddca091072ffe48c464b85970 13-Feb-2013 Elliott Hughes <enh@google.com> am 3002d64b: Merge "Everyone has a TLS register."

# Via Elliott Hughes (1) and Gerrit Code Review (1)
* commit '3002d64bcd4644456803dd0547d20b39e14be02c':
Everyone has a TLS register.
91a9925998f2b878f0245ce03aab22cc412a4d8b 13-Feb-2013 Elliott Hughes <enh@google.com> Everyone has a TLS register.

Change-Id: Id7cdf67087aa7d5074c9c59b7e595bc391d9f146
ndroid.mk
63358ae068859e339a93d3f52687e49e97f831d0 08-Feb-2013 Elliott Hughes <enh@google.com> am 8f509e8b: am 9a9bb243: Merge "Switch to using AT_RANDOM for the stack guards."

# Via Android Git Automerger (1) and others
* commit '8f509e8be11876023d4bcb3e827ca096f22fc0c5':
Switch to using AT_RANDOM for the stack guards.
d3920b3a996b358e48232f417aa0a1e44a60f155 08-Feb-2013 Elliott Hughes <enh@google.com> Switch to using AT_RANDOM for the stack guards.

Bug: 7959813
Change-Id: I8db4b8912ba649bfe668c6f22aa44690ddd401a2
inker.cpp
8c372fc77e69f141ebeca0ab621ca634bff3115c 07-Feb-2013 Elliott Hughes <enh@google.com> am 5bb67760: am f6afd3b6: Merge "Fix x86 build, remove void* arithmetic."

# Via Android Git Automerger (1) and others
* commit '5bb67760f0baddd815334bf87be79f0e7fd9fafe':
Fix x86 build, remove void* arithmetic.
389ebfa16fcf6b458955b2dd29c94d3570583f6a 07-Feb-2013 Elliott Hughes <enh@google.com> am 6f67cd22: am 2f41531f: Merge "Clean up the argc/argv/envp/auxv handling."

# Via Android Git Automerger (1) and others
* commit '6f67cd224e6ffdfa2619849eb4b9b2ff6c1e2c59':
Clean up the argc/argv/envp/auxv handling.
646e058136d59671d5d32d93bedbb71004a9ce73 07-Feb-2013 Elliott Hughes <enh@google.com> Fix x86 build, remove void* arithmetic.

Change-Id: Idc7f14af2e094ac33de315e808176237af063bb8
rch/x86/begin.c
42b2c6a5eed5e4ef35315b8cd32d1355f12a69b6 07-Feb-2013 Elliott Hughes <enh@google.com> 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
rch/x86/begin.c
inker.cpp
inker_environ.cpp
inker_environ.h
1c3039301b2642824517871b11dc8b88f63824c5 06-Feb-2013 Elliott Hughes <enh@google.com> am 0e51a861: am 4fc2a74b: Merge "Remove partial implementation of MIPS non-PIC support."

# Via Android Git Automerger (1) and others
* commit '0e51a861241ea49455c519890b34e80eccfd4709':
Remove partial implementation of MIPS non-PIC support.
d2b1a7311f023a1c532b5b418fc4bc7bd835be34 06-Feb-2013 Elliott Hughes <enh@google.com> Remove partial implementation of MIPS non-PIC support.

Change-Id: I3c287e52aae10559508174e73113367aea40e5c2
inker.cpp
inker.h
a1b8c145cb23946a4dee221e6da085401ae60a4f 30-Jan-2013 Elliott Hughes <enh@google.com> am a7f44b5a: am 172e038f: am f09f6db5: Merge "Use the NetBSD <sys/exec_elf.h>."

# Via Android Git Automerger (2) and others
* commit 'a7f44b5afe64199eeee715e613c7d42d2724232c':
Use the NetBSD <sys/exec_elf.h>.
a6a3ac59243d8c95c94c3069e9332051f785c05f 30-Jan-2013 Elliott Hughes <enh@google.com> 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
inker.h
bdd209561ee8c2245329720fd317732eb77e7c1b 23-Jan-2013 Elliott Hughes <enh@google.com> am 1029364e: am e8e1f34a: am 85597e2b: Merge "Clean up debuggerd-related logging."

* commit '1029364ec5710755164ec9a7f0fe625cc184bb60':
Clean up debuggerd-related logging.
6b8e321e610c0683062c0e8d8deabb64565c7403 22-Jan-2013 Elliott Hughes <enh@google.com> Clean up debuggerd-related logging.

Bug: 7291287
Change-Id: Ia7aa386e8b75b8058d7d9e707e11b1da7dc62f00
ebugger.cpp
16f7b78fd1059efcd3458441d8c3357cc265d62c 22-Jan-2013 Elliott Hughes <enh@google.com> am 4cd5703b: am 75b64a1b: am ca483765: Merge "Fix the duplication in the debugging code."

* commit '4cd5703b9eef30a32271819503808576666e1601':
Fix the duplication in the debugging code.
ca483765bd0dc16294b9e67dd0de5c6d53b1bfa3 22-Jan-2013 Elliott Hughes <enh@google.com> Merge "Fix the duplication in the debugging code."
1e980b6bc8315d00a07312b25486531247abd98c 18-Jan-2013 Elliott Hughes <enh@google.com> 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
ndroid.mk
ebugger.cpp
inker.cpp
inker_debug.h
inker_format.cpp
inker_format.h
4df577fef74063507cba229bce352bbcf89df279 18-Jan-2013 Guang Zhu <guangzhu@google.com> Revert "Filter ANDROID_PROPERTY_WORKSPACE"

Temporarily revert the change since DNS resolution seems
broken right now in ping util.

Bug: 8029617

This reverts commit a0f64756a4a55ab48b2b5511d4e7c45583dac44b.
inker_environ.cpp
bf1d22559376aa5c3fff5c278a90fd0832ec6207 18-Jan-2013 Guang Zhu <guangzhu@google.com> Revert "Filter ANDROID_PROPERTY_WORKSPACE"

Temporarily revert the change since DNS resolution seems
broken right now in ping util.

Bug: 8029617

This reverts commit a0f64756a4a55ab48b2b5511d4e7c45583dac44b.
inker_environ.cpp
dbcf3ed458d2eca5795a1e2530e450a856020ffc 17-Jan-2013 Nick Kralevich <nnk@google.com> 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
d89ce40d8e6b4a6a8074a6fddca9570abbfa4b9d 17-Jan-2013 Nick Kralevich <nnk@google.com> 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
ndroid.mk
927d904d526e854881fe886fe1314ba42dc46ae2 16-Jan-2013 Nick Kralevich <nnk@google.com> am 91bc5865: am 8d01c055: am 1271cdc1: Merge "Revert "stack protector: use AT_RANDOM""

* commit '91bc5865a333212e7cac934b0a2ac7c522911d58':
Revert "stack protector: use AT_RANDOM"
bcd18c04858601c02121fbdc0d19e78a45e65bd4 16-Jan-2013 Nick Kralevich <nnk@google.com> am 27ff1ae4: am de666485: am ba117e41: Merge "stack protector: use AT_RANDOM"

* commit '27ff1ae414915789b27d0a485ff6d856ae742aad':
stack protector: use AT_RANDOM
dde6b88a9f10f9c16541bda60651bc3e289310c5 16-Jan-2013 Nick Kralevich <nnk@google.com> am 079e4356: am 30894bdf: am 1b34228b: Merge "Filter ANDROID_PROPERTY_WORKSPACE"

* commit '079e4356550030e8bacec86b8aa058ade2b7142c':
Filter ANDROID_PROPERTY_WORKSPACE
36bd371e26c716cbc18e11801b13eff0352d91b0 16-Jan-2013 Nick Kralevich <nnk@google.com> 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 e3a49a8661125f24aec8a1453e54b3b78005e21e.

Change-Id: I05c58a896b1fe32cfb5d95d43b096045cda0aa4a
inker.cpp
ba117e4172fe6f160bf5f4d58b37e12c08c34245 16-Jan-2013 Nick Kralevich <nnk@google.com> Merge "stack protector: use AT_RANDOM"
e3a49a8661125f24aec8a1453e54b3b78005e21e 14-Jan-2013 Nick Kralevich <nnk@google.com> 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
inker.cpp
a0f64756a4a55ab48b2b5511d4e7c45583dac44b 16-Jan-2013 Nick Kralevich <nnk@google.com> 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
inker_environ.cpp
32cefdbc7afad198bc7fdfd4aa351d72dfad91fc 14-Jan-2013 Elliott Hughes <enh@google.com> am 375db86a: am 09d13c39: Merge "Fix my git mistake."

* commit '375db86aeaedfe716b69a62f81a2484ee446d5e5':
Fix my git mistake.
99c32055cb50443f722c55914869c1f6bb941959 14-Jan-2013 Elliott Hughes <enh@google.com> Fix my git mistake.

This was the formatting change that was supposed to be in
cf23905a4bcc7bfdd109be5b6d69ad06877aa217.

Change-Id: Ib79fa031b68f6f541f532507eb589afeaedb831f
inker.cpp
14ab1a63d6a53fd16206b1bf4ffc014082e484da 14-Jan-2013 Elliott Hughes <enh@google.com> am bc3c7183: am 48c632a3: Merge "[MIPS] Set DT_DEBUG dyntab entry if it is writable"

* commit 'bc3c718346d81c04451c35c2d8fb00c68b0a815d':
[MIPS] Set DT_DEBUG dyntab entry if it is writable
cf23905a4bcc7bfdd109be5b6d69ad06877aa217 12-Jan-2013 Chris Dearman <chris@mips.com> [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>
inker.cpp
inker_phdr.cpp
inker_phdr.h
8dd63f31ba9ae28ab27316d46421310357064bea 04-Jan-2013 Elliott Hughes <enh@google.com> am 81508de3: am f0036944: Merge "Fix debug malloc."

* commit '81508de3d277db2ef3c8aa55b57ce3ce0a142e48':
Fix debug malloc.
db492b3ca753c4ef688d0daf648294de0c89145e 04-Jan-2013 Elliott Hughes <enh@google.com> Fix debug malloc.

...which has been broken since the linker data structures went read-only.

Bug: 7941716
Change-Id: If28f6bac0fcb13e371e4d85b064544f561c8d692
inker.cpp
36a9f354c0931bd7ae94ff8f52030703499c99f5 28-Dec-2012 Elliott Hughes <enh@google.com> am c0c05ff8: am 918d776f: Merge "Support System.loadLibrary for libraries with transitive dependencies."

* commit 'c0c05ff8ecfe5f27aedcd6315e191245aa7b4824':
Support System.loadLibrary for libraries with transitive dependencies.
0ce87c89845880096bc539a3b1a1c010041626b8 28-Dec-2012 Elliott Hughes <enh@google.com> am df5c77c9: am f6524f8b: Merge "Fix format_number."

* commit 'df5c77c91a276a79d05f58241df3695b56422d54':
Fix format_number.
918d776f7edf1a9c4209ada4c2401ef0ea0bf660 22-Dec-2012 Elliott Hughes <enh@google.com> Merge "Support System.loadLibrary for libraries with transitive dependencies."
eababde2141c7128155200b213e45291cd876e46 21-Dec-2012 Elliott Hughes <enh@google.com> Fix format_number.

I broke this the other day when silencing x86 gcc warnings.

Bug: 7904160
Change-Id: I8e60cc1f8cbaff95248c8738d84e515413d839e4
inker_format.cpp
cade4c36e7c9c62db3f476a0f9cfc329bac9acb7 20-Dec-2012 Elliott Hughes <enh@google.com> 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
lfcn.cpp
inker.cpp
inker.h
d020802e3771390c2ff49631e55a0f66c7288b5c 19-Dec-2012 Elliott Hughes <enh@google.com> am 5fd31f68: am 4b582142: Merge "Fix x86 dynamic linker build."

* commit '5fd31f6891a6e0b5db84c4c7992d0a4b08f3dddd':
Fix x86 dynamic linker build.
05ab167cf74731b5cad25562712b79df82a970d5 19-Dec-2012 Elliott Hughes <enh@google.com> am a0edecf3: am a4ebdcf5: Merge "Check for unknown flags passed to dlopen(3)."

* commit 'a0edecf3438d036ee2353076d171ee68939c2a5e':
Check for unknown flags passed to dlopen(3).
45288c5ce3d2a40f1426fbeb099e3a90cd10dc20 19-Dec-2012 Elliott Hughes <enh@google.com> Fix x86 dynamic linker build.

Change-Id: Ia9fc6342e3d409de86dcd187c7402e8ac2ae96c8
rch/x86/begin.c
inker_format.cpp
e66190d2a97a713ae4b4786e60ca3d67ab8aa192 19-Dec-2012 Elliott Hughes <enh@google.com> Check for unknown flags passed to dlopen(3).

Change-Id: I56f4aab0e5a1487bc32d2c4d231e8bd15c4ac8da
ndroid.mk
lfcn.cpp
inker.cpp
inker.h
2e51dc444fe48775044dd33aec5d78a2e5b0adda 30-Nov-2012 Elliott Hughes <enh@google.com> 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
97b70b2bda47af46adf58dfde61050357114aa1f 30-Nov-2012 Elliott Hughes <enh@google.com> Merge "Replace .S version of x86 crtfiles with .c version"
20c4a3a8eee5ca8c87ae377732f541baffce1fda 28-Nov-2012 Pavel Chupin <pavel.v.chupin@intel.com> 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>
ndroid.mk
rch/x86/begin.S
rch/x86/begin.c
4867b00666446067bd6c434003b1748677c0fcfd 27-Nov-2012 Elliott Hughes <enh@google.com> am f2de6b0f: Merge "Do not include \'\0\' when writing error messages to stderr"

* commit 'f2de6b0f6e873f9cb28682b8fc6764b0ab41c6ee':
Do not include '\0' when writing error messages to stderr
20a24403bc333cd92996cd43cef2e6a79c72d055 31-Oct-2012 Chris Dearman <chris@mips.com> Do not include '\0' when writing error messages to stderr

Change-Id: I6adc806c3920e5a4ae61ca55c40613fcf338b18c
Signed-off-by: Chris Dearman <chris@mips.com>
inker.cpp
c16ea161343bcf0e8ac8d651d08ff5972b3e47ad 19-Nov-2012 Nick Kralevich <nnk@google.com> am 8784709a: Merge "We should use load_bias. This patch fixes MIPS NDK device exception test failures."

* commit '8784709a2cfe6d32b5fff2c6b826b8d9cbf73d7b':
We should use load_bias. This patch fixes MIPS NDK device exception test failures.
8784709a2cfe6d32b5fff2c6b826b8d9cbf73d7b 19-Nov-2012 Nick Kralevich <nnk@google.com> Merge "We should use load_bias. This patch fixes MIPS NDK device exception test failures."
c5db969aa4a24a76fc0964f2ff89533e832b47a6 15-Nov-2012 Chao-Ying Fu <fu@mips.com> We should use load_bias. This patch fixes MIPS NDK device exception test failures.

Change-Id: I4b718c36666e66062c1f13e4deea1ec7a7951c54
inker.cpp
aec9a254a2f4803e078c6a565797d261cd027e0e 16-Nov-2012 Nick Kralevich <nnk@google.com> am 170168cd: Merge "Temporarily address gcc 4.7 breakage."

* commit '170168cdf37111b45b15817fab9e3df54cbc27b7':
Temporarily address gcc 4.7 breakage.
83697b8b76501cc09b3f1963485184bc7cae06ee 16-Nov-2012 Nick Kralevich <nnk@google.com> Temporarily address gcc 4.7 breakage.

Change-Id: I8ebb2d5df2f8f8aedf252c94ff69505e61ed0a74
inker_format.cpp
da71c7d9a37594a83ab102077dd17f13273ae365 05-Nov-2012 Elliott Hughes <enh@google.com> am ce876beb: am a41e6426: Merge "Tone down some of the overly-verbose linker logging."

* commit 'ce876bebf250d386a06ebc1145c6959e30bf413c':
Tone down some of the overly-verbose linker logging.
ce876bebf250d386a06ebc1145c6959e30bf413c 05-Nov-2012 Elliott Hughes <enh@google.com> am a41e6426: Merge "Tone down some of the overly-verbose linker logging."

* commit 'a41e6426073c57881f49bdaec46ca90a5b164401':
Tone down some of the overly-verbose linker logging.
9c94fc9fbefe55836c1e1b949850f7726e64c118 05-Nov-2012 Elliott Hughes <enh@google.com> 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
inker.cpp
inker_debug.h
f1566fd6923aacb00569e60b32ea66f3f6f6accc 02-Nov-2012 Elliott Hughes <enh@google.com> am bc35807f: am 9df2e000: Merge "Cleaning the linker environment as we initialize it requires less API."

* commit 'bc35807fc6c5f11b6d057b20250d41ebc419da62':
Cleaning the linker environment as we initialize it requires less API.
d752fc02860956ea76bfff12e2f1a8a02cab29b1 02-Nov-2012 Elliott Hughes <enh@google.com> am cfb47daf: am 01271b18: Merge "Make dynamic linker debugging always available."

* commit 'cfb47daf4eb4741ac462c7350c73ad1cf96cf83f':
Make dynamic linker debugging always available.
bc35807fc6c5f11b6d057b20250d41ebc419da62 02-Nov-2012 Elliott Hughes <enh@google.com> 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.
cfb47daf4eb4741ac462c7350c73ad1cf96cf83f 02-Nov-2012 Elliott Hughes <enh@google.com> am 01271b18: Merge "Make dynamic linker debugging always available."

* commit '01271b1812f2cec8aaf3c105b9f960f027b33a95':
Make dynamic linker debugging always available.
9df2e000b5d56b2e529656034d684e370aa6a8d1 02-Nov-2012 Elliott Hughes <enh@google.com> Merge "Cleaning the linker environment as we initialize it requires less API."
61a9ccb41eba8c35cae6e21318aca7160a402c5b 02-Nov-2012 Elliott Hughes <enh@google.com> 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
ndroid.mk
EADME.TXT
ebugger.cpp
inker.cpp
inker_debug.h
inker_format.cpp
inker_format.h
0894b2c5d35c9c3a7483ed8faaf65fd6d9ffb00b 02-Nov-2012 Elliott Hughes <enh@google.com> Cleaning the linker environment as we initialize it requires less API.

Change-Id: I612fd699e46833a411589478564a1f859223c380
inker_environ.cpp
inker_environ.h
1d0129b1b28c99b328c1a1ef023c46364c829e29 02-Nov-2012 Elliott Hughes <enh@google.com> am cdc5a17c: am ed537239: Merge "Adjust symbol lookup for DT_SYMBOLIC case"

* commit 'cdc5a17cef00c49086e1bfe4c3715d2ebd61addb':
Adjust symbol lookup for DT_SYMBOLIC case
cdc5a17cef00c49086e1bfe4c3715d2ebd61addb 02-Nov-2012 Elliott Hughes <enh@google.com> am ed537239: Merge "Adjust symbol lookup for DT_SYMBOLIC case"

* commit 'ed537239a94ebd11a8c262a319d81fd1f0d3f73f':
Adjust symbol lookup for DT_SYMBOLIC case
ed537239a94ebd11a8c262a319d81fd1f0d3f73f 02-Nov-2012 Elliott Hughes <enh@google.com> Merge "Adjust symbol lookup for DT_SYMBOLIC case"
c77c434149959e135ba21d1dd8a78a408fef2489 31-Oct-2012 Pavel Chupin <pavel.v.chupin@intel.com> 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>
inker.cpp
eb15e1d4852e6c4aa42bc285323f4804f9630d4d 02-Nov-2012 Elliott Hughes <enh@google.com> am e109930e: am dc77a228: Merge "Allow dlopen("egl/blah.so")."

* commit 'e109930e9fd0922280e6f74b3df270093ee95fa6':
Allow dlopen("egl/blah.so").
e109930e9fd0922280e6f74b3df270093ee95fa6 02-Nov-2012 Elliott Hughes <enh@google.com> am dc77a228: Merge "Allow dlopen("egl/blah.so")."

* commit 'dc77a22850e31eb369ec9776c13c967566bf61d0':
Allow dlopen("egl/blah.so").
6971fe4ca52ebdaa85ba676a044412b01d2ef1bf 02-Nov-2012 Elliott Hughes <enh@google.com> 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
inker.cpp
d781dfdb094a9e213e33e87c61245d36070853b9 02-Nov-2012 Elliott Hughes <enh@google.com> am 6db8f5bb: am d30116cf: Merge "Keep the dynamic linker\'s soinfo pools mostly read-only."

* commit '6db8f5bb75bb79e0b4873e6d293aa25e2c9f090b':
Keep the dynamic linker's soinfo pools mostly read-only.
6db8f5bb75bb79e0b4873e6d293aa25e2c9f090b 02-Nov-2012 Elliott Hughes <enh@google.com> 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.
d23736e4f228e46304b7cbc674a1d0094d73e0f5 01-Nov-2012 Elliott Hughes <enh@google.com> 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
ebugger.cpp
lfcn.cpp
inker.cpp
inker.h
02c3513e5ffae07794ec7c2389e66de7dfede00e 01-Nov-2012 Elliott Hughes <enh@google.com> am 65ba5b62: am 064f862d: Merge "Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too."

* commit '65ba5b62c5a59181317b86f772d9ebb756d4741f':
Stop defining our own PAGE_SIZE and PAGE_MASK, and test dlclose(3) too.
65ba5b62c5a59181317b86f772d9ebb756d4741f 01-Nov-2012 Elliott Hughes <enh@google.com> 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.
1a6961650c82168864afe040dbdc05977db701df 01-Nov-2012 Elliott Hughes <enh@google.com> 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
inker.cpp
inker.h
00fe4a20d7ec59883cdded9d48768edfda13671b 01-Nov-2012 Elliott Hughes <enh@google.com> am 3bb62578: am 0be1819b: Merge "Dynamically allocate soinfo-structs in linker"

* commit '3bb62578beb36a35d3b1d2fbe18bd34a9d4ecca4':
Dynamically allocate soinfo-structs in linker
3bb62578beb36a35d3b1d2fbe18bd34a9d4ecca4 01-Nov-2012 Elliott Hughes <enh@google.com> am 0be1819b: Merge "Dynamically allocate soinfo-structs in linker"

* commit '0be1819b22b33fbedcb150f96a196ed096abe2fc':
Dynamically allocate soinfo-structs in linker
ba98d9237b0eabc1d8caf2600fd787b988645249 12-Sep-2012 Magnus Malmborn <magnus.malmborn@sonymobile.com> 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
inker.cpp
inker.h
e892414bd3c0133fc5106d97f328ae5f13c2a0f9 31-Oct-2012 Elliott Hughes <enh@google.com> am 1de3af51: am c0ac7eba: Merge "Reject .so files with no sysv hash table."

* commit '1de3af51d459c2ced602f10e4f7e7fe704400cdc':
Reject .so files with no sysv hash table.
1de3af51d459c2ced602f10e4f7e7fe704400cdc 31-Oct-2012 Elliott Hughes <enh@google.com> am c0ac7eba: Merge "Reject .so files with no sysv hash table."

* commit 'c0ac7eba934fb88f321c75a71312ea482e9a85e9':
Reject .so files with no sysv hash table.
124fae9eabd7a25d80dfa8c3b56bed0f0fba16f1 31-Oct-2012 Elliott Hughes <enh@google.com> 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
inker.cpp
8478dbc85fab5db5595910a5a0615ec74778ce68 31-Oct-2012 Elliott Hughes <enh@google.com> am 3cd7a165: am 084be591: Merge "linker: handle R_ARM_COPY relocations in a proper way"

* commit '3cd7a1653aa579213cb68a666bd9949e2b8fff95':
linker: handle R_ARM_COPY relocations in a proper way
3cd7a1653aa579213cb68a666bd9949e2b8fff95 31-Oct-2012 Elliott Hughes <enh@google.com> 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
5ae44f302b7d1d19f25c4c6f125e32dc369961d9 30-Aug-2012 Ard Biesheuvel <ard.biesheuvel@gmail.com> 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>
lfcn.cpp
inker.cpp
inker.h
864d48917a2421cb2846138f6c49e499a83614d4 31-Oct-2012 Elliott Hughes <enh@google.com> am 914112ea: am 155e8d1d: Merge "More dynamic linker cleanup."

* commit '914112ea21a62c7658dc4b094a369358009be6a9':
More dynamic linker cleanup.
914112ea21a62c7658dc4b094a369358009be6a9 31-Oct-2012 Elliott Hughes <enh@google.com> am 155e8d1d: Merge "More dynamic linker cleanup."

* commit '155e8d1df5b8fdfeabda3e7b61d95beb5b8d1467':
More dynamic linker cleanup.
18a206c81d9743481e364384affd43306911283d 30-Oct-2012 Elliott Hughes <enh@google.com> 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
ndroid.mk
ebugger.c
ebugger.cpp
inker.cpp
inker.h
inker_debug.h
inker_environ.c
inker_environ.cpp
inker_environ.h
inker_format.c
inker_format.cpp
inker_format.h
inker_phdr.c
inker_phdr.cpp
inker_phdr.h
t.c
t.cpp
4e0b489a0c17a415eb48ac0b6a28e500fce596cb 26-Oct-2012 Elliott Hughes <enh@google.com> am 8cacc639: am 7193731a: Merge "Workaround g++ 4.7 compfail"

* commit '8cacc639b6ae660c494aca07c537cb443c6c6cd9':
Workaround g++ 4.7 compfail
8cacc639b6ae660c494aca07c537cb443c6c6cd9 26-Oct-2012 Elliott Hughes <enh@google.com> am 7193731a: Merge "Workaround g++ 4.7 compfail"

* commit '7193731ae6b8083bc7a5e5e468fb98b1dbcf3f3d':
Workaround g++ 4.7 compfail
20aa6c0f4cbe6fdaba8938536a7b80270cfe7203 24-Oct-2012 Pavel Chupin <pavel.v.chupin@intel.com> Workaround g++ 4.7 compfail

error: C99 designator 'name' outside aggregate initializer

G++ 4.7+ can't handle some of C99 designated initializers.
Most likely it's just not implemented yet. Other possible workarounds is
to compile this as C not C++ or define name as char* instead of char[SIZE].

Appeared after this change https://android-review.googlesource.com/#/c/44470

Change-Id: Ib28157848ce759b8bb5dbb2ac0d9a768fa4e5107
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
lfcn.cpp
9eaa9536428504a6ac26e4c4fb4324495383d0bb 17-Oct-2012 Elliott Hughes <enh@google.com> am 06abe13c: am a2f596b6: Merge "Make dlerror(3) thread-safe."

* commit '06abe13c5f7a318eef316268d0d25d92ff128c19':
Make dlerror(3) thread-safe.
06abe13c5f7a318eef316268d0d25d92ff128c19 17-Oct-2012 Elliott Hughes <enh@google.com> am a2f596b6: Merge "Make dlerror(3) thread-safe."

* commit 'a2f596b65075db7916ffffa2f5059e7953719578':
Make dlerror(3) thread-safe.
5419b9474753d25dff947c7740532f86d130c0be 17-Oct-2012 Elliott Hughes <enh@google.com> Make dlerror(3) thread-safe.

I gave up trying to use the usual thread-local buffer idiom; calls to
calloc(3) and free(3) from any of the "dl" functions -- which live in
the dynamic linker -- end up resolving to the dynamic linker's stubs.
I tried to work around that, but was just making things more complicated.
This alternative costs us a well-known TLS slot (instead of the
dynamically-allocated TLS slot we'd have used otherwise, so no difference
there), plus an extra buffer inside every pthread_internal_t.

Bug: 5404023
Change-Id: Ie9614edd05b6d1eeaf7bf9172792d616c6361767
lfcn.cpp
inker.cpp
4089dea45128174dac400a25533dcc65b02d1562 12-Oct-2012 Elliott Hughes <enh@google.com> am c2483ea9: am 9434e8fe: Merge "Make the dlfcn mutex static."

* commit 'c2483ea9b63de373e7521e39162395a8c667239a':
Make the dlfcn mutex static.
c2483ea9b63de373e7521e39162395a8c667239a 12-Oct-2012 Elliott Hughes <enh@google.com> am 9434e8fe: Merge "Make the dlfcn mutex static."

* commit '9434e8febc8b223db2d49e7f97140771700113b9':
Make the dlfcn mutex static.
22d629211d72adaf46f3fc48f59540f8e5798b1e 12-Oct-2012 Elliott Hughes <enh@google.com> Make the dlfcn mutex static.

More style fixes too, and removal of yet another lingering SH reference!

Change-Id: Iebc34a46475dd11845ad172b9108bb6ddd7585bb
lfcn.cpp
66d71c8f13d1b4c0b537cf8f47ccdfadcb4ef67e 12-Oct-2012 Elliott Hughes <enh@google.com> am ab4e2ed1: am db4fdf1a: Merge "Fix dlerror(3)."

* commit 'ab4e2ed182011998751ff5d6c321ff5bae20c6cd':
Fix dlerror(3).
ab4e2ed182011998751ff5d6c321ff5bae20c6cd 12-Oct-2012 Elliott Hughes <enh@google.com> am db4fdf1a: Merge "Fix dlerror(3)."

* commit 'db4fdf1aafb63b09ee967066d9b8107a9812db2d':
Fix dlerror(3).
3b297c40794b23d50cb5240f9b03f6ef25fd98db 12-Oct-2012 Elliott Hughes <enh@google.com> 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
ndroid.mk
lfcn.c
lfcn.cpp
inker.cpp
a55f0a1007423837ff8dc26336a1976469439def 08-Oct-2012 Ying Wang <wangying@google.com> am b04598a6: Set up the private variables.

* commit 'b04598a63c3f0df597f6186beea3adafc665ef56':
Set up the private variables.
b04598a63c3f0df597f6186beea3adafc665ef56 26-Sep-2012 Ying Wang <wangying@google.com> 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
ndroid.mk
1db6f2db499490e125a92e2c859a6dc3bef81d72 02-Oct-2012 Andy McFadden <fadden@android.com> Test flags before using "info"

Our debugger signal catcher expects to receive three args, but if
somebody cleared SA_SIGINFO we only get one, and bad things happen
when we try to use the second one. Test to see if SA_SIGINFO is
still set before we try to use the argument.

(cherry-pick of f84bc8d6f6368f1c846124a8168761ee8cc589c0.)

Bug: 7272866
Change-Id: I69a65c25e833aea70acb78f9ba40ed93308583e6
ebugger.c
399f54c13304c79d0dd289854de91f3500a38bc8 03-Oct-2012 Andy McFadden <fadden@android.com> am 51c7167d: am 7c67e4e4: am 98957db5: Merge "Test flags before using "info"" into jb-mr1-dev

* commit '51c7167d2245286e3458ffb06b0b5068d8f04e1b':
Test flags before using "info"
51c7167d2245286e3458ffb06b0b5068d8f04e1b 03-Oct-2012 Andy McFadden <fadden@android.com> am 7c67e4e4: am 98957db5: Merge "Test flags before using "info"" into jb-mr1-dev

* commit '7c67e4e423f7608c50a1fc7c355d87593cfdbcca':
Test flags before using "info"
f84bc8d6f6368f1c846124a8168761ee8cc589c0 02-Oct-2012 Andy McFadden <fadden@android.com> Test flags before using "info"

Our debugger signal catcher expects to receive three args, but if
somebody cleared SA_SIGINFO we only get one, and bad things happen
when we try to use the second one. Test to see if SA_SIGINFO is
still set before we try to use the argument.

Bug: 7272866
Change-Id: If682a2262fe8a575f3802fb0c60a53eea3082456
ebugger.c
7f1464c03c1da0b336f10cc30356e05562200e69 01-Oct-2012 Elliott Hughes <enh@google.com> am 068f3398: am 0fa6279f: am 5b6346f6: Merge "bionic: linker: Need update the map->l_addr for execution."

* commit '068f33981ddaee7e397eee73ea5ea97827aabeb7':
bionic: linker: Need update the map->l_addr for execution.
5b6346f6d5dca4022fe0044dd2807c19ac596788 01-Oct-2012 Elliott Hughes <enh@google.com> Merge "bionic: linker: Need update the map->l_addr for execution."
1be6e685a5b95b896da5aac55224b0d1d047781d 26-Sep-2012 Ying Wang <wangying@google.com> Merge "Set up the private variables."
f680b0f4049b4864f7d5d0e1a59aec2ce8d9de74 26-Sep-2012 Ying Wang <wangying@google.com> 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
ndroid.mk
2fb6457efb8791b9c9e84ca7d9a289105c07e71b 26-Sep-2012 Elliott Hughes <enh@google.com> am c3233178: am 00f33977: am 3307bff0: Merge "Revert dl_fbase initialization to the address where the shared object is loaded."

* commit 'c32331781097b51a46c03b002cd813752677236a':
Revert dl_fbase initialization to the address where the shared object is loaded.
e6dc2a664e7c06fe02a100d6d1a5b0eba3d92935 26-Sep-2012 Raghu Gandham <raghu@mips.com> Revert dl_fbase initialization to the address where the shared object is loaded.

Change-Id: If868cab774a1ae5ff370208216cecda9b8c3b9fd
lfcn.c
0647355bef6b9053f4640329d512aa8d65726195 24-Sep-2012 Elliott Hughes <enh@google.com> am 28bd96cc: am d5c654c0: am 3b6914bf: Merge "Fix dlsym and dladdr to use load_bias instead of base"

* commit '28bd96cc0b9a5eed785df09a4c1bffc43b95fe6b':
Fix dlsym and dladdr to use load_bias instead of base
c1993cac4072e2d0c48cd9b55e3861d879ada224 21-Sep-2012 Raghu Gandham <raghu@mips.com> Fix dlsym and dladdr to use load_bias instead of base

Change-Id: If0f9aa944ccb1f90451aa6674428e34494331d2d
lfcn.c
9c3449ecd9d5e9cdb1e995e35e53334a4a288a5e 13-Sep-2012 Xiaokang Qin <xiaokang.qin@intel.com> bionic: linker: Need update the map->l_addr for execution.

Currently, linker doesn't update the map->l_addr for execution.
Which could break the Unwind_Backtrace with PT_GNU_EH_FRAME enabled
in new toolchain.

Change-Id: Ifbd853134da64a962f7e4c4105e56a3f20def1b2
Author: Fengwei Yin <fengwei.yin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 57077
inker.cpp
6709aba1268f3a3368154772f6f6f971202e9206 29-Aug-2012 Elliott Hughes <enh@google.com> am 418ecb7e: am 8c368b5d: am dde94f4c: am 8b4e8a93: Merge "Improve the dynamic linker diagnostics."

* commit '418ecb7ec800d8caa97b01a84d7403272fab4e28':
Improve the dynamic linker diagnostics.
e9b6fc6f82276188404a2839e31a2f4c19f6c336 29-Aug-2012 Elliott Hughes <enh@google.com> Improve the dynamic linker diagnostics.

Lose the pid, only show the name of the function (not its whole signature),
and include the name of the library we failed to load. (I hadn't noticed
that the library name was missing before because in Java we add that into
the UnsatisfiedLinkError detail message.)

The new output looks like this:

Cannot load library: soinfo_relocate(linker.cpp:968): cannot locate symbol "__libc_malloc_default_dispatch" referenced by "libc_malloc_debug_leak.so"...

Change-Id: I3bb5c9780d9aaf3a9e4418ea55bc98122a81f80f
inker.cpp
c64bb00cdffdce4f7d4a487470895f3e5f050aad 28-Aug-2012 Nick Kralevich <nnk@google.com> am 773a7832: am d7440f37: am 7cab2188: am ad180738: Merge "linker: Fix ARM_R_COPY relocations"

* commit '773a783295e758bdef1a7e205761bcc1f832af95':
linker: Fix ARM_R_COPY relocations
ad18073897378d3a13aaa6a7e7005f254ab8c1c8 28-Aug-2012 Nick Kralevich <nnk@google.com> Merge "linker: Fix ARM_R_COPY relocations"
d39c3abd5ad8600fb1d79a0b95a58197197087e0 24-Aug-2012 Nick Kralevich <nnk@google.com> linker: Fix ARM_R_COPY relocations

Per http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044d/IHI0044D_aaelf.pdf
Section 4.7.1.10, ARM_R_COPY relocations are only suppose to reference shared
libraries, not the executable itself. When resolving an R_ARM_COPY symbol,
ensure we don't look in our own symbol.

This partially addresses
http://code.google.com/p/android/issues/detail?id=28598 . After this
patch, the printfs generated by the test program are:

global = 0x42 (0x401c7000)
global = 0x42 (0x11000)

before, the output was:

global = 0x42 (0x40071000)
global = 0x0 (0x11000)

I'm still not very happy with this patch, but I think it's an improvement
over where we were at before.

This change was modeled after https://android-review.googlesource.com/38871

Change-Id: Id7ad921e58395e76a36875bcc742ec5eeba53f08
inker.cpp
47cac977f5aded8344360fe204dc5d9e317a33e1 28-Aug-2012 Nick Kralevich <nnk@google.com> am 5443561d: am 48c88804: am 775dabd4: am 9dfaa63a: Merge "Allow linker to compile with -DLINKER_DEBUG=1"

* commit '5443561d5d9fd8ababac989116a036b3ab7b15b0':
Allow linker to compile with -DLINKER_DEBUG=1
3697b52605230d1479b662dceb27b4ef1fab0567 24-Aug-2012 Nick Kralevich <nnk@google.com> Allow linker to compile with -DLINKER_DEBUG=1

Change-Id: I27e734048cbcb9ed936369115582b3c734de1280
inker_debug.h
1f6639a1bfacf138d3eab978ce6f875d0f9f4215 17-Aug-2012 Elliott Hughes <enh@google.com> am d060b824: am efd39834: am e5242bfd: am 1771a33d: Merge "Add link.h for all platforms with dl_phdr_info"

* commit 'd060b824dd293bf1ecd7814cd2e75a77186cefcb':
Add link.h for all platforms with dl_phdr_info
b7beb6907599b36809effe1b4db76039ac649518 16-Aug-2012 Pavel Chupin <pavel.v.chupin@intel.com> Add link.h for all platforms with dl_phdr_info

This header is used on bionic build and should be propagated into
sysroot on toolchain rebuild. Discussion re. this header is here:
http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00936.html

It is available already in mips NDK platforms:
development/ndk/platforms/android-9/arch-mips/include/link.h

Change-Id: I39ff467cdac9f448e31c11ee3e14a6200e82ab57
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
inker.h
1d16b89289b59172fc3e967697a6ba9fa4a3bc28 16-Aug-2012 Elliott Hughes <enh@google.com> am 31041a01: am 29af938c: am ab8850f7: am 07cd1125: Merge "Fix comment typos."

* commit '31041a0138d62879257d6980abd1e006c299752b':
Fix comment typos.
b8d2695c8283d9127b356aeb10eb6204a716d14e 16-Aug-2012 Elliott Hughes <enh@google.com> am cdbd3406: am 4d63f33c: am 76aad1d2: am e1cd69a7: Merge "Regenerate all NOTICE files with the latest version of the script."

* commit 'cdbd3406f51d7f21326fe99df21e48a9191dddc1':
Regenerate all NOTICE files with the latest version of the script.
105bc26fa6e5f6a946a2ff144ae316e69c6ce08e 16-Aug-2012 Elliott Hughes <enh@google.com> Fix comment typos.

Change-Id: I8feeec1ee9935a6d6baebe57f1c0043ff90ff94f
inker_phdr.c
32dbc03c73dc1f9d1fcd072086d894a9eb25aecd 16-Aug-2012 Elliott Hughes <enh@google.com> Regenerate all NOTICE files with the latest version of the script.

This sorts every entry, so we should have more stability and fewer
merge conflicts in future.

Change-Id: Ifc5347dc53352da22c82d41ca59b483966fcfc6b
OTICE
ea4900b89aaf7beb273ede4be9647199a8c73e36 15-Aug-2012 Elliott Hughes <enh@google.com> am 0a3f66e9: am fdbecf3b: am 63696738: am b6a97196: Merge "More cleanup."

* commit '0a3f66e9a0ef47dc2f751292a69434405221ef90':
More cleanup.
bedfe38b8ba512dd6236c00e8b4a9b01c2bd1281 14-Aug-2012 Elliott Hughes <enh@google.com> More cleanup.

Make more stuff static, remove some dead code, and fix a few typos.

Change-Id: I010b0eadeaf61e2899c37014ad1e7082c70bd510
lfcn.c
inker.cpp
inker.h
inker_debug.h
6bdc30e923ac41b069084665e057ca029e8d8018 14-Aug-2012 Elliott Hughes <enh@google.com> am 028ed539: am dc320d99: am 82b69fcb: am b9c6854c: Merge "linker: avoid clobbering the .dynamic section of shared libs"

* commit '028ed539ddbe577687ac9778382c98aab3bf279f':
linker: avoid clobbering the .dynamic section of shared libs
12c78bbded8ec03f821dfa09174464c04836e4ea 14-Aug-2012 Ard Biesheuvel <ard.biesheuvel@gmail.com> linker: avoid clobbering the .dynamic section of shared libs

This patch removes the DT_NEEDED hack which stores pointers
to soinfo structs in the .dynamic section of the library
being loaded.

Instead, it caches the soinfo struct pointers on the stack
during relocation time. After relocation time, i.e. when
calling constructors and destructors of the shared library
and its dependencies, uncached access is used instead,
doing lookups using the string table entries pointed to by
the DT_NEEDED entries.

By removing this hack, it is no longer needed to undo the
PT_GNURELRO protection, i.e., all non-writable mappings
can remain non-writable during their entire lifespan.

Even though, strictly speaking, the algorithmic complexity
has increased somewhat, the real-world adverse effect
is negligible on the systems I have tested.

Change-Id: I2361502560b96b5878f7f94a8e8a215350d70d64
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@gmail.com>
inker.cpp
inker_phdr.c
inker_phdr.h
66c033868ff4ce13f1668c97ab11d45aa125a40b 14-Aug-2012 Elliott Hughes <enh@google.com> am c64c1b49: am ad8ff472: am c1eb7619: am 440e417d: Merge "Add dependencies on all the makefiles."

* commit 'c64c1b49fd5c51b1b6e87d88b233d23fa172d372':
Add dependencies on all the makefiles.
ae5c64413bf72bc18d7fc81e1f5761824bc01f49 13-Aug-2012 Elliott Hughes <enh@google.com> 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
ndroid.mk
5dcf871abb9da073fb5efe1c178d0e93d5b50aef 13-Aug-2012 Elliott Hughes <enh@google.com> am 94d7f701: am 71c0366f: am e135d7f3: am a61ac525: Merge "Fix module constructor order."

* commit '94d7f701d1b5cda0621eb46160e11ccbeb85cdd3':
Fix module constructor order.
9181a5dcfe69199415c7aebf93524cc3dd6f8a6f 13-Aug-2012 Evgeniy Stepanov <eugenis@google.com> Fix module constructor order.

.preinit_array goes before the constructors of LD_PRELOAD-ed libraries.

Change-Id: I1af32ce29eaf3ca4351ae8a0f7f5da5165853216
inker.cpp
f574ce603a65008fe9b9e95fd21c90a1f3d3dee3 13-Aug-2012 Nick Kralevich <nnk@google.com> am 34e52129: am 19b10419: am 89fd9ecc: am 20b94c0c: Merge "linker: don\'t perform unnecessary mprotects"

* commit '34e5212961cb64cf690289bc94c59b3b6245694c':
linker: don't perform unnecessary mprotects
5135b3ae6ebc460418f7917bd36b368340e48d5a 11-Aug-2012 Nick Kralevich <nnk@google.com> linker: don't perform unnecessary mprotects

The linker only needs to mark the text segment as
writable iff the file has text relocations. Unnecessarily
calling mprotect when it isn't necessary is slow, and some
security enhanced kernels don't like it. Pages which are
simultaneously writable and executable are considered a no-no.

The vast majority of executables / shared libraries on Android
do NOT have text relocations.

Change-Id: Ic38ce30a99b7e33ecf21efd9c108547a58eafa35
inker.cpp
inker.h
dd8cd5d6bc9e5857a2306116e43c8a8788bd3922 12-Aug-2012 Ben Cheng <bccheng@google.com> am daedcfc5: am 9eeaa4bd: am 7e3918eb: am 0bf5cf87: Merge "Set the dynamic field in the link map for the linker itself."

* commit 'daedcfc595f51b1fe22b53d272cee1a142305a11':
Set the dynamic field in the link map for the linker itself.
c97c5fc7880267fd835d22946a920bf370461cf2 11-Aug-2012 Ying Wang <wangying@google.com> Split out LOCAL_ASFLAGS.

Bug: 6967574
Change-Id: I5be50d582c1cb8075039b06292cf0745a996c3c4
ndroid.mk
0bf5cf87c6b7d3de8962ba132ecfb6f0e4b84f06 11-Aug-2012 Ben Cheng <bccheng@google.com> Merge "Set the dynamic field in the link map for the linker itself."
06f0e74a2b957db93fed3fdd49fe939ab2fe1595 11-Aug-2012 Ben Cheng <bccheng@google.com> Set the dynamic field in the link map for the linker itself.

Otherwise gdb will print a spurious warning each time gdb is used:

warning: .dynamic section for "/system/bin/linker" is not at the expected
address (wrong library or version mismatch?)

BUG:6946614
Change-Id: Ib21b8db0615751189c1601140deb43bc089289b6
inker.cpp
387d4b7de9af2afd0c37a895ff9d012eb1f66156 10-Aug-2012 Elliott Hughes <enh@google.com> Auto-generate a complete NOTICE file.

Remove the hand-collated ones, and switch to a script that pulls the
copyright headers out of every file and collects the unique ones.

Change-Id: Ied3b98b3f56241df97166c410ff81de4e0157c9d
OTICE
57e6d9ab48219467bee0ab28a96533f98552581c 09-Aug-2012 Elliott Hughes <enh@google.com> Fix x86 build.

Change-Id: Ice50ca71a19f3bf26de7cfd4c02075f1e6e0823f
rch/x86/begin.S
4688279db5dcc4004941e7f133c4a1c3617d842c 04-Aug-2012 Elliott Hughes <enh@google.com> 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
ndroid.mk
EADME.TXT
ebugger.c
inker.c
inker.cpp
inker.h
inker_environ.h
inker_format.c
inker_format.h
inker_phdr.c
inker_phdr.h
d7daacb46372132ae3f0121647074936c304b572 31-Jul-2012 Raghu Gandham <raghu@mips.com> 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>
ndroid.mk
rch/mips/begin.S
ebugger.c
lfcn.c
inker.c
inker.h
inker_format.c
8dfc073b1487ab25ab483ab346cee1d9e584adb1 28-Jul-2012 Elliott Hughes <enh@google.com> Fix a TEMP_FAILURE_RETRY usage error in the linker.

Similar to the fix in c20d0f3993ebb0d3dec958a306a68ebb48bfeadd.

grep(1) says this was the only other instance in bionic.

Change-Id: I1729038762ee1c7c4743a6bd11d5558afd6f5749
inker.c
f6ee33cee717f9878d3a43bf76c35547649676d7 18-Jul-2012 Nick Kralevich <nnk@google.com> Merge "linker: Fix LD_PRELOADS for calling constructors"
3fd5e91e58ba40a7321a3f2c4c64970584e9bb56 16-Jul-2012 Elliott Hughes <enh@google.com> Merge "bionic: Report linker relocation address to gdb"
8211bc6325ef61f2fe2021fac9e0f4219abaccf2 05-Jul-2012 Robin Burchell <robin.burchell@collabora.co.uk> linker: cleanup of undefined state handling, which is really dead code

Given that _elf_lookup (and thus, _do_lookup) cannot possibly return an
undefined symbol (due to the check for SHN_UNDEF in _elf_lookup), there's
no need for spurious checks for SHN_UNDEF on its return value.

Conflicts:

linker/linker.c

Change-Id: Ic73cf439924b45f72d4d9ba3f64a888c96cbbd9b
inker.c
439fa8ea8c33a7945258dfe84a71ab2665efaa9a 05-Jul-2012 Robin Burchell <robin.burchell@collabora.co.uk> linker: Use SHN_UNDEF instead of describing what it is trying to do.
inker.c
856512ea9c933c5fe0fff14ee123496730df6b19 16-Jul-2012 Elliott Hughes <enh@google.com> Use std=gnu99 for the dynamic linker as well as libc.

Change-Id: I76dd78576c5af6eb6282555f069647b6260edc31
ndroid.mk
bb5c30a3ee40324effd4daa346505e16faf91728 16-Jul-2012 Ryan V. Bissell <ryan@bissell.org> bionic: Report linker relocation address to gdb

GDB needs the runtime linker's base address in order to
locate the latter's ".text" and ".plt" sections, for the
purpose of detecting solib trampolines. It also can
potentially use this to calculate the relocated address
of rtld_db_dlactivity.

Bug: http://code.google.com/p/android/issues/detail?id=34856
Change-Id: I63d3e7ae4e20a684ceb25967f2241e7d58dd685d
Signed-off-by: Ryan V. Bissell <ryan@bissell.org>
inker.c
326e85eca6916eb904649f7bff65244a40088ba7 14-Jul-2012 Kito Cheng <kito@0xlab.org> linker: Fix LD_PRELOADS for calling constructors

Change-Id: I1eae77a4c59e8a5acc009127d271455bb6fc01b6
inker.c
793e6aedf2dfb6cc9bdf0cf9fd60dd87ec21f658 09-Jul-2012 Andrew Hsieh <andrewhsieh@google.com> am 67636eea: am 40e7ed58: Unhide rtld_db_dlactivity()

* commit '67636eea20f7789e6689ee8cf6017e7d48735ca1':
Unhide rtld_db_dlactivity()
67636eea20f7789e6689ee8cf6017e7d48735ca1 09-Jul-2012 Andrew Hsieh <andrewhsieh@google.com> am 40e7ed58: Unhide rtld_db_dlactivity()

* commit '40e7ed58d73eae59d0cf2fed61284d16692e307b':
Unhide rtld_db_dlactivity()
40e7ed58d73eae59d0cf2fed61284d16692e307b 02-Jul-2012 Andrew Hsieh <andrewhsieh@google.com> Unhide rtld_db_dlactivity()

Since linker is built with -fvisibility=hidden rtld_db_dlactivity()
if hidden from gdb. Unhide it otherwise gdb may not know linker
activity and rescan solib

Change-Id: Ia8cd8d9738c6ea5696ba2ef0ebf2cf783f9ca70a
inker.c
t.c
b52e4385c403d18a68309e568ac729c787d900c4 19-Jun-2012 David 'Digit' Turner <digit@google.com> linker: improve loadable segment protection.

Use the functions in linker_phdr.c to load the PT_LOAD segments
in memory, and toggle their mapping's writable protection bit
as needed. In particular:

- when loading a library, load the segments then unprotected
them to allow relocations to work.

- when relocating the linker of the executable, unprotect
the segments loaded by the kernel to make relocations work
too.

- after all relocations are done, re-protect the segments,
and apply GNU RELRO protection if needed.

- just before calling the destructors, undo the GNU RELRO
protection.

Change-Id: I50e709f03958204b8d6140c0f51ebe24fe089a1b
inker.c
inker.h
63f99f4a4e05353de2e8ba3d7bd4d882d716167a 19-Jun-2012 David 'Digit' Turner <digit@google.com> linker: simplify code for dynamic and ARM exidx sections.

This moves the code that determines where the .dynamic and .ARM.exidx
sections are to a single place in soinfo_link_image().

Change-Id: I98adcb440577bed86442349f03f3c629c945efec
inker.c
bea23e59f7145537fd4e600ae67fa92a798872cf 18-Jun-2012 David 'Digit' Turner <digit@google.com> linker: rename load_offset to load_bias.

This patch changes the definition of the 'load_offset' field
in struct soinfo. The field is renamed because it is not the
basic load bias to add to every p_vaddr value read from the ELF
file to get the corresponding memory address.

This also slightly simplifies the relocation code.

+ Fix for proper load_bias computation for relocatable executables.

Change-Id: I72502c75a70751cba324deee7d313ae61f96609e
inker.c
inker.h
23363ed7503c25ef4024ce0d517f7415c096645d 18-Jun-2012 David 'Digit' Turner <digit@google.com> linker: avoid mapping the whole library before load.

This patch changes the load_library() function in the
dynamic linker to avoid reserving a huge read-only
address-space range just to read the ELF header and
program header (which are typically very small and easily
fit in the first page).

Instead, we use the functions in linker_phdr.c to only
load the data that we need in a temporary mmap-allocated
page of memory, which we release when the function exits.

This avoids issues when loading very large libraries, or
simply debug versions that only need to load a tiny percentage
of their overall file content in RAM.

Change-Id: Id3a189fad2119a870a1b3d43dd81380c54ea6044
inker.c
a6545f46784e67edd5dbcd2bb714c60549f9192d 18-Jun-2012 David 'Digit' Turner <digit@google.com> linker: Add PAGE_START/OFFSET/END convenience macros

This patch adds a few macros related to memory pages to help
clarify some of the code in linker.c

Change-Id: I36c727132d257b1497398dd0a9e8a5a4505467ca
inker.c
c1bd559d5b0fdcc25db2b6ae2705914103b24699 19-Jun-2012 David 'Digit' Turner <digit@google.com> 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
ndroid.mk
inker.h
inker_phdr.c
inker_phdr.h
20bc061dc7a03249c90f8765ae757395587ce4f1 22-Jun-2012 Evgeniy Stepanov <eugenis@google.com> Add module base to main executable's ARM_exidx.

BUG:6697872

Change-Id: I448f4b86397307086231776da38a7af334a75fe5
inker.c
63d0ceec75927155947c07bc45cb9fed5e527922 21-Jun-2012 Andrew Hsieh <andrewhsieh@google.com> am fa136e8c: am a5948157: Merge "Define __stack_chk_fail_local.S"

* commit 'fa136e8ca71cb20956cd1792251869cac8bed257':
Define __stack_chk_fail_local.S
fa136e8ca71cb20956cd1792251869cac8bed257 21-Jun-2012 Andrew Hsieh <andrewhsieh@google.com> am a5948157: Merge "Define __stack_chk_fail_local.S"

* commit 'a5948157fd34acb2b1d1bfaf129901af865ab5fc':
Define __stack_chk_fail_local.S
6973e3da873c5694d0011734c7c6841a46150cb1 20-Jun-2012 Andrew Hsieh <andrewhsieh@google.com> 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
ndroid.mk
rch/x86/begin.S
166b7dbd4aa143fc22f61c64dae1219a910f1a6e 19-Jun-2012 David 'Digit' Turner <digit@google.com> linker: reduce size by nearly 20KB

This patch adds a trivial implementation of snprintf() that calls
our internal vsnprintf().

Inspection of the generated machine code showed that the linker
contained a full implementation of stdio's vfprintf. It was pulled
in because the pthread implementation uses snprintf() somewhere.

ProTip: It's possible to see why specific objects files are included
in a final binary by adding the following to your Android.mk, then
looking at the content of /tmp/MAP.TXT:

LOCAL_LDFLAGS += -Wl,-Map=/tmp/MAP.TXT

Change-Id: I325e71b0cad1d01116a2e00c09e30a80cb716aa3
inker_format.c
16084168111cd7d2ac8a6b92e6fa6df5696928a5 12-Jun-2012 David 'Digit' Turner <digit@google.com> linker: small code-cleanup

This patch adds to make the linker a little bit easier to understand
by making all functions that acts on a sofino object with a soinfo_
prefix.

This is to more easily distinguish functions that operate on global
state, and those that operate on individual libraries.

This should be purely stylistic, i.e. no feature/behaviour change.

Change-Id: Ie510d13d743aa4317644caefa9910b8af7e84f44
lfcn.c
inker.c
inker.h
inker_environ.c
f41855949d5f19e0fc1f8873278ae21c52dd5676 09-Jun-2012 Jeff Brown <jeffbrown@google.com> am e4db460a: am b7630f01: Use new debuggerd protocol.

* commit 'e4db460a54e4f024b83a7df9a3f9920d695da9f3':
Use new debuggerd protocol.
b7630f018abc83261acf78e8cf9a88c1df72f7f5 07-Jun-2012 Jeff Brown <jeffbrown@google.com> Use new debuggerd protocol.

Bug: 6615693
Change-Id: Ibfddc0de3fa2a882f7d0238ab797e5b29296b54b
ebugger.c
f186a1819a4489c8d73485042670a3002742b683 31-May-2012 Ji-Hwan Lee <jihwan@google.com> Support non-zero p_vaddr in first PT_LOAD segment

Before changing mmap() permission to PROT_NONE in alloc_mem_region(),
such libraries once worked with a bug that uses mmap'ed region outside of
memory region allocated by alloc_mem_region(). This possibly incurs
SIGSEGV because it can overwrite memory region of previously loaded
library, but it sometimes worked, depending on loading order.

After PROT_NONE, this caused SIGSEGV earlier during calculation of
si->phdr in load_library(), but this was fixed by:

75917c84d16c35b8fceff6977fa717a3de9ef65d Use mmap to read an ...

Now the behaviour is the same as before applying PROT_NONE in
alloc_mem_region().

This CL fixed the original issue, supporting shared libraries that have
non-zero p_vaddr in first (= with lowest p_vaddr) PT_LOAD segment.

Bug: 6561258
Change-Id: Ib6176dd3e44c4d99a340eb1cbd16fb037586b0bc
inker.c
inker.h
75917c84d16c35b8fceff6977fa717a3de9ef65d 25-May-2012 Ji-Hwan Lee <jihwan@google.com> Use mmap to read an initial ELF header of library

Also, fixes SIGSEV during calculation of si->phdr in load_library(),
which is caused by accessing PHDR area, which is not guaranteed to be
loaded.

Note that this usually does not happen because program header area is
covered by immediately following PT_LOAD entry. But it does not hold
always.

Bug: 6561258
Change-Id: Ie376253c773b5420279ca89044e81b1aad5a5736
inker.c
dcbc3787bfb9a272a010f13ac149d546b4b741d8 12-Nov-2011 Nick Kralevich <nnk@google.com> 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
ndroid.mk
inker.c
inker.h
e742c1f5649d3298cd98d8cc8e62d0cd10be0e82 04-Nov-2011 Nick Kralevich <nnk@google.com> 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
ndroid.mk
077891b199ad295017b32bc9cf1c542c1360b3b8 15-Nov-2011 David 'Digit' Turner <digit@google.com> linker: Fix the computation of si->base

The computation of si->base assumed that the first entry in the
program header table is a PT_PHDR. This results in the dynamic
linker crashing with a SIGSEGV/MAPERR when trying to load some
of the NDK unit test programs, which happen to have an EXIDX
header first, followed byu a PHDR one.

This patch fixes the computation by parsing the program header
table, looking explicitely for the PHDR entry. This fixes the
load of the NDK unit test programs, and doesn't affect system
libraries.

Change-Id: Id18ea6037dbe950b5abbbce816c2960321f0b81d
inker.c
6cdefd06c0386776405e4379af036722db5d60c0 20-Oct-2011 Nick Kralevich <nnk@google.com> Add linker support for PIE

Modify the dynamic linker so that executables can be loaded
at locations other than 0x00000000.

Modify crtbegin* so that non-PIC compilant "thumb interwork
veneers" are not created by the linker.

Bug: 5323301
Change-Id: Iece0272e2b708c79034f302c20160e1fe9029588
inker.c
94179a509ee3f6ba7b4ba45fb90477b01049dab8 24-Apr-2012 Nick Kralevich <nnk@google.com> linker: remove STB_LOCAL hack

The ARM static linker wasn't properly handling __exidx_start
and __exidx_end symbols. Now that the static linker has been fixed,
we don't need the dynamic linker to work around this problem.

Change-Id: I041b94903609fafab33663a7d441a5e70b7ffcdd
inker.c
1a78fbb5c8228e4aea2a516818828b76044310f2 22-Mar-2012 Evgeniy Stepanov <eugenis@google.com> Initialize TLS before any application code is run.

Since e19d702b8e33, dlsym and friends use recursive mutexes that
require the current thread id, which is not available before the libc
constructor. This prevents us from using dlsym() in .preinit_array.

This change moves TLS initialization from libc constructor to the earliest
possible point - immediately after linker itself is relocated. As a result,
pthread_internal_t for the initial thread is available from the start.

As a bonus, values stored in TLS in .preinit_array are not lost when libc is
initialized.

Change-Id: Iee5a710ee000173bff63e924adeb4a4c600c1e2d
inker.c
7f03d2356f1380637d5a38fca20d2cd9b3f6c900 10-Apr-2012 Nick Kralevich <nnk@google.com> Revert "linker: remove STB_LOCAL hack"

This reverts commit 61ff83475c6f3a3bb05a01ac89d668a331bfe9e9.

This code is harmless, and only applies to the linker, so
there's no harm in keeping it in the tree a little bit longer.
Let's roll this back while we try to figure out the root cause
of bug 6314858.

Bug: 6314858
Change-Id: I9f5ed81d23a7abe273baf792aa8a0a2839ef094c
inker.c
61ff83475c6f3a3bb05a01ac89d668a331bfe9e9 09-Apr-2012 Nick Kralevich <nnk@google.com> linker: remove STB_LOCAL hack

The ARM static linker wasn't properly handling __exidx_start
and __exidx_end symbols. Now that the static linker has been fixed,
we don't need the dynamic linker to work around this problem.

Change-Id: Ic567122b6c7746cc016795e2befba2c6bd7c0478
inker.c
8c4f3ce8d084e3949d77ad8743593b5c83c3d41c 04-Apr-2012 Nick Kralevich <nnk@google.com> linker: surround "debug_verbosity" by "#if LINKER_DEBUG"

Avoid executing useless code when we're not compiled
with debugging support.

Change-Id: Iea1821b241acacdf65d1a91d743356058dfef273
inker.c
3a7ea52f17b68f62fa088d57f96ff24a76f50ea2 04-Apr-2012 Nick Kralevich <nnk@google.com> 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 468319ce4f3f7383d788b76c09cda2a405311f36.
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
ndroid.mk
aac0dc97a9ad91231fa89878e745548d693366c1 20-Mar-2012 Nick Kralevich <nnk@google.com> Merge "linker: fix off-by-one error in GNU_RELRO handling"
d73b5cafa0ef381f7c63a75e968fb7eec8e9f555 16-Mar-2012 Nick Kralevich <nnk@google.com> linker: fix off-by-one error in GNU_RELRO handling

Fix a bug where the GNU_RELRO end address could be exactly
the end of the loadable segment.

Change-Id: If6c43acabc06e9aff9217c0f6016e158b28bb41f
inker.c
6625986f3a5c7989b45022413c851f611783f361 16-Mar-2012 Nick Kralevich <nnk@google.com> linker: initially reserved memory as PROT_NONE

When the dynamic linker loads a shared library into memory, it
initially allocates a chunk of memory. The memory is then carved
into smaller chunks for each LOAD region, and appropriate memory
protections applied.

Modify the initial memory allocation so that the pages are mapped
as PROT_NONE, rather than PROT_READ / PROT_EXEC. This ensures that
gaps between LOAD regions are not inadvertantly readable / executable.

(Long term, we should munmap() these gaps entirely)

Change-Id: If128a203ccc6fe12dcbbd2bfe0cf13a2045675af
inker.c
ca9a0712b89eee017c2a40056c101d86c1f7d02f 08-Mar-2012 Andy McFadden <fadden@android.com> Re-throw signals

If we catch a fatal signal that won't automatically re-throw when
the thread resumes, re-throw it manually. (Common examples are
SIGPIPE and the SIGFPE from integer division by zero.)

Change-Id: I329e6d4db907047c555957b42cbd09c50fc808e7
ebugger.c
e5cf8166dcfeebe50e0981467f93b79ac4f69a4f 07-Mar-2012 Marco Nelissen <marcone@google.com> Merge "Log the thread id and name for fatal signals."
3df3e672f51580525452c2eeb4d35633d4dba873 07-Mar-2012 Marco Nelissen <marcone@google.com> Log the thread id and name for fatal signals.

This adds the thread id and name to the "Fatal signal" logging,
making it easier to track down where in process it actually crashed.

Change-Id: I17a365042b2f10b161debe98bc2e7070af055dfb
ebugger.c
9ec0f03a0d0b17bbb94ac0b9fef6add28a133c3a 28-Feb-2012 Nick Kralevich <nnk@google.com> 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
ndroid.mk
inker.c
inker.h
76ab561b4dd30711d82060d66b599aece0a40878 23-Feb-2012 Jean-Baptiste Queru <jbq@google.com> am 49a05c06: am 62daffe1: am f9c5afb1: Merge "Redesign dlopen() locks to be recursive per thread."

* commit '49a05c060acd4d3e17b2819f00a694271bf40977':
Redesign dlopen() locks to be recursive per thread.
e19d702b8e330cef87e0983733c427b5f7842144 20-Feb-2012 Pavel Chupin <pavel.v.chupin@intel.com> Redesign dlopen() locks to be recursive per thread.

That is to fix the bug:
dlxxx functions can't be called recursively.
For example, if we use dlopen() to use open one library whose constructor
also calls dlopen() in order to open another library, then the thread is
dead-blocked.

By changing the dl_lock from a non-recursive lock to a recursive lock, we can
prevent the thread from dead-blocked by recursive dlxxx calls in the same
thread context.

Change-Id: I1018b41c82f4641cc009c0a2eda31f5a47a534f9
Signed-off-by: Pavel Chupin <pavel.v.chupin@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
lfcn.c
9db064a0d3985bc1e4bb9f88ec81c7c2715c410c 01-Feb-2012 David 'Digit' Turner <digit@google.com> am 5d7181a7: am 68fc85ff: am 177a7706: linker: fix x86 build

* commit '5d7181a71c0b066fe6c19b9c5906bd694a399a59':
linker: fix x86 build
177a77067b6d3326dbcf88fd93d0664e48e27f9f 01-Feb-2012 David 'Digit' Turner <digit@google.com> linker: fix x86 build

Change-Id: I47d76a0f50515013c37ccef89accba03cc69529d
lfcn.c
25b7a16a6ee73248192909862f03f95d2363ad14 01-Feb-2012 Jean-Baptiste Queru <jbq@google.com> Merge c4cb87f3

Change-Id: I4cc14eba43fde75a7702fdc7ad07d3d949e9c092
70b1668a76d3b719ae690903ea790fda964a5458 30-Jan-2012 David 'Digit' Turner <digit@google.com> 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>
ndroid.mk
rch/sh/begin.S
lfcn.c
inker.c
inker.h
f5d1693e3ca8cfd089e6259f320044833eae2991 31-Jan-2012 Jesse Hall <jessehall@google.com> Fix recursive ELF constructor check

The flag to avoid calling ELF constructors recursively (in the case
of recursive .so dependencies) was being set after the dangerous
recursive constructor call had already been made.

This fixes the libc's debug malloc implementation.

Change-Id: I5e601f0ea19ab1df81b8b1ad4df25c3eab0ccda4
inker.c
1fc51769ded79c74f15d59611c5ae4bd0547b32b 26-Jan-2012 Andy McFadden <fadden@android.com> Log debuggerd connection failures

Write a message to the log file if the signal handler is not able
to connect to debuggerd. This is especially handy if the failure
was caused by running out of file descriptors, since there's some
chance that the lack of fds relates to the crash.

Sample:

F libc : Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
F libc : Unable to open connection to debuggerd: Too many open files

Bug 5926330

Change-Id: I0ff210d82ab1db39b08f328bae5e08f67a69e5d7
ebugger.c
f20d59e69137336a2555844ce9f74ece96ad60ea 21-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am c83c1da5: am cee8425f: Merge "Move variable declaration on its own line"

* commit 'c83c1da54831ef1c9ff59cf9df8d5c0173893ee5':
Move variable declaration on its own line
c3650d6a4be812989bcc6b4938af6da644168a09 21-Jan-2012 Jean-Baptiste Queru <jbq@google.com> am 5b44655f: am 7e6a5773: Merge "Use the AT_SECURE auxv flag to determine whether to enable secure mode."

* commit '5b44655f22dd05c7cd8afcd218102616a6f5f4da':
Use the AT_SECURE auxv flag to determine whether to enable secure mode.
bb44055d0a3515410f45417d5b0e047cc60f0dc6 20-Jan-2012 Stephen Smalley <sds@tycho.nsa.gov> Move variable declaration on its own line

Change-Id: Ied54ffabccdc867ea4e124a0f0324a217270d6e7
inker.c
861b42a2d83f72f11b4271b5b8431595a097c7c2 13-Jan-2012 Stephen Smalley <sds@tycho.nsa.gov> Use the AT_SECURE auxv flag to determine whether to enable secure mode.

The Linux kernel provides an AT_SECURE auxv flag to inform userspace
whether or not a security transition has occurred. This is more reliable
than directly checking the uid/gid against the euid/egid, because it covers
not only setuid/setgid but also file capabilities, SELinux, and AppArmor
security transitions. It is also a more efficient test since it does
not require any additional system calls.

Change-Id: I9752a4f6da452273258d2876d13b05e402fb0409
inker.c
e83c56dfbb6a9a61f0f18031620322af97e80162 21-Dec-2011 Evgeniy Stepanov <eugenis@google.com> Execute .preinit_array before any shared object initialization functions.

This change makes linker handling of .preinit_array compliant with the
System V ABI:

"These [pre-initialization] functions are executed after the dynamic linker has
built the process image and performed relocations but before any shared object
initialization functions."
http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#init_fini

Change-Id: Iebfee22bb1ebe1d7c7e69cb4686e4ebae0dfc4bb
EADME.TXT
lfcn.c
inker.c
inker.h
253b7631606e47de720f38082394a5791fe4bf0d 06-Dec-2011 Nick Kralevich <nnk@google.com> get rid of unused "main" function.

confuses gdb.

Change-Id: I1c64357ce122fe5a2564ee96bb4caa32b733f6ea
inker.c
0e0bd586319b25e6e8e797b426a0adcce7612577 30-Nov-2011 Zhenghua Wang <zhenghua.wang@intel.com> am 1ad08626: am 897815a1: bionic: add machine type check

* commit '1ad08626a143dc684e92f56754c7176cc4914ce8':
bionic: add machine type check
897815a1feff230be3ea42655a77dcbb9a8dcca9 18-Oct-2011 Zhenghua Wang <zhenghua.wang@intel.com> bionic: add machine type check

android linker doesn't check machine type, it may load some
libraries which it doesn't support sometimes.

Author: Zhenghua Wang <zhenghua.wang@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
inker.c
7e2daefe6cec40e143f519c46aec877ee053b407 16-Nov-2011 Nick Kralevich <nnk@google.com> Merge "Make the linker relocatable."
8180b08fb2f27052f9df2ae4787bb5bf409f13e0 15-Nov-2011 David 'Digit' Turner <digit@google.com> linker: Fix the computation of si->base

The computation of si->base assumed that the first entry in the
program header table is a PT_PHDR. This results in the dynamic
linker crashing with a SIGSEGV/MAPERR when trying to load some
of the NDK unit test programs, which happen to have an EXIDX
header first, followed byu a PHDR one.

This patch fixes the computation by parsing the program header
table, looking explicitely for the PHDR entry. This fixes the
load of the NDK unit test programs, and doesn't affect system
libraries.

Change-Id: Id18ea6037dbe950b5abbbce816c2960321f0b81d
inker.c
468319ce4f3f7383d788b76c09cda2a405311f36 12-Nov-2011 Nick Kralevich <nnk@google.com> 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
ndroid.mk
inker.c
inker.h
7939908c8310342c8e1b717c4599273a782b3c2b 04-Nov-2011 Nick Kralevich <nnk@google.com> 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
ndroid.mk
8e8a7b1f0fb9daf8d4434e18a9fff5c28f849cb8 03-Nov-2011 Nick Kralevich <nnk@google.com> Revert "Make the linker relocatable."

This reverts commit 994e9a5ed1c4e9f23a8bed79caea684eaa270027.

Broke x86 build.
ndroid.mk
inker.c
inker.h
994e9a5ed1c4e9f23a8bed79caea684eaa270027 01-Nov-2011 Nick Kralevich <nnk@google.com> 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
ndroid.mk
inker.c
inker.h
d9ad62343c2db6b66a5fa597c9b20a6faabd7a9a 20-Oct-2011 Nick Kralevich <nnk@google.com> Add linker support for PIE

Modify the dynamic linker so that executables can be loaded
at locations other than 0x00000000.

Modify crtbegin* so that non-PIC compilant "thumb interwork
veneers" are not created by the linker.

Bug: 5323301
Change-Id: Iece0272e2b708c79034f302c20160e1fe9029588
inker.c
bda5da074eab4bdf374e1f4a19d480c62c72f5ff 28-Sep-2011 Mathias Agopian <mathias@google.com> fix prototype of dladdr

this breaks C++ source code in particular.

Change-Id: Ie06b5d31d23b5455e6950c470adc64dd5e7784df
lfcn.c
inker.c
inker.h
96e5faccdc5616bb6d4a55d50a0e6148f99d943b 30-Aug-2011 David 'Digit' Turner <digit@android.com> am 91966c30: am 0acdbe08: am 89ea107d: Merge "linker: allow debugging of constructors"

* commit '91966c30efbdc7feecd6c45a46ab488e715c0a35':
linker: allow debugging of constructors
91966c30efbdc7feecd6c45a46ab488e715c0a35 30-Aug-2011 David 'Digit' Turner <digit@android.com> am 0acdbe08: am 89ea107d: Merge "linker: allow debugging of constructors"

* commit '0acdbe0892105d01a38de9baf4e34eef22b8259c':
linker: allow debugging of constructors
38bccb271f121fc06eaa0d8fbd3c982bc44c36b7 29-Aug-2011 Nick Kralevich <nnk@google.com> linker.h: don't change the soinfo structure

In 48527c3f740a80b45acb5a6efc217f771ae50143, we modified the soinfo
structure to remove an unnecessary variable. However, third party
programs seem to be relying on the structure not changing.
Add a dummy variable back into place to preserve structure.

Bug: 5064106

Change-Id: I3014dda1a46e624644b09e156c3e9381ba3729bd
inker.h
e5ea45547e131ae842b7c79cd45b164470137367 27-Aug-2011 David 'Digit' Turner <digit@android.com> linker: allow debugging of constructors

This patch allows the debugging of constructors in shared
libraries and executables. It does so by ensuring that the
corresponding binary is visible to gdb before running the
constructors.

Change-Id: I0a3df726a04ad109944c834dcbba672b85d3991e
inker.c
ec92af8fe5d28c74f3505932135b1b8f3fbaad00 29-Jul-2011 Andy McFadden <fadden@android.com> Log signal info at time of receipt

When a fatal signal is received, we now write a message to the log
that looks like this:

F/libc ( 1540): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)

This is useful for debugging fatal signals that turn out not to be
fatal. This also changes the signal reset from SIG_IGN to SIG_DFL,
so that future non-fatal fatal signals are fatal.

The code that blocked SIGUSR1 to avoid being interrupted by the GC
has been removed.

Also, fix minor issues in format_buffer().

Bug 5035703

Change-Id: I8940af47297b5dcf3cf33537e3483ca5334ed565
ebugger.c
inker_format.c
48527c3f740a80b45acb5a6efc217f771ae50143 17-Jul-2011 Shih-wei Liao <sliao@google.com> Revert "Revert "linker: get rid of the buddy allocator""

This reverts commit f9a9cda23a6afc1c2dfdfd624cde23b61941eb5e.
This revert is promised once b/5039224, b/5036755, b/5036610 are resolved.
ndroid.mk
a.c
a.h
inker.c
inker.h
f9a9cda23a6afc1c2dfdfd624cde23b61941eb5e 16-Jul-2011 Nick Kralevich <nnk@google.com> Revert "linker: get rid of the buddy allocator"

This reverts commit 7059b1f02ea9197728c851edd9ae0dd7688fa700.
Bug: 5036610
ndroid.mk
a.c
a.h
inker.c
inker.h
7059b1f02ea9197728c851edd9ae0dd7688fa700 14-Jul-2011 Nick Kralevich <nnk@google.com> 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
ndroid.mk
a.c
a.h
inker.c
inker.h
a903811819c06e4d6e9e27fcc9db3ab5459009bc 07-Jun-2011 Martijn Coenen <maco@google.com> Revert "x86: Enable -fstack-protector"

This reverts commit e0b4844a20ffd022a568abb4203b3f7c759c7ff5,
causes netd to crash.
ndroid.mk
rch/x86/begin.S
65fb884d28c26dc84d27bea6861b3a95a327db66 06-Jun-2011 David Turner <digit@android.com> am 204d1f65: am b2c7e0c1: Merge "x86: Enable -fstack-protector"

* commit '204d1f65dbfc6d5a14a90627d9d1efcfce8261ee':
x86: Enable -fstack-protector
204d1f65dbfc6d5a14a90627d9d1efcfce8261ee 06-Jun-2011 David Turner <digit@android.com> am b2c7e0c1: Merge "x86: Enable -fstack-protector"

* commit 'b2c7e0c18b7ab04cfe306277c79165de0612a2d1':
x86: Enable -fstack-protector
e0b4844a20ffd022a568abb4203b3f7c759c7ff5 04-May-2011 Bruce Beare <bruce.j.beare@intel.com> x86: Enable -fstack-protector

Change-Id: Ib69514c3afcb4c1f5e5f3f8cd91acfd145a0866c
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
ndroid.mk
rch/x86/begin.S
c2af2c075f15fa22f7ac8f6bb9d2aab1c3bd3b31 02-May-2011 David Turner <digit@android.com> am 1af88c97: am d004dc99: Merge "Use MAP_FIXED when allocating prelinked shared library regions"

* commit '1af88c97432c88ec5b39d155e8c296d2a6eb1225':
Use MAP_FIXED when allocating prelinked shared library regions
1af88c97432c88ec5b39d155e8c296d2a6eb1225 02-May-2011 David Turner <digit@android.com> am d004dc99: Merge "Use MAP_FIXED when allocating prelinked shared library regions"

* commit 'd004dc9957cd8944d3db8ed92544c8ee65b117ca':
Use MAP_FIXED when allocating prelinked shared library regions
368070454b1349d1fcf29a5d1eb51c869fb538f6 14-Mar-2011 Iliyan Malchev <malchev@google.com> bionic: remove LOCAL_PRELINK_MODULE

Change-Id: Iad65ae18446b20d2aace7b8fe19b1a032b616e9c
Signed-off-by: Iliyan Malchev <malchev@google.com>
ndroid.mk
db4bce05493d09a20f1ebc0ab68c82e906327afd 10-Mar-2011 Chris Dearman <chris@mips.com> Use MAP_FIXED when allocating prelinked shared library regions

Prelinked libraries must be mapped to a fixed address. MAP_FIXED is ignored
for non-prelinked libraries (si->base==0)

Signed-off-by: Raghu Gandham <raghu@mips.com>
inker.c
81d79f9fb38d9ae8a5711f5774aa5a1516f6cc26 10-Mar-2011 David 'Digit' Turner <digit@android.com> am 962dcb22: am fed58049: Merge "libc: Fix PTHREAD_RWLOCK_INITIALIZER"

* commit '962dcb22218a1a6d4ebd05e4fc4a69875d037234':
libc: Fix PTHREAD_RWLOCK_INITIALIZER
Proxy getnameinfo through netd
Updated gcc 4.4.3 IA toolchain doesn't require the .ctors list
Convert cname lenght before use
48e1feaa9d7d7f36b5eba25baccd99a56adf9b64 27-Jan-2011 Bruce Beare <bruce.j.beare@intel.com> Updated gcc 4.4.3 IA toolchain doesn't require the .ctors list

Change-Id: Ia840a19a45257128eccdcf25d105f500f2d90741
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
rch/x86/begin.S
72f9a5c374bf559e9c69a62c1d95304f913ef6b2 11-Feb-2011 Kenny Root <kroot@google.com> Increase SO_MAX to accomodate valgrind

system_server loads up 87 shared libraries upon start. Running under
valgrind pushes this just over the edge of 96. Increase SO_MAX to 128 to
give us some more headroom.

Change-Id: Iadceb14ab6d9621bdccd292570d50867828057d9
inker.c
b67c1bacd0fc27c26cc3ec19bd2c9ded19cecd08 21-Jan-2011 tedbo <tedbo@google.com> Fix bug in linker environment variable lookup.

The linker_env_get() method that is used to match an environment
variable was failing due to an incorrect equality check.

This was introduced in git change
be5755969d70668bbab0e0c0ed75ebd867189723.

The bug was causing the linker to ignore environment variables such
as LD_LIBRARY_PATH. This issue also affects the linker_env_secure()
path that removes unsafe environment variables, since it would
not match any in the unsecure variable list.

Change-Id: I14228df9252010e9fb4c1862bed5735f23e97aec
inker_environ.c
b3cdf7fef86eb17dba5640e9a1b158510326b9b7 21-Jan-2011 tedbo <tedbo@google.com> Fix bug in linker environment variable lookup.

The linker_env_get() method that is used to match an environment
variable was failing due to an incorrect equality check.

This was introduced in git change
be5755969d70668bbab0e0c0ed75ebd867189723.

The bug was causing the linker to ignore environment variables such
as LD_LIBRARY_PATH. This issue also affects the linker_env_secure()
path that removes unsafe environment variables, since it would
not match any in the unsecure variable list.

Change-Id: I169024de4a005321e768accd38246fc1d717271b
inker_environ.c
1f353828c3535c03899d6cc08d26f85fc688622e 18-Jan-2011 Glenn Kasten <gkasten@google.com> Fix typos

Change-Id: Ia02baba53be7034903f325258205441e5c193f7b
EADME.TXT
be5755969d70668bbab0e0c0ed75ebd867189723 16-Dec-2010 David 'Digit' Turner <digit@google.com> linker: Remove unsecure env. variable for setuid programs.

This removes several unsecure environment variables from the
environment block when the program being loaded is setuid. The
list of env. variables is the same than what GLibc uses at this
point.

Change-Id: I456d3ea0880fe0d4de0d3c5dd51871dd36e87fd6
ndroid.mk
inker.c
inker_environ.c
inker_environ.h
fedbcde6ef552e84bf7ce7598bca7dddf1722d6a 19-Sep-2010 Brian Swetland <swetland@google.com> add /vendor support

- add /vendor/lib to front of default library search path
- remove long-obsolete /lib from default library search path

Change-Id: I7d33bf899be018e7cc4c213d5790bbd991023a62
inker.c
a716190241da07f42cf874b04bf044261f36381c 18-Aug-2010 Dima Zavin <dima@android.com> linker: fix overwriting the real linker error string

Change-Id: Ia9165fd9aa1951b2bb81d0ac8f5bb3057aded8bd
Signed-off-by: Dima Zavin <dima@android.com>
inker.c
6774809b6249d9d4efd982b6e3ca377c84482d9a 22-Jul-2010 David 'Digit' Turner <digit@google.com> linker: Support dlopen(NULL, ...) properly.

Change-Id: Icba37823cb350c34848cc466d144c3a0af87c94c
inker.c
8bff9a31aa13ff83ccaedd54ebda96770e6cf910 11-Jun-2010 David 'Digit' Turner <digit@google.com> linker: remove libcutils dependency by re-implementing simpler socket_local_client.

Change-Id: I87f29fd59454d713b9ddfb13e6cf114822f52efd
ndroid.mk
ebugger.c
f4394458301909a83b7ee7f3b436c038b7235ea8 12-May-2010 Jean-Baptiste Queru <jbq@google.com> fix build

Change-Id: I243c98e20a250e0d40d481f16af481ff070219fd
inker.c
bb7928ccdae0cc5766f290e18ab14b07d80c6912 12-May-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: Iecfd2bd3069f70bbe508042cc249fcf7ff24800d
4fd42c1dc002fa19349fa0d4ef97757eb1815032 31-Dec-2009 Matt Fischer <matt.fischer@garmin.com> Added support for LD_PRELOAD

The LD_PRELOAD environment variable allows the user to specify a list of
libraries which should be unconditionally loaded before any others. This
makes possible some useful tricks, such as library interposers.

Change-Id: I433d775ab08ef63a5fbe7b21f87a5642954fc32f
inker.c
5ef5272be985dfdeafa86077c306f6b64d334240 21-Apr-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: I518bb4ae9d7269957365561d4d609f22cde519db
1698d9ebfc7e27271852a1fdf305a2ac37b3ebe4 31-Dec-2009 Matt Fischer <matt.fischer@garmin.com> Fixed support for RTLD_NEXT in dlsym()

The previous implementation of this flag was broken--it behaved identically
to RTLD_DEFAULT. This adds a proper implementation, which examines the address
of the calling function, and uses it to determine which library to use to begin
the symbol search process.

Change-Id: I2ad2b46363f68932af63a3828a22f9c7987eea67
lfcn.c
inker.c
inker.h
d04672513351af4eb302692e0f39fd5bd17191cb 31-Mar-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: I483fedf77d978b1c6e52d73eebc14f011bb9f809
3cab22c8cf0dcf30718a1452ce9cbb637876cea3 19-Jan-2010 Min-su, Kim <min-su.kim@windriver.com> linker: fix the undefined weak symbols issue
inker.c
377d4c979dee3dcb5929e8f7a68a53c2407259ab 22-Mar-2010 The Android Open Source Project <initial-contribution@android.com> merge from open-source master

Change-Id: I70266ee8c520b216773f267e46c8273d2334c31d
e2a8b1fd19fb3a8ead2ba28ddba27be19fa978b5 31-Dec-2009 Matt Fischer <matt.fischer@garmin.com> Added support for dladdr()

dladdr() is a GNU extension function, which allows the caller to retrieve
symbol information for a specified memory address. It is useful for things
like generating backtrace information at runtime.

Change-Id: I3a1def1a6c9c666d93e1e97b7d260dfa5b9b79a9
lfcn.c
inker.c
inker.h
5c734644eebf8d01be1e86cbe20a111a5c5a2738 20-Jan-2010 David 'Digit' Turner <digit@google.com> Fix debug output in the dynamic linker.

This provides a mini-printf implementation that reduces the
size of the dynamic linker by 25 KB, by preventing the drag of
formatting-related routines from the C library.

Also allow traces to be sent to the log, instead of stdout.

NOTE: You now need to modify Android.mk to enable/disable debug
output.
ndroid.mk
EADME.TXT
lfcn.c
inker.c
inker_debug.h
inker_format.c
inker_format.h
e100f52f4ad1b70762bbcc5ad9828bd258917ee5 11-Feb-2010 Iliyan Malchev <malchev@google.com> bionic/linker: rename ba_prelink to ba_nonprelink

-- fixes b/2432550
-- ba_prelink is used to manage non-prelinked libraries, hence ba_nonprelink is
a more appropriate name for it

Signed-off-by: Iliyan Malchev <malchev@google.com>
inker.c
90f82e5868de5a30d4842951b80be0c8a9cedc6d 25-Jan-2010 Doug Kwan <dougkwan@google.com> Fix typo in a comment.
ndroid.mk
1a2917ca954f575cc9698c99e54bd93087793c8f 25-Jan-2010 Doug Kwan <dougkwan@google.com> Align TEXT section to 4K boundary so that we can use both ld and gold.
ndroid.mk
278d157f437c0357b7c6d1fb1cbffbc0a72bb788 30-Sep-2009 Gary King <gking@nvidia.com> Use correct TLS codepath for linker

Replicate ARM libc build's HAVE_ARM_TLS_REGISTER preprocessor definition
logic, to ensure that the runtime linker uses the correct codepath for
accessing the TLS address
ndroid.mk
a3de55c83185ba3d1355f20b48ef9ec3fc4c281d 02-Dec-2009 David 'Digit' Turner <digit@google.com> am fe62de1a: Add support for R_ARM_REL32 to the dynamic linker.

Merge commit 'fe62de1ad036a1417df44b7b1a7c65cc79dc7091' into eclair-plus-aosp

* commit 'fe62de1ad036a1417df44b7b1a7c65cc79dc7091':
Add support for R_ARM_REL32 to the dynamic linker.
fe62de1ad036a1417df44b7b1a7c65cc79dc7091 02-Dec-2009 David 'Digit' Turner <digit@google.com> Add support for R_ARM_REL32 to the dynamic linker.

Merged from eclair-mr2
inker.c
inker.h
83d3d7491a2d3870efd8d5be9281ee942f5fad07 18-Nov-2009 David 'Digit' Turner <digit@google.com> am ebf3ea00: am 34ea5117: Add support for R_ARM_REL32 to the dynamic linker.

Merge commit 'ebf3ea006e5367fff93d2491eec24c4b1a633805'

* commit 'ebf3ea006e5367fff93d2491eec24c4b1a633805':
Add support for R_ARM_REL32 to the dynamic linker.
ebf3ea006e5367fff93d2491eec24c4b1a633805 18-Nov-2009 David 'Digit' Turner <digit@google.com> am 34ea5117: Add support for R_ARM_REL32 to the dynamic linker.

Merge commit '34ea5117dbeba41ae5dfdfb2c2ec8cae23388b66' into eclair-mr2-plus-aosp

* commit '34ea5117dbeba41ae5dfdfb2c2ec8cae23388b66':
Add support for R_ARM_REL32 to the dynamic linker.
34ea5117dbeba41ae5dfdfb2c2ec8cae23388b66 17-Nov-2009 David 'Digit' Turner <digit@google.com> Add support for R_ARM_REL32 to the dynamic linker.
inker.c
inker.h
b152dde4cafffb3b37ca60c589f71110ca988c79 09-Nov-2009 Jean-Baptiste Queru <jbq@google.com> am 83362689: merge from open-source master

Merge commit '83362689f5b1f6393d376d242fe29541b63ead2d'

* commit '83362689f5b1f6393d376d242fe29541b63ead2d':
added and modified linker to support SuperH architecture
Add the BSD sys_signame array.
added and modified bionic code to support SuperH architecture
83362689f5b1f6393d376d242fe29541b63ead2d 09-Nov-2009 Jean-Baptiste Queru <jbq@google.com> merge from open-source master
10be95cffc7f2b02d8baac55a9cf1b16d8afbadb 09-Nov-2009 Jean-Baptiste Queru <jbq@google.com> merge from open-source master
ad13c57298e57d33c130fb03a2c6494da573408c 06-Nov-2009 Shin-ichiro KAWASAKI <shinichiro.kawasaki.mg@hitachi.com> added and modified linker to support SuperH architecture
ndroid.mk
rch/sh/begin.S
lfcn.c
inker.c
inker.h
e823807dc2fb5f2d44cd00d75c10ddd9f5e93bea 26-Oct-2009 Doug Kwan <dougkwan@google.com> Add weak symbol support. Also fix a bug caused by a typo.
inker.c
f1729553e310b55eef8ee784c95cd9dd8ffd24fd 24-Oct-2009 Iliyan Malchev <malchev@google.com> am 9e78de3e: am 70bba516: am 763ac283: Merge changes Ibcba4b4f,I9af341e1 into eclair

Merge commit '9e78de3e3c90ec3c2970431d8eae7378fdc0dac6'

* commit '9e78de3e3c90ec3c2970431d8eae7378fdc0dac6':
bionic/linker: make the buddy allocator compute max_order on its own
bionic/linker: change the buddy allocator to take a handle to the managed area
9e78de3e3c90ec3c2970431d8eae7378fdc0dac6 24-Oct-2009 Iliyan Malchev <malchev@google.com> am 70bba516: am 763ac283: Merge changes Ibcba4b4f,I9af341e1 into eclair

Merge commit '70bba5160f83ecd6251c4539f747ae39e9ed469c' into eclair-mr2-plus-aosp

* commit '70bba5160f83ecd6251c4539f747ae39e9ed469c':
bionic/linker: make the buddy allocator compute max_order on its own
bionic/linker: change the buddy allocator to take a handle to the managed area
53b32f8b7ef0ae319cc048ce1f0a81a4be8bce64 24-Oct-2009 Iliyan Malchev <malchev@google.com> am 763ac283: Merge changes Ibcba4b4f,I9af341e1 into eclair

Merge commit '763ac28357f604e0e4196e0a7ad5b0f5cdcf274a' into eclair-plus-aosp

* commit '763ac28357f604e0e4196e0a7ad5b0f5cdcf274a':
bionic/linker: make the buddy allocator compute max_order on its own
bionic/linker: change the buddy allocator to take a handle to the managed area
70bba5160f83ecd6251c4539f747ae39e9ed469c 24-Oct-2009 Iliyan Malchev <malchev@google.com> am 763ac283: Merge changes Ibcba4b4f,I9af341e1 into eclair

Merge commit '763ac28357f604e0e4196e0a7ad5b0f5cdcf274a' into eclair-mr2

* commit '763ac28357f604e0e4196e0a7ad5b0f5cdcf274a':
bionic/linker: make the buddy allocator compute max_order on its own
bionic/linker: change the buddy allocator to take a handle to the managed area
943043583a8f3a8de34970b550a3e8e8a6fb0fb8 24-Oct-2009 Doug Kwan <dougkwan@google.com> Clean up some linker code.
inker.c
bb9eedeff4ddc4550991eb4511003bda8672d6c4 19-Oct-2009 Iliyan Malchev <malchev@google.com> bionic/linker: make the buddy allocator compute max_order on its own

Signed-off-by: Iliyan Malchev <malchev@google.com>
a.c
inker.c
af7315acf6a3a5ac329b04cb543b5d8a95dc26f1 17-Oct-2009 Iliyan Malchev <malchev@google.com> bionic/linker: change the buddy allocator to take a handle to the managed area

-- rename struct ba_info to struct ba
-- move the static ba descriptor from ba.c to linker.c and rename it ba_prelink
-- ba_init, ba_allocate, ba_free, ba_start_addr, and ba_len all take a pointer
to struct ba

Signed-off-by: Iliyan Malchev <malchev@google.com>
a.c
a.h
inker.c
b3cfdb6220b9ce8ec6d25984ef086fa06f157236 20-Oct-2009 David 'Digit' Turner <digit@google.com> am eeaf6544: Merge change I7934a799 into eclair-mr2

Merge commit 'eeaf6544b676f68ccdd70a3fa78f44789a1bf69c' into eclair-mr2-plus-aosp

* commit 'eeaf6544b676f68ccdd70a3fa78f44789a1bf69c':
Prevent spurious EINTR to freeze process debugging
eeaf6544b676f68ccdd70a3fa78f44789a1bf69c 19-Oct-2009 Android (Google) Code Review <android-gerrit@google.com> Merge change I7934a799 into eclair-mr2

* changes:
Prevent spurious EINTR to freeze process debugging
5d436ddcae640e2b2af30a5654bec33273b7a9c3 16-Oct-2009 David 'Digit' Turner <digit@google.com> am 8213d5c3: am ff7b46b8: Merge change I3c998761 into eclair

Merge commit '8213d5c3c072b23f5cc1922d232efe7338091d9b' into eclair-mr2-plus-aosp

* commit '8213d5c3c072b23f5cc1922d232efe7338091d9b':
Allow the dynamic linker to relocate references to thumb symbols in NDK libraries.
cd230988286eb6aa395e051345052773f1943294 16-Oct-2009 David 'Digit' Turner <digit@google.com> am ff7b46b8: Merge change I3c998761 into eclair

Merge commit 'ff7b46b87c4d85881d88c2105a94be6c6accb628' into eclair-plus-aosp

* commit 'ff7b46b87c4d85881d88c2105a94be6c6accb628':
Allow the dynamic linker to relocate references to thumb symbols in NDK libraries.
7934a799e1041db9cff9753f4d87d7361f644450 16-Oct-2009 David 'Digit' Turner <digit@google.com> Prevent spurious EINTR to freeze process debugging
ebugger.c
73981476a389847e8537cca37503c43e107fadc9 14-Oct-2009 Jean-Baptiste Queru <jbq@google.com> merge from open-source master
3c99876116356cae09231189f09e5a679fd0d2fd 14-Oct-2009 David 'Digit' Turner <digit@google.com> Allow the dynamic linker to relocate references to thumb symbols in NDK libraries.

The lowest bit of the symbol's value should be ignored when looking at UNDEF symbols
for correctness. It is used as an ARM/Thumb flag by the linker.
inker.c
4a9afcb10151b083cd2d75253385615f459172ed 29-Sep-2009 Iliyan Malchev <malchev@google.com> bionic/linker: allow resolving of symbols from library back to executable

Signed-off-by: Iliyan Malchev <malchev@google.com>
inker.c
9ea64da6c511e8f9f4edae4c10c20879957631ab 29-Sep-2009 Iliyan Malchev <malchev@google.com> bionic/linker: change lookup() to return soinfo, not base
lfcn.c
inker.c
inker.h
6ed80c8814db9eed1fb687be22322e38dc46a2fb 29-Sep-2009 Iliyan Malchev <malchev@google.com> Revert "Revert "bionic/linker: fix symbol lookup during relocations""

This reverts commit 33acbf0719c4f3db059bc9e1f52cf554a5d0295f.
inker.c
33acbf0719c4f3db059bc9e1f52cf554a5d0295f 28-Sep-2009 Mathias Agopian <mathias@google.com> Revert "bionic/linker: fix symbol lookup during relocations"

This reverts commit 8d0c0334f1106d36f2fd5c1cf6d5dc75a4b88850.
inker.c
8d0c0334f1106d36f2fd5c1cf6d5dc75a4b88850 25-Sep-2009 Iliyan Malchev <malchev@google.com> bionic/linker: fix symbol lookup during relocations

When resolving relocations while loading a library, the linker used to find
symbols by looking them up in the list of all linked libraries for the current
process, as opposed to following just the library's DT_NEEDED entries. This
can cause a problem where the symbol is picked up from the wrong library.

Signed-off-by: Iliyan Malchev <malchev@google.com>
inker.c
5cf640c926e7d7b79934c97226433a3dc448e1eb 03-Jul-2009 Thinker K.F Li <thinker@branda.to> Fill l_ld of linkmaps with value from soinfo::dynamic.

GDB will try to read l_ld of linkmaps and compare the value to vma of
.dynamic sections from shared objects. Since linker does not assign l_ld,
GDB will complain about and re-compute l_addr from l_ld. And, GDB will get a
wrong value.
inker.c
30eb40241c612a7ddbd21c4daa4e7bbfd9d5e89f 14-Aug-2009 Erik Gilling <konkers@android.com> bionic: linker: add error message if link failed due to previous error

Signed-off-by: Erik Gilling <konkers@android.com>
inker.c
fde8642fc43bdd224e43e5ee9583a49a758fb03c 29-Jul-2009 Erik Gilling <konkers@android.com> bionic/linker: keep track of opened libraries by basename

Prior to this change, the dynamic loader kept track of opened libraries
either by their base name (i.e., libfoo.so instead of /system/lib/libfoo.so)
when the shared library was loaded through the DT_NEEDED tag in an ELF header,
or by whatever name was passed to dlopen(). This created a number of problems,
among which:

1. dlopen("libfoo.so") and dlopen("/path/to/libfoo.so") would open the same
library twice;
2. dlopen("/path/to/libfoo.so") and then dlopen("libbar.so"), where libbar.so
depends on libfoo.so, would open libfoo.so twice.

This patch makes the dynamic loader keep track of each loaded library by
basename, which resolves the above ambiguity. The patch also enforces
library lookup by base name, which means that it will refuse to load another
library that has the same name.

Thanks for the inspiration Iliyan.

Signed-off-by: Erik Gilling <konkers@android.com>
Cc: Iliyan Malchev <malchev@google.com>
inker.c
d00d23a9d4598108d7f498291b35c7730e48cf5c 23-Jul-2009 Erik Gilling <konkers@android.com> linker: remove newlines from DL_ERR so that dlerror works correctly

Signed-off-by: Erik Gilling <konkers@android.com>
inker.c
ef0bd1857041ffde069cf52138aaf22c1af7130e 17-Jul-2009 David 'Digit' Turner <digit@google.com> Pass the elfdata pointer in a slot of the temporary TLS area.

This is needed to properly initialize the C runtime when libc.so
is loaded by the dynamic linker.

Move the temporary TLS setup before the first system call, just
in case something really horrible happens, we won't crash when
trying to write an error code in 'errno'

Remove the broken TLS_SLOT_THREAD_ID setup. First, this slot
should normally receive the address of a pthread_internal_t,
not a kernel thread identifier. Second, it is never used by
the linker anyway.

Also remove an obsolete comment.
inker.c
bc3a5c26f1b9cf29da6abfc3e197258ef4c03362 03-Jun-2009 David Bartley <dtb@google.com> Add LD_LIBRARY_PATH support to bionic's linker
inker.c
0353195f344666256dba474a15c9ba22cf0cccc9 30-May-2009 Dima Zavin <dima@android.com> linker: Give more context for failures during library dependency resolution.

Signed-off-by: Dima Zavin <dima@android.com>
inker.c
2e85579c34047c305caf15fb0ebe02bf3d001d0e 21-May-2009 Dima Zavin <dima@android.com> linker: Make the errors reported by dlopen/dlsym be more useful.

Changed it so that when the linker generates error messages, they are
scribbled away into a buffer that dlfcn and friends can read from.

Since the error messages are generetad with snprintf, and snprintf
MAY call malloc during some code paths, we now link against a version
of libc that does not contain malloc/free/realloc/calloc. We then define
malloc and friends in the dynamic loader, and make them abort() if they
are ever called.

Signed-off-by: Dima Zavin <dima@android.com>
ndroid.mk
lfcn.c
inker.c
inker.h
inker_debug.h
8215679b355efe3829bab571bd566dc818ea4ccc 18-May-2009 David 'Digit' Turner <digit@google.com> Fix the parsing of the .fini_array in the dynamic linker (it should happen in reverse order).
Also add a small design overview document for the linker. The latter contains details on
how the initialization/finalization is supposed to work.
EADME.TXT
inker.c
d1b40d8c69dfca94185ea9231f6cb16f70c02e39 12-May-2009 Dima Zavin <dima@android.com> linker: Compute symbol name before lookup so we can also use it for error msg

Signed-off-by: Dima Zavin <dima@android.com>
inker.c
ba52b3092f361580a5dea7ab8fbe2a227b55ee43 01-May-2009 James Dong <jdong@google.com> Increase the limit of loaded shared libraries from 64 to 96 This change is required for OpenCORE 2.0
This is the same as Change 71 in master branch.
inker.c
5e12d7ec70472659623d2e4552a670d8877f2423 25-Mar-2009 Iliyan Malchev <> Automated import from //branches/donutburger/...@140950,140950
inker.c
1dc9e472e19acfe6dc7f41e429236e7eef7ceda1 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
ndroid.mk
ODULE_LICENSE_APACHE2
OTICE
rch/arm/begin.S
rch/x86/begin.S
a.c
a.h
ebugger.c
lfcn.c
inker.c
inker.h
inker_debug.h
t.c
1767f908af327fa388b1c66883760ad851267013 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
ndroid.mk
ODULE_LICENSE_APACHE2
OTICE
rch/arm/begin.S
rch/x86/begin.S
ebugger.c
lfcn.c
inker.c
inker.h
inker_debug.h
t.c
a799b53f10e5a6fd51fef4436cfb7ec99836a516 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@132589
ndroid.mk
a.c
a.h
inker.c
inker.h
inker_debug.h
fe5745033a4f397c62a4e00efd9257ac9f83755c 03-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@137055
ndroid.mk
a.c
a.h
inker.c
inker.h
inker_debug.h
6f04a0f4c72acff80dad04828cb69ef67fa609d1 19-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@132276
inker.c
9f65adf2ba3bb15feb8b7a7b3eef788df3fd270e 11-Feb-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@130745
rch/arm/begin.S
rch/x86/begin.S
ebugger.c
inker.c
inker.h
inker_debug.h
t.c
e5cc1f386b167b9f7bfdebc7219e89aa9b71e4b2 16-Jan-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //branches/cupcake/...@126645
ndroid.mk
inker.c
4e468ed2eb86a2406e14f1eca82072ee501d05fd 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
ebugger.c
inker.c
inker_debug.h
a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
ndroid.mk
ODULE_LICENSE_APACHE2
OTICE
rch/arm/begin.S
rch/x86/begin.S
ebugger.c
lfcn.c
inker.c
inker.h
inker_debug.h
t.c