Commit graph

72 commits

Author SHA1 Message Date
Ryan Prichard
d9a4115273 Cleanup linker unwinder integration
The linker shouldn't throw exceptions, but because it links with
libc++_static.a, there are code paths that could throw an exception. On
those code paths, the unwinder needs to lookup EH information for the
linker binary, and the linker had two inconsistent ways of doing this:

 * dl_iterate_phdr (for libgcc): dlfcn.cpp defined a linker-internal
   version of this API that forwarded to __loader_dl_iterate_phdr

 * __gnu_Unwind_Find_exidx (for arm32 libgcc): linker_exidx_static.c was
   an old, broken copy of exidx_static.c that used
   __exidx_start/__exidx_end symbols. (The file should have used the
   addresses of the symbols rather than their contents.)

The linker's data structures might be in an inconsistent state at a point
where exceptions are thrown, so it seems better to limit its unwinder to
just the linker binary's EH info. Rather than forward the dl* EH APIs,
link in the static-binary versions from libc_unwind_static.a. That library
is already part of libc_nomalloc.a, but include it directly with
whole_static_libs so that __gnu_Unwind_Find_exidx is defined when we're
using libgcc on arm32.

Try to link in libunwind_llvm.a into the arm32 linker binary so we're
using the same unwinder as normal arm32 binaries. I'm not sure the library
will appear in the right order, but maybe it doesn't matter given LLD's
unconventional archive linking semantics.

Test: bionic unit tests
Test: "readelf --dyn-syms linker" reports no UNDEF symbols
Test: "readelf -r linker" reports only relative relocations
Bug: none
Change-Id: I5982ec830ba0f15d066536de24f6cd7e9503498b
Merged-In: I5982ec830ba0f15d066536de24f6cd7e9503498b
2019-10-16 04:20:23 +00:00
Jiyong Park
e87e0dcbae Restrict the availability of the bionic libs
The bionic libs are now restricted to be in the runtime APEX and the
platform (for bootstrapping). It can still be referenced from other
APEXes but can't be included there.

Bug: 139870423
Test: m
Change-Id: I7f99eef27ccf75844ca5c9a7ea866496841b738f
2019-10-07 13:52:32 +09:00
Treehugger Robot
74e56438bb Merge "Link libc++demangle." 2019-08-21 23:54:48 +00:00
Tom Cherry
cd70aa47d2 linker: Remove setting _USING_LIBCXX
As of aosp/1086558, stdatomic.h directly checks for the presence of
<atomic> instead of checking _USING_LIBCXX, so these lines are
obsolete.

Test: build
Change-Id: Icfdb47b3ad109421b3413041f3d3027e2c0b518e
2019-08-05 14:36:46 -07:00
Dan Albert
4ea19214a4 Link libc++demangle.
The demangler is moving out of libc++abi to save on bloat.

Test: make checkbuild
Bug: http://b/138245375
Change-Id: I7402894bb326f524388c9efdf86509dad50f2018
2019-07-24 12:16:41 -07:00
Elliott Hughes
90f96b9f48 linker: support ldd(1)-like behavior via --list.
Given that we have both linker and linker64, I didn't really want to have
to have ldd and ldd64, so this change just adds the --list option to the
linkers and a shell script wrapper "ldd" that calls the appropriate
linker behind the scenes.

Test: adb shell linker --list `which app_process32`
Test: adb shell linker64 --list `which date`
Test: adb shell ldd `which app_process32`
Test: adb shell ldd `which date`
Change-Id: I33494bda1cc3cafee54e091f97c0f2ae52d1f74b
2019-05-09 22:12:17 -07:00
Dimitry Ivanov
78e42d81ec Merge "Enable native_bridge_support" 2019-05-07 11:30:58 +00:00
Yi Kong
7ac2afbde3 Exclude libgcc_stripped wherever libgcc is excluded
Test: manual testing
Bug: 130267141
Bug: 29275768
Change-Id: If50420c05d36e6f680a36673e7c26ca7deb93b28
2019-05-06 17:02:53 -07:00
dimitry
7f04880820 Enable native_bridge_support
Enable native bridge support for bionic libraries.
Makes it possible to use them in binaries for translated
architectures.

Bug: http://b/77159578
Test: make
Change-Id: Iccd4ad7aecfa5260cc15f09ca975d2e18987278a
2019-05-06 17:13:51 +02:00
dimitry
afe30a5281 Remove dependency on unused libutils
Test: make
Change-Id: I64f9390c680eeedec7acb8465bfde254b3c96904
2019-04-30 13:01:42 +02:00
Jiyong Park
036e09c36e Don't install *.mountpoint targets
The *.mountpoint targets that installs /bionic/lib/lib*.so and
/bionic/bin/linker* are no longer needed.

Now, /system/lib/lib*.so and /system/bin/linker* are simply symlinks to
the corresponding files in the runtime apex. For example,

/system/lib/libc.so -> /apex/com.android.runtime/lib/bionic/libc.so

This is made possible because we now activate APEXes even before the
data partition is mounted. Before the data partition mounting, the
APEXes from the system partition are ativated. After the data partition
is mounted, updated APEXes in the partition (if any) are activated. As a
result, the symlink always points to the valid path regardless of
whether /data is mounted or not.

Bug: 125549215
Test: device boots
Change-Id: Ie7d83686abe00b3c436f9f9db75d4244200a0fc9
2019-03-14 07:35:52 +09:00
Elliott Hughes
d102cf62d1 Merge "Switch linker tests to Android.bp." 2019-02-16 01:11:56 +00:00
Elliott Hughes
15a2b7b17b Switch linker tests to Android.bp.
Life is easier if we just keep test code in the same directory as the
stuff it's testing...

Test: tests still build and pass
Change-Id: I9b35d689098bdc28a71d69645b0ca9fdd6ea0108
2019-02-15 14:40:08 -08:00
Pirama Arumuga Nainar
fcd35380dd Disable native_coverage for ld-android and linker
Bug: http://b/116873221

The coverage library, which depends on libc, cannot link with libraries
since they opt of libc.

Test: m NATIVE_COVERAGE=true COVERAGE_PATHS=bionic
Change-Id: Iaaca8bc30c8ba59e5d4f7092b1a0fce8e8c14c72
2019-02-14 13:50:55 -08:00
Jiyong Park
fbc4c8edd6 Move the dynamic linker to ./bootstrap subdir
The dynamic linker installed to /system partition is only for
bootstraping, i.e. to be used only by early processes. The existing path
/system/bin/linker[64] will be a symlink to the mount pointpoint
/bionic/bin/linker[64] which will be bind-mounted with either the
bootstrap linker or the default linker in the runtime APEX. Since the
path is taken by the symlink, bootstrap linker is moved to ./boostrap
subdirectory.

Bug: 120266448
Test: m linker; the linker is found under /system/bin/bootstrap/
Change-Id: I163e0c8a1738b94565a6b60f48e65841ba058a91
2019-01-31 13:44:20 +09:00
Jiyong Park
a5f914aef1 Add bionic mount points under /bionic
This change adds following files and symlinks:

Files:
/bionic/lib[64]/lib{c|dl|m}.so
/bionic/bin/linker[64]

Symlinks:
/system/lib[64]/lib{c|dl|m}.so -> /bionic/lib[64]/lib{c|dl|m}.so
/system/bin/linker[64] -> /bionic/bin/linker[64]
/system/bin/linker_asan[64] -> /bionic/bin/linker[64]

The files serve as mount points for either the bootstrap Bionic or the
default Bionic from the runtime APEX. init does the bind-mounting during
booting.

The symlinks are there to not change the ordinary paths to the bionic
files; there are many places that the paths are implied or hard-coded,
e.g., dlopen("/system/lib/libc.so") or DT_INTERP pointing to
/system/bin/linker in the vendor prebuilts.

Bug: 120266448
Test: m blueline, cf_x86, aosp_arm
The aforementioned files and symlinks are found

Change-Id: I97e38c29409ac0610dde285db8df6e94a7930094
2019-01-31 13:44:20 +09:00
Ryan Prichard
ffaae70936 Implement arm64 TLSDESC
Each TLSDESC relocation relocates a 2-word descriptor in the GOT that
contains:
 - the address of a TLS resolver function
 - an argument to pass (indirectly) to the resolver function

(Specifically, the address of the 2-word descriptor is passed to the
resolver.)

The loader resolves R_GENERIC_TLSDESC relocations using one of three
resolver functions that it defines:
 - tlsdesc_resolver_static
 - tlsdesc_resolver_dynamic
 - tlsdesc_resolver_unresolved_weak

The resolver functions are written in assembly because they have a
restrictive calling convention. They're only allowed to modify x0 and
(apparently) the condition codes.

For a relocation to memory in static TLS (i.e. the executable or an solib
loaded initially), the loader uses a simple resolver function,
tlsdesc_resolver_static, that returns the static offset it receives from
the loader.

For relocations to dynamic TLS memory (i.e. memory in a dlopen'ed solib),
the loader uses tlsdesc_resolver_dynamic, which allocates TLS memory on
demand. It inlines the fast path of __tls_get_addr, then falls back to
__tls_get_addr when it needs to allocate memory. The loader handles these
dynamic TLS relocations in two passes:
 - In the first pass, it allocates a table of TlsDynamicResolverArg
   objects, one per dynamic TLSDESC relocation.
 - In the second pass, once the table is finalized, it writes the
   addresses of the TlsDynamicResolverArg objects into the TLSDESC
   relocations.

tlsdesc_resolver_unresolved_weak returns a negated thread pointer so that
taking the address of an unresolved weak TLS symbols produces NULL.

The loader handles R_GENERIC_TLSDESC in a target-independent way, but
only for arm64, because Bionic has only implemented the resolver functions
for arm64.

Bug: http://b/78026329
Test: bionic unit tests
Test: check that backtrace works inside a resolver function and inside
  __tls_get_addr called from a resolver
  (gdbclient.py, b __tls_get_addr, bt)
Merged-In: I752e59ff986292449892c449dad2546e6f0ff7b6
Change-Id: I752e59ff986292449892c449dad2546e6f0ff7b6
2019-01-29 08:33:09 +00:00
Ryan Prichard
083d850b30 Move the linker allocator into libc
Rename LinkerMemoryAllocator -> BionicAllocator
Rename LinkerSmallObjectAllocator -> BionicSmallObjectAllocator

libc and the linker need to share an instance of the allocator for
allocating and freeing dynamic ELF TLS memory (DTVs and segments). The
linker also continues to use this allocator.

Bug: http://b/78026329
Test: /data/nativetest/bionic-unit-tests-static
Test: /data/nativetest64/bionic-unit-tests-static
Test: /data/nativetest/linker-unit-tests/linker-unit-tests32
Test: /data/nativetest64/linker-unit-tests/linker-unit-tests64
Change-Id: I2da037006ddf8041a75f3eba2071a8fcdcc223ce
2019-01-25 15:31:35 -08:00
Jiyong Park
57b9d1e6c0 support LIB in runpath
In addition to ORIGIN, LIB is now expanded to either lib or lib64
depending on the ABI in the DT_RUNPATH.

Test: To be added (can't be added to AOSP directly since there are
internal tests that have to be updated as well)

Change-Id: I34a8316f1765a27c731bc270ee25c0ce287d7eed
2019-01-24 17:00:37 +09:00
Ryan Prichard
9ee8069046 Build the linker with -D_USING_LIBCXX
This macro is necessary for using stdatomic.h and <atomic> in the same
libc++-based program. <atomic> is used implicitly by other STL headers,
and stdatomic.h is used (or will be used) in headers shared with libc.
libc only has access to stdatomic.h because it can't use an STL.

Bug: http://b/78026329
Test: bionic unit tests
Change-Id: I89b128df08b478287ef4e2867319e74dbcc30d4e
2019-01-16 01:11:26 -08:00
Ryan Prichard
45d1349c63 Reorganize static TLS memory for ELF TLS
For ELF TLS "local-exec" accesses, the static linker assumes that an
executable's TLS segment is located at a statically-known offset from the
thread pointer (i.e. "variant 1" for ARM and "variant 2" for x86).
Because these layouts are incompatible, Bionic generally needs to allocate
its TLS slots differently between different architectures.

To allow per-architecture TLS slots:
 - Replace the TLS_SLOT_xxx enumerators with macros. New ARM slots are
   generally negative, while new x86 slots are generally positive.
 - Define a bionic_tcb struct that provides two things:
    - a void* raw_slots_storage[BIONIC_TLS_SLOTS] field
    - an inline accessor function: void*& tls_slot(size_t tpindex);

For ELF TLS, it's necessary to allocate a temporary TCB (i.e. TLS slots),
because the runtime linker doesn't know how large the static TLS area is
until after it has loaded all of the initial solibs.

To accommodate Golang, it's necessary to allocate the pthread keys at a
fixed, small, positive offset from the thread pointer.

This CL moves the pthread keys into bionic_tls, then allocates a single
mapping per thread that looks like so:
 - stack guard
 - stack [omitted for main thread and with pthread_attr_setstack]
 - static TLS:
    - bionic_tcb [exec TLS will either precede or succeed the TCB]
    - bionic_tls [prefixed by the pthread keys]
    - [solib TLS segments will be placed here]
 - guard page

As before, if the new mapping includes a stack, the pthread_internal_t
is allocated on it.

At startup, Bionic allocates a temporary bionic_tcb object on the stack,
then allocates a temporary bionic_tls object using mmap. This mmap is
delayed because the linker can't currently call async_safe_fatal() before
relocating itself.

Later, Bionic allocates a stack-less thread mapping for the main thread,
and copies slots from the temporary TCB to the new TCB.
(See *::copy_from_bootstrap methods.)

Bug: http://b/78026329
Test: bionic unit tests
Test: verify that a Golang app still works
Test: verify that a Golang app crashes if bionic_{tls,tcb} are swapped
Merged-In: I6543063752f4ec8ef6dc9c7f2a06ce2a18fc5af3
Change-Id: I6543063752f4ec8ef6dc9c7f2a06ce2a18fc5af3
(cherry picked from commit 1e660b70da)
2019-01-11 15:34:22 -08:00
Dan Willemsen
6b3be172d6 Prevent dependency cycle due to system_shared_libs expansion
It was discovered that we were building some objects inconsistently due
to an optimization in cc_library to only build objects once and use them
for both the static and shared libraries. But static libraries didn't
get system_shared_libs set automatically, and we didn't notice that we
would have built the objects differently.

So static libraries now get the default system_shared_libs, we allow
adjusting that for static vs shared in a cc_library, and we disable the
optimization if the linked libraries are configured differently between
static and shared in a single cc_library.

This triggers dependency cycles for static libraries that libc/libdl
use, so fix those cycles here.

Test: treehugger
Change-Id: I3cf7fda161a05ec32e0c1e871999720d12a4d38e
2018-12-03 15:41:56 -08:00
Ivan Lozano
f17fd1d68a Disable XOM in linker, libc, and libm.
These modules have issues running with execute-only memory. Disable it
in them until we can resolve the issues.

Bug: 77958880
Test: No more XOM-related crashes in these binaries

Change-Id: Ie6c957731155566c2bbe7dbb7a91b9583d9aff93
2018-11-27 07:56:17 -08:00
Chih-hung Hsieh
bbd465a230 Merge "Revert "Disable lld, failed to link bionic/linker."" 2018-11-08 04:58:14 +00:00
Chih-hung Hsieh
34d1f2ddf2 Revert "Disable lld, failed to link bionic/linker."
This reverts commit 73de62e461.

Reason for revert: bug was fixed upstream and included into AOSP lld
Bug: 78115263
Test: make checkbuild

Change-Id: Ib9e4af1efdcdb547c7bd65cce4ce48d7f09ed217
2018-11-07 21:55:18 +00:00
Elliott Hughes
5e62b34c0d Clean up bionic_macros.h a bit.
Use <android-base/macros.h> instead where possible, and move the bionic
macros out of the way of the libbase ones. Yes, there are folks who manage
to end up with both included at once (thanks OpenGL!), and cleaning that
up doesn't seem nearly as practical as just making this change.

Bug: N/A
Test: builds
Change-Id: I23fc544f39d5addf81dc61471771a5438778895b
2018-10-25 11:00:00 -07:00
Yi Kong
c15baefc0a Merge "Exclude libclang_rt.builtins symbols" 2018-10-04 22:09:55 +00:00
Yi Kong
7786a344ce Exclude libclang_rt.builtins symbols
Similar to libgcc, libclang_rt.builtins symbols need to be excluded.

Bug: 29275768
Change-Id: Iaf7381de3b4dbd92997abd03667dea0baaab98e1
2018-10-03 10:07:13 +00:00
dimitry
b8b3a76606 linker: extract defaults and source files
Move source files to filegroup and extract c/ldflags and
version-script to linker_defaults.

Bug: http://b/71494052
Test: make
Change-Id: Ic82885e1c006f91a8446978fabd214f87cd20510
2018-09-25 16:17:24 +02:00
Evgenii Stepanov
be551f596f HWASan support in bionic.
* Allow sanitization of libc (excluding existing global sanitizers)
  and disallow sanitization of linker. The latter has not been
  necessary before because HWASan is the first sanitizer to support
  static binaries (with the exception of CFI, which is not used
  globally).
* Static binary startup: initialize HWASan shadow very early so that
  almost entire libc can be sanitized. The rest of initialization is
  done in a global constructor; until that is done sanitized code can
  run but can't report errors (will simply crash with SIGTRAP).
* Switch malloc_common from je_*  to __sanitizer_*.
* Call hwasan functions when entering and leaving threads. We can not
  intercept pthread_create when libc depends on libclang_rt.hwasan.
  An alternative to this would be a callback interface like requested
  here:
    https://sourceware.org/glibc/wiki/ThreadPropertiesAPI

All of the above is behind a compile-time check
__has_feature(hwaddress_sanitizer). This means that HWASan actually
requires libc to be instrumented, and would not work otherwise. It's
an implementation choice that greatly reduces complexity of the tool.
Instrumented libc also guarantees that hwasan is present and
initialized in every process, which allows piecemeal sanitization
(i.e. library w/o main executable, or even individual static
libraries), unlike ASan.

Change-Id: If44c46b79b15049d1745ba46ec910ae4f355d19c
2018-08-21 00:15:47 +00:00
Jiyong Park
8d7866c58f Build recovery variant of the dynamic linker
In order to support shared libraries in the recovery mode, the dynamic
linker is now built with recovery_available: true option.

In addition, a few more modules (such as libasync, etc.) are also marked
as recovery_available: true as they are transitive dependencies of the
dynamic linker.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: `adb root && adb shell` and then
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.

Change-Id: Idd981d8cf25568a85b24032cf78e50adfd5f4a7f
2018-06-08 14:49:56 +09:00
Ryan Prichard
7046f391d1 Reenable __work_around_b_24465209__ for x86 linker
Bug: b/80258696
Test: build aosp_x86-userdebug ; run emulator
Change-Id: If7de24c3fc91a143c0bd17c6364c56ec04dfb08e
(cherry picked from commit dac8340c43)
2018-05-24 20:14:56 -07:00
Jiyong Park
5603c6e6b9 Mark as recovery_available: true
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.

Bug: 67916654
Bug: 64960723
Bug: 63673171
Bug: 29921292
Test: m -j
Change-Id: I59bf859a10a218af6591025a0fe7d1853e328405
2018-05-14 18:08:01 +09:00
Chih-Hung Hsieh
73de62e461 Disable lld, failed to link bionic/linker.
* Upstream bug: https://bugs.llvm.org/show_bug.cgi?id=36295

Bug: 78115263
Test: make checkbuild
Change-Id: Id38d90f90ca2e3505a47e40c1a3fe0647e7f3a32
2018-04-16 09:51:50 -07:00
Ryan Prichard
470b66644b Break libdl.so and ld-android.so's dependency on libc.so.
* Specify "nocrt: true" to avoid calling __cxa_finalize.

 * Define a dummy __aeabi_unwind_cpp_pr0 for arm32.

Bug: b/62815515
Bug: b/73873002
Test: boot AOSP hikey960-userdebug
Test: run ndk_cxa_example in special /system/bin/debug namespace
Test: run Bionic unit tests
Change-Id: I59bcb100a2753286b59c51a47d7a183507219a07
2018-03-30 13:56:03 -07:00
Elliott Hughes
4e6bf9e9fa Remove obsolete debuggerd32/debuggerd64 hack.
Bug: N/A
Test: builds
Change-Id: I159eea4e1c0d88e5e51184479ed020e7597390ba
2018-02-16 10:53:03 -08:00
Ryan Prichard
f857d59635 Switch x86 begin.c to asm; align ESP correctly
Every other architecture already uses an assembly file here.

The previous code aligned ESP incorrectly, but it doesn't really matter
because everything is built with Clang's -mstackrealign, which realigns
ESP in every function prologue.

Bug: http://b/73140672#comment4
Test: lunch aosp_x86-eng; m; emulator; device boots
Test: manual
Change-Id: I921fd7848cdc611b4f8f13d1176d1983ffea952d
2018-02-12 21:43:12 -08:00
Elliott Hughes
d50a1de565 Run bpfmt manually.
Bug: N/A
Test: builds
Change-Id: I0cf145c3b699ac8ef170a63366832f63a9cc1a91
2018-02-05 17:30:57 -08:00
dimitry
581723ebc7 Make ld-android.so export linker symbols
ld-android.so exports exact same set of symbols
as linker. Since it is not supposed to be loaded
every symbol points to fail() method.

Test: make
Test: bionic-unit-tests --gtest_filter=dl*
Change-Id: I23bec365b302ce4ddf5f08832e665ae2b181cf8a
2018-01-09 11:27:23 +01:00
dimitry
11da1dcd8c Move ld-android.so build under linker/
This will allow us to apply linker's version script to the "fake"
version of ld-android.so.

Test: make
Change-Id: I55645cc0fc90e6c65e2269ba2340a908aeed1eaa
2018-01-09 11:13:40 +01:00
dimitry
8e8c2c0013 Unhardcode linker soname
Set and use DT_SONAME instead.

Test: bionic-unit-tests
Change-Id: I38a246c8a43664792424e8fef96ae2ff5f743ba6
2018-01-09 11:11:46 +01:00
Dan Willemsen
c6021960a4 Merge "Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]" 2017-10-03 02:30:05 +00:00
Chih-Hung Hsieh
84f0dcd59e Use -Werror in bionic
Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: Ic68141a5c50880c485646e38349f94b866267bd9
2017-10-02 13:21:22 -07:00
Dan Willemsen
3a3982d779 Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]
In the future, target.linux will apply to all targets running a linux kernel
(android, linux_glibc, linux_bionic). So move all current users to the specific
linux_glibc.

There will be another cleanup pass later that will move some instances back to
target.linux if the properties should be shared with target.android and
target.linux_bionic, but target.linux needs to be removed first.

Test: out/soong/build.ninja identical before/after
Change-Id: I56c84d206fb1e98cd7ea0d8fb875de0ebd87ea5e
Exempt-From-Owner-Approval: build system cleanup
2017-10-02 10:41:07 -07:00
Dan Willemsen
7ccc50d2e4 Use an embedded linker for host bionic
The linux kernel requires that the ELF interpreter (runtime linker)
that's referenced by PT_INTERP be either an absolute path, or a relative
path from the current working directory. We'd prefer a relative path
from the binary, similarly to how we handle looking up shared libraries,
but that's not supported.

Instead, extract the LOAD segments from the runtime linker ELF binary
and embed them into each host bionic binary, omitting the PT_INTERP
declaration. The kernel will treat it as a static binary, and we'll use
a special entry point (linker_wrapper) to fix up the arguments passed by
the kernel before jumping to the embedded linker. From the linker's
point of view, it looks like the kernel loaded the linker like normal.

Bug: 31559095
Test: Enable host bionic, build and run libdemangle_test
Change-Id: I1753401ef91eecbf0ae3376faca31eec1c53842b
2017-09-20 13:59:13 -07:00
Dan Willemsen
4326d84d21 linker: Only link to debuggerd on Android
Don't link to it when building with bionic for the host.

Also add libasync_safe, which is used by linker_globals.h even when
debuggerd isn't used.

Bug: 31559095
Test: mma
Test: Attempt to build host bionic
Change-Id: I374e2c2c288133875da82de780b27917ca524240
2017-09-20 13:16:13 -07:00
dimitry
7abea57ba5 Replace artificial symbol table with proper one
This change also replaces elf-hash with gnu-hash.

Test: make
Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: Ibc4026f7abc7e8002f69c33eebaf6a193f1d22eb
2017-08-29 18:18:28 +02:00
dimitry
25bf29bbad Implement __gnu_Unwind_Find_exidx/__cxa_type_match
Leaving these unimplemented causes linker to have 2 weak undefined
symbols which in turn results in 3 unwanted relocations for arm arch.
Implementing them removes unwanted relocations from resulted dynamic
object

Test: make && readelf --dyn-sym linker
Test: linker-unit-tests && bionic-unit-tests --gtest_filter=dl*:Dl*
Test: flash and boot angler
Change-Id: I10120271936c770659239898aaf852d31c5483c2
2017-08-29 18:18:27 +02:00
Jiyong Park
02586a2a34 linker: the global group is added to all built-in namespaces
With ld.config.txt, we now have multiple built-in namespaces other than
the default namespace. Libs (and their dependents) listed in LD_PRELOAD
must be visible to those additional namespaces as well.

This also adds a debugging only feature: path to the linker config file
can be customized via LD_CONFIG_FILE environment variable. This works
only for debuggable builds.

Bug: 38114603
Bug: 62815515
Test: 1. ./external/compiler-rt/lib/asan/scripts/asan_device_setup --lib
prebuilts/clang/host/linux-x86/clang-stable/lib64/clang/5.0/lib/linux
2. enable talkback shortcut
3. in the home screen, hold vol-up/down together
4. device does not reboots and talkback shortcut is toggled
Test: bionic-unit-tests and linker-unit-tests successful

Change-Id: I9a03591053f4a9caea82f0dcb23e7a3d324bb9bd
2017-08-03 01:02:07 +09:00
Christopher Ferris
7a3681e5b6 Move libc_log code into libasync_safe.
This library is used by a number of different libraries in the system.
Make it easy for platform libraries to use this library and create
an actual exported include file.

Change the names of the functions to reflect the new name of the library.

Run clang_format on the async_safe_log.cpp file since the formatting is
all over the place.

Bug: 31919199

Test: Compiled for angler/bullhead, and booted.
Test: Ran bionic unit tests.
Test: Ran the malloc debug tests.
Change-Id: I8071bf690c17b0ea3bc8dc5749cdd5b6ad58478a
2017-05-03 08:50:43 -07:00