Commit graph

1094 commits

Author SHA1 Message Date
Justin Yun
53ce74288c Use ld.config.$VER.txt when current VNDK version is $VER
When ro.vndk.version is set to a specific version, not "current",
use ld.config.$VER.txt as a linker namespace configuration file,
where $VER is the VNDK version set by ro.vndk.version.

Because ro.vndk.version is set by the vendor partition, the
configuration file will be automatically selected by the VNDK version
of vendor patition.

If ro.vndk.version is current or not set, ld.config.txt will be used
as before.

Bug: 69531793
Test: Build for a Pixel2 device.
  In the out/target/product/<device> directory,
    rename system/etc/ld.config.txt to system/etc/ld.config.27.1.0.txt
    rename system/lib[64]/vndk to system/lib[64]/vndk-27.1.0
    copy system/lib[64]/vndk-sp to system/lib[64]/vndk-sp-27.1.0
    set ro.vndk.version to 27.1.0 in vendor/default.prop
  Build system and vendor images with "make snod" and "make vnod".
  Disble vbmeta using avbtool.
  Flash a device and check boot.

Change-Id: Ic55bb0a741d434e5fa93e109be15df9d9de3f105
2017-12-03 23:26:53 +09:00
Jiyong Park
8b02951135 Allow property += value in ld.config.txt
ld.config.txt currently does not support split line. As the file gets
larger, this limitation makes the file very unreadable. Now, long lines
can be avoided by breaking one line into multiple lines using +=
operator.

ex)

namespace.default.search.paths = /system/${LIB}
namespace.default.search.paths += /system/${LIB}

Delimitor (':' for *.paths and *.shared_libs, and ',' for *.links) is
automatically added.

Bug: 69888716
Test: linker-unit-tests passes

Change-Id: I4b94fd4e7f8a76d59db8d1096c86aa2118e46625
2017-12-01 10:58:10 +09:00
Alin Jerpelea
074a9fd3da linker: add support for odm partition
If libraries are on the odm partition they will fail to load
This patch adds the odm path as a search path for linker.

Test: libraries load from the odm partition
Change-Id: Ia7786e047cc565d74d25c025dacf9266b3763650
Signed-off-by: Alin Jerpelea <alin.jerpelea@son.com>
2017-12-01 06:21:17 +09:00
Elliott Hughes
65ba81b4e8 Merge "Revert "Fix bug with double unload on unsuccessful dlopen""
am: 4eb332439a

Change-Id: I21ba611931b2e5794ef49cae9bcafc8748ebe804
2017-11-29 19:34:10 +00:00
Elliott Hughes
27f1806b90 Revert "Fix bug with double unload on unsuccessful dlopen"
This reverts commit 58554ccb8a.

causes /vendor/bin/qseecomd to hit the new abort:

[    8.983301] c5    603 DEBUG: Abort message: 'soinfo=0x7147894cd0 is not in soinfo_list (double unload?)'

Bug: http://b/69909887
Bug: http://b/69787209
Change-Id: Ied38f797e0a071a1acc5ed41adf1b45e855143c7
2017-11-29 18:48:33 +00:00
Dimitry Ivanov
f1e645c67b Merge "Fix bug with double unload on unsuccessful dlopen"
am: dc89324e93

Change-Id: Ibff72e8a13cdc737d950dc71f2612fc99740109f
2017-11-29 09:37:01 +00:00
dimitry
58554ccb8a Fix bug with double unload on unsuccessful dlopen
In the case of unsuccessful dlopen the failure guard is triggered
for two namespaces which leads to double unload.

Also update soinfo_free to abort in case when linker tries to free same
soinfo for the second time - this makes linker behavior less undefined.

Test: bionic-unit-tests
Bug: http://b/69787209
Change-Id: I886787ee021b050667f967bce7aa2708390886ea
2017-11-28 21:47:01 +01:00
Xin Li
74d57a37cb Merge commit 'e3d21c84af0b8e3244e4c67a873d2a16bfb85034' into HEAD
Change-Id: I09b21c2e27a0dfbef10633b20d8ee7adbedc1597
2017-11-14 13:14:23 -08:00
dimitry
c92ce715c5 Log dlclose calls and library unloads
Bug: http://b/29458203
Bug: http://b/68262627
Test: make && run bionic-unit-tests
Test: set debug.ld.all to dlopen and check the logs
Change-Id: I9a5495843a4145f267cc3a4714294d05b1e1fe90
2017-10-27 15:38:15 +02:00
Dimitry Ivanov
0b1c8be3be Merge "linker: fix error message for inaccessible libs" 2017-10-24 06:44:19 +00:00
Treehugger Robot
8ab16c5da6 Merge "Set search path to ro.vndk.version property" 2017-10-24 01:17:00 +00:00
dimitry
8db36a51ff linker: fix error message for inaccessible libs
Added a test to make sure linker produces correct error message
when user attempts to load a library in a linked namespace and fails.

Bug: http://b/67866190
Bug: http://b/64950640
Bug: http://b/64888291
Test: bionic-unit-test --gtest_filter=dlext*
Change-Id: I5b5c2070d1388eff123118350b2b5c8fc7571a29
2017-10-23 15:14:01 +02:00
Josh Gao
27242c642e Actually correctly call vector::erase after remove_if.
vector::erase(iterator) erases the element that that iterator points
to, vector::erase(iterator a, iterator b) erases the range [a, b), with
a == b being a no-op.

Test: LD_PRELOAD=libc.so sh
Change-Id: I6a85c1cfaa8eb67756cb75d421f332d5c9a43a33
2017-10-20 17:47:29 -07:00
Sundong Ahn
8fc5032ed2 Set search path to ro.vndk.version property
The permitted and search paths should be changed according to VNDK
version for VNDK snapshot. So, {VNDK_VER} value is added in ld.config.txt
file and this value is set through the linker.
If ro.vndk.version is not set, search paths are vndk and vndk-sp as
before.

Bug: 66074376
Test: build & run
Change-Id: I266b66fe1bc95d8925053ef497db11ac0a57c082
2017-10-20 13:41:14 +09:00
Treehugger Robot
9f69fc714a Merge "Correctly call vector::erase after std::remove_if." 2017-10-20 02:29:58 +00:00
Jiyong Park
01162f2469 Fix: linker segfault on dlopen of a DF_1_GLOBAL so
Added the missing null check routine.

Bug: 67755729
Test: dlfcn.dlopen_df_1_global added and it passes
Change-Id: Ibe8db18b0b5a481e2e9937041abef6d6b179dd87
2017-10-19 15:13:54 +09:00
Josh Gao
44f6e189d9 Correctly call vector::erase after std::remove_if.
std::remove_if moves removed elements to the end, without actually
resizing the collection. To do so, you have to call erase on its
returned iterator.

Test: mma
Change-Id: Iae7f2f194166408f2b101d0c1cfc95202d8bbe63
2017-10-18 17:29:39 -07:00
Christopher Ferris
68039e5b67 Merge "Force _start to be the top frame for the linker." am: 5f1a8440ad am: 30ed16f7c7
am: c46317416a

Change-Id: I48f4dc665c22f3391c80509b6712ff63cbf76925
2017-10-17 18:06:58 +00:00
Christopher Ferris
aa81761c5e Force _start to be the top frame for the linker.
I noticed that sometimes the old unwinder will add an extra PC 0 frame
after this change, but the new unwinder works in all cases. I'm not going
to fix the old unwinder since I plan to remove it very soon.

Bug: 67784501

Test: Forced a crash in the linker and verified that the unwind
Test: stops in __dl_start. Tested on arm/aarch64/x86/x86_64.

Change-Id: Id6585768023256be5c1d341df7b06b786a220b40
2017-10-16 14:43:34 -07:00
Elliott Hughes
1f62be3dcf Merge "Fix mip64 build." am: 92b0f36acc am: 7d8623a4d6
am: c67348fa04

Change-Id: I21b1005762e2b0bb8342f117dbe75d6d5d0b9ea5
2017-10-15 04:28:02 +00:00
Goran Ferenc
1622b1c5fa Merge "MIPS: Fix MIPS linker VDSO issues" am: 73651cf23f am: 76c07c50af
am: ce67915364

Change-Id: If352ae2e944de5e67ce32192fd96f93a2cd0b9a0
2017-10-15 04:26:57 +00:00
Elliott Hughes
ab413c535c Fix mip64 build.
Fallout from the unified sysroot work.

Bug: N/A
Test: builds
Change-Id: If0595a241b9ce0d8c8c7137ddaf8fca932487b7c
2017-10-13 13:22:24 -07:00
Goran Ferenc
e8c76b7a30 MIPS: Fix MIPS linker VDSO issues
This patch resolves two issues:
(1) AOSP MIPS linker crash with SIGSEGV while relocating VDSO GOT
(2) Missing of MIPS_ABI_FP_ANY flag while ckecking & adjusting MIPS FP modes

(1): AOSP MIPS linker crash with SIGSEGV while relocating VDSO GOT

During bringup and testing of the kernel VDSO support on the emulator we
encountered an issue where all userspace processes were crashing due to
linker crash with SIGSEGV during VDSO GOT relocation.

The mentioned scenario will trigger SIGSEGV in the linker only if the kernel
code base contains VDSO implementation introduced with the following commits:

a7f4df4 MIPS: VDSO: Add implementations of gettimeofday() and clock_gettime()
c0a9f72 irqchip: irq-mips-gic: Provide function to map GIC user section
ebb5e78 MIPS: Initial implementation of a VDSO

Another prerequisite is that the linker contains the following commit from AOSP:
https://android-review.googlesource.com/#/c/264857/

The above commit introduces auxvec.h header containing definition of
AT_SYSINFO_EHDR in:
https://android.googlesource.com/platform/bionic/+/master/libc/kernel/uapi/asm-mips/asm/auxvec.h,
which in turn activates VDSO GOT relocations in mips_relocate_got():
https://android.googlesource.com/platform/bionic/+/master/linker/linker_mips.cpp#149

Since VDSO is mapped as a RO region, writing anything to its page will result
in SIGSEGV.

Removing this 0xdeadbeef cookies writes to the got[0]/got[1] solved SIGSEGV issue.
We also compared with the glibc linker code and we haven't seen anything similar
like writing some cookie values into GOT entries.

(2): Missing of MIPS_ABI_FP_ANY flag while checking & adjusting MIPS FP modes

This issue was found during testing of the patch:
https://android-review.googlesource.com/#/c/platform/bionic/+/494440/

This patch adds a bionic dlfcn.dlopen_vdso test which tries to open "linux-vdso.so.1"
(virtual ELF shared library) and expects to succeed.

dlopen fails in the mips linker part due to the following error:
"Unsupported MIPS32 FloatPt ABI 0 found in linux.vdso.so.1"

According to:
https://dmz-portal.imgtec.com/wiki/MIPS_O32_ABI_-_FR0_and_FR1_Interlinking#A.2._O32_FPXX_code_calling_FPXX,
ABI 0 is:
Val_GNU_MIPS_ABI_FP_ANY = 0 /* Not tagged or not using any ABIs affected by the differences.  */

The issue appeared because MIPS_ABI_FP_ANY is not supposed to be checked as
a possible FP ABI-variant compatibility flag.

This patch adds logic to MIPS linker to handle this case appropriately,
after which dlfcn.dlopen_vdso test passes.

Test:
* bionic-unit-tests --gtest_filter=dlfcn.dlopen_vdso
* Boot android in emulator with kernel which supports VDSO optimizations

Change-Id: Icbcd9879beea1b38fbe8d97b3b205058eaa861f4
Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
2017-10-13 12:08:30 +02:00
Dan Albert
9db212cda3 Merge "Add missing includes." am: 36f7b8b789 am: 19ecbbd6a1
am: b4b0e42c0d

Change-Id: Ib0c31b5e29cf2b78e3e5f68bd82318ba570236a3
2017-10-11 21:02:21 +00:00
Dan Albert
1c78cb0fee Add missing includes.
Test: mma
Bug: None
Change-Id: I0221b213e08d07cc5ac0b704a86e98ae8c0f456f
2017-10-11 11:25:52 -07:00
Jiyong Park
1a524d6248 Revert "linker: disable ld.config.txt in ASAN mode"
This reverts commit 81b175747d.

Reason: 02586a2a34 fixed the bug that
prevented us from using LD_PRELOAD with multiple namespaces.

Bug: 38114603
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

(cherry picked from commit 6ab40bbf53)

Merged-In: I25a05927ffbb28b9fa72303652893f43918ccec6
Change-Id: If264f0ce5d7187816d3acc790b6e31d479b628ee
2017-10-04 07:32:28 +09:00
Dan Willemsen
3491d65b3f Merge "Rename target.linux[_x86[_64]] to target.linux_glibc[_x86[_64]]" am: c6021960a4 am: 735fef090d
am: c423d7afec

Change-Id: Ibb8b2bbc1fa73c44313ec52e996a7f10de152029
2017-10-03 03:28:54 +00: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
dfbff07c92 Merge "Use -Werror in bionic" am: 9385d778fd am: 7887421aed
am: a4fcd22ffd

Change-Id: I40302d02f9f70c2d020d029336c4c73816636de8
2017-10-02 22:28:38 +00:00
Treehugger Robot
9385d778fd Merge "Use -Werror in bionic" 2017-10-02 22:04:48 +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
dimitry
0de4982099 Merge "Replace abort with exit(1) in __linker_cannot_link" am: 95f90784ea am: 2161b032e0
am: 4eae0fc50a

Change-Id: I3ffe725ed2977cb211ba96d02dca03e7d4046547
2017-09-29 20:05:17 +00:00
dimitry
04f7a798cf Replace abort with exit(1) in __linker_cannot_link
Bug: http://b/67038409
Test: bionic-unit-tests
Change-Id: I7d39b44f2da8c5111ac8a9faf3416f19d5a35c05
2017-09-29 19:48:46 +02:00
dimitry
df775eda92 Merge "Link vdso before linking the main executable" am: 62767bc31d am: 348161ed3c
am: ce97d243f1

Change-Id: Ic65207315cd9cb03d77f305428d73d6cb0936bac
2017-09-26 17:20:29 +00:00
dimitry
c18de1bd47 Link vdso before linking the main executable
Also set linked flag after it is linked and
call constructors. Set RTLD_NODELETE flag to
prevent accidental unloads.

Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Test: bionic-unit-tests-glibc --gtest_filter=dl*
Change-Id: Ib2178849b918cbefd6f8fcfe6d1f78889fe0bf76
2017-09-26 14:34:18 +02:00
Jiyong Park
93b277a6d2 Merge "Don't resolve permitted.paths" into oc-mr1-dev
am: 52cd1e7a42

Change-Id: I249a82481761739704fc236a25642ef6204c084b
2017-09-22 02:38:38 +00:00
Jiyong Park
0f33f23a76 Don't resolve permitted.paths
Linker resolves the paths in /system/etc/ld.config.txt to canonicalize
the paths and to ensure they exist. However, as permitted paths for the
default namespace contain directories such as /vendor/app, /mnt/expand,
and etc., the resolving causes selinux denial on some processes which do
not have access to some of the permitted paths.

In order to silence the bogus selinux denial, resolution is skipped for
permitted paths.

Note that the resolution is not strictly required especially for
Treble-ized devices where permitted paths are already canonicalized (i.e
/vendor isn't a symlink to /system/vendor).

Bug: 65843095
Test: no selinux denial on /vendor/app, /vendor/framework, etc. while
booting.

Merged-In: I1a9921e45f4c15b08cdf8f1caee64c4cb0761e1f
Change-Id: I1a9921e45f4c15b08cdf8f1caee64c4cb0761e1f
(cherry picked from commit 527757e16b)
2017-09-22 11:34:43 +09:00
Jiyong Park
527757e16b Don't resolve permitted.paths
Linker resolves the paths in /system/etc/ld.config.txt to canonicalize
the paths and to ensure they exist. However, as permitted paths for the
default namespace contain directories such as /vendor/app, /mnt/expand,
and etc., the resolving causes selinux denial on some processes which do
not have access to some of the permitted paths.

In order to silence the bogus selinux denial, resolution is skipped for
permitted paths.

Note that the resolution is not strictly required especially for
Treble-ized devices where permitted paths are already canonicalized (i.e
/vendor isn't a symlink to /system/vendor).

Bug: 65843095
Test: no selinux denial on /vendor/app, /vendor/framework, etc. while
booting.

Change-Id: I1a9921e45f4c15b08cdf8f1caee64c4cb0761e1f
2017-09-21 11:48:06 +09:00
Dan Willemsen
39b65475d9 Merge changes from topic "host_bionic" am: 6e6e1abb89 am: 9938cdeee8
am: 23ec4fd7e6

Change-Id: Ieb803f66f1f0f7bd29fea16df7e48f3c0195e3bf
2017-09-21 00:56:16 +00:00
Dan Willemsen
60b8ad3b86 linker: Only link to debuggerd on Android am: 4326d84d21 am: 7e78df9a62
am: b4a71637e2

Change-Id: I6fb98a3ea925f363431bf85f6afcbe5c8a41f030
2017-09-21 00:56:11 +00: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
Elliott Hughes
f810219ce7 Merge "Always log errno when aborting." am: 0c9ea17e0c am: 002b30843b
am: 5d1cf56ce5

Change-Id: I1999c656307aea0a0a0372248d65a05657546e59
2017-09-18 21:44:57 +00:00
Elliott Hughes
7b0af7ad82 Always log errno when aborting.
(Where errno is relevant.)

Also consistently use -1 as the fd for anonymous mmaps. (It doesn't matter,
but it's more common, and potentially more intention-revealing.)

Bug: http://b/65608572
Test: ran tests
Change-Id: Ie9a207632d8242f42086ba3ca862519014c3c102
2017-09-15 16:18:49 -07:00
Elliott Hughes
4fde457022 Merge "Explicitly name DT_RPATH." am: e0e2798f11 am: e68ca24650
am: 1b64c2c4f0

Change-Id: I59b094b9a1c76d77f01f8a25102b3e0a6dc6f257
2017-08-30 20:03:08 +00:00
Elliott Hughes
6eae4cc57b Explicitly name DT_RPATH.
The specific case of finding a DT_RPATH entry is a pretty common harmless
warning. An alternative to this change would be to just add a case to the
switch for DT_RPATH to just silently ignore it, since it's never been
supported and is deprecated anyway.

Bug: N/A
Test: builds
Change-Id: I01986da8f1f8d411fc2ea32d492c53b9f4488c72
2017-08-30 09:02:33 -07:00
Dimitry Ivanov
cd13aabe45 Merge changes from topic "version-script-for-binaries" am: 0d5d0746e8 am: fcf482294a
am: f612be6f3b

Change-Id: Iab24817b2ba1c0c6bb8011e08e8b5188b17df7f5
2017-08-29 19:15:41 +00:00
dimitry
383e2a86bf Implement __gnu_Unwind_Find_exidx/__cxa_type_match am: 25bf29bbad am: 64403340fe
am: 4a980dc27e

Change-Id: I289496536f4d1f3e1f8a7ed064a2345f00036486
2017-08-29 19:15:36 +00: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
Dimitry Ivanov
5050503a5a Merge "Add support of architecture specific ld.configs" am: 506f3f11f1 am: bfec477beb
am: 595ac73b12

Change-Id: Id5e8ddaf0b6cbabf3973fa5601e0531e6d7739a0
2017-08-24 09:50:23 +00:00
dimitry
fe1b27cf84 Add support of architecture specific ld.configs
Prefer architecture specific ld.config.<arch>.txt if it exists;
fall back to default ld.config.txt files if arch-specific one is
not present.

Bug: http://b/64061157
Test: bionic-unit-tests && linker-unit-tests
Change-Id: I83a298a932f2e4af7acb2049a7641fb86908736c
2017-08-23 10:47:07 +02:00
Justin Yun
6cd3989598 Make default namespace handle the 'visible' flag.
'visible' flag was interpreted only the namespaces other than 'default'.
The flag has to be handled without exception once it is set.

Bug: 63411330
Test: Build and boot without errors.
Test: Add `namespace.default.visible = true` to [vendor] process in
      'ld.config.txt' and reboot the device.

Merged-In: Ia363dfadf0200317b875e26bb4b2fae849af1384
Change-Id: Ia363dfadf0200317b875e26bb4b2fae849af1384
(cherry picked from commit 90de9f081e)
2017-08-17 10:12:51 +09:00
Justin Yun
3396d1616f Merge "Make default namespace handle the 'visible' flag." am: f2c203f188 am: 01a2910758 am: 897b6dabef
am: 07cdf5e9a6

Change-Id: Ib56be3f3b4ad716dc023be3cfec531afe29246bb
2017-08-16 17:58:18 +00:00
Justin Yun
01a2910758 Merge "Make default namespace handle the 'visible' flag."
am: f2c203f188

Change-Id: Ia95b8d4179265d49ab51cd0dee57f52919e4f549
2017-08-16 17:18:42 +00:00
Justin Yun
90de9f081e Make default namespace handle the 'visible' flag.
'visible' flag was interpreted only the namespaces other than 'default'.
The flag has to be handled without exception once it is set.

Bug: 63411330
Test: Build and boot without errors.
Test: Add `namespace.default.visible = true` to [vendor] process in
      'ld.config.txt' and reboot the device.

Change-Id: Ia363dfadf0200317b875e26bb4b2fae849af1384
2017-08-16 14:38:07 +09:00
Jiyong Park
150452f0f6 Revert "linker: disable ld.config.txt in ASAN mode"
am: f1e5dbd1cc

Change-Id: I6db4ffcb76bc928409cfb560d3bc68db236234f1
2017-08-04 20:27:15 +00:00
Jiyong Park
f1e5dbd1cc Revert "linker: disable ld.config.txt in ASAN mode"
This reverts commit 81b175747d.

Reason: 02586a2a34 fixed the bug that
prevented us from using LD_PRELOAD with multiple namespaces.

Bug: 38114603
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

Merged-In: I25a05927ffbb28b9fa72303652893f43918ccec6
Change-Id: Ib7568d65c2524fd2307d01eb3d50fc308feced9c
(cherry picked from commit 6ab40bbf53)
2017-08-04 14:15:20 +09:00
Jiyong Park
34a4acd801 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

Merged-In: I9a03591053f4a9caea82f0dcb23e7a3d324bb9bd
Change-Id: I9a03591053f4a9caea82f0dcb23e7a3d324bb9bd
(cherry picked from commit 02586a2a34)
2017-08-04 14:14:09 +09:00
Jiyong Park
d741e5ef43 Merge "linker: the global group is added to all built-in namespaces" am: c9fb66209d am: ec8c79aaa1 am: 0a51b36ad6
am: e247953f1b

Change-Id: I26521ec9cc11b9ee9ce55a61ac2bfe3152a0dd7f
2017-08-03 02:47:38 +00:00
Jiyong Park
ec8c79aaa1 Merge "linker: the global group is added to all built-in namespaces"
am: c9fb66209d

Change-Id: I9c45ba3b6878a9a098634eae4b9cb97360161495
2017-08-03 02:32:37 +00:00
Evgenii Stepanov
91cf283bd4 Merge "Fix asan path translation loading a library twice." into oc-mr1-dev
am: cc28f6ea09

Change-Id: Ib6083f142d7cd07d19234de7e062585c3e2ebcd9
2017-08-02 18:24:19 +00:00
Evgenii Stepanov
cc28f6ea09 Merge "Fix asan path translation loading a library twice." into oc-mr1-dev 2017-08-02 18:11:47 +00: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
Elliott Hughes
f54872e5bf Merge "Clean up linker fatals slightly."
am: 1bac61f09f

Change-Id: Icf7d5b5b0def92ddb60c5c8a5c15e8867e76b2ad
2017-08-01 20:57:43 +00:00
Elliott Hughes
ad2d0380a6 Clean up linker fatals slightly.
Use __linker_cannot_link more consistently, and fix a comment.

Bug: http://b/22798163
Test: ran tests
Change-Id: Id6d868f459997eaa67b8cbbf85b0b0f2749bf43d
2017-08-01 10:06:10 -07:00
Evgenii Stepanov
9e77a6468b Fix asan path translation loading a library twice.
An ASan binary may load a non-ASan library from /system if /data is not mounted yet.
A dlopen() call for the same library later, when /data/ is available, will translate the path and attempt to load
an ASan copy of the library from /data/asan/system. This way we may end up loading both ASan and non-ASan copies of
the library in the same process, which is a very bad thing.

This change adds a check for a loaded library with the non-translated real path before applying path translation.

Bug: 63622872
Test: hide/rename a library in /data/asan; dlopen; restore the library; dlopen; check that the library from /data/asan is NOT loaded.
Change-Id: I17060837f08dc3c665cab803dd89979d88f0a019
2017-07-27 15:02:08 -07:00
Dimitry Ivanov
66479d88d1 Merge "The ifdef check for AT_SYSINFO_EHDR is no longer needed"
am: 9d2d21d636

Change-Id: I00cfa9f85bafb069f3ce029baea71b496e4c9b6e
2017-07-06 15:20:05 +00:00
dimitry
f9abbf6983 The ifdef check for AT_SYSINFO_EHDR is no longer needed
AT_SYSINFO_EHDR is present in all architectures

Test: make
Change-Id: I0f4c115bb48e47ea156e7fca936960f5f10c618e
2017-07-06 12:24:33 +02:00
George Burgess IV
f437c90407 Merge "bionic: fix assorted static analyzer warnings"
am: e202036e03

Change-Id: I88dce02b7f483fb7bc2819406d800d5056c2fc48
2017-06-29 16:34:13 +00:00
George Burgess IV
705910094d bionic: fix assorted static analyzer warnings
Warnings:

bionic/libc/bionic/fts.c:722:5: warning: Null passed to a callee that
requires a non-null 1st parameter

bionic/libc/bionic/sched_cpualloc.c:34:25: warning: Result of 'malloc'
is converted to a pointer of type 'cpu_set_t', which is incompatible
with sizeof operand type 'unsigned long'

bionic/linker/linker_main.cpp:315:7: warning: Access to field 'e_type'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')

bionic/linker/linker_main.cpp:493:66: warning: Access to field 'e_phoff'
results in a dereference of a null pointer (loaded from variable
'elf_hdr')

bionic/linker/linker_main.cpp:90:14: warning: Access to field 'next'
results in a dereference of a null pointer (loaded from variable 'prev')

Bug: None
Test: mma; analyzer warnings are gone. CtsBionicTestCases pass.
Change-Id: I699a60c2c6f64c50b9ea06848a680c98a8abb44a
2017-06-28 15:03:15 -07:00
Jaesung Chung
bfda5770c7 Merge "linker_config_test: allow search paths of systems without a vendor partition" am: b1b7eda11e
am: 12b44daa11

Change-Id: I7ec1a1f6a541cfd951093a63da175f521babcb4d
2017-06-19 00:22:55 +00:00
Jaesung Chung
9d97008a68 linker_config_test: allow search paths of systems without a vendor partition
linker_config#smoke and linker_config.asan_smoke are trying to find
paths under the /vendor directory. If there is no vendor partition,
the real path of them is started with /system/vendor.

This CL allows those paths in the tests by getting the resolved paths
for systems without a vendor partition.

Bug: http://b/62562515
Test: linker_config_test passes without a vendor partition.
Change-Id: Id6d16ef623efd81ab9083c3e819da2ad22a28bf8
2017-06-19 00:12:45 +00:00
Dimitry Ivanov
c3c83d9f4b Merge "Make dl_iterate_phdr return correct name for first entry" am: 533cf06474 am: 1e55a0420e
am: c27ac0df9b

Change-Id: Ida956645eaf002113587960e931acc570e44c7a3
2017-06-01 07:24:29 +00:00
Dimitry Ivanov
c27ac0df9b Merge "Make dl_iterate_phdr return correct name for first entry" am: 533cf06474
am: 1e55a0420e

Change-Id: I80c1b5f9169c5d7ae7e139d52643fce981c2f7a3
2017-06-01 07:22:28 +00:00
Dimitry Ivanov
cd510cbed9 Make dl_iterate_phdr return correct name for first entry
Test: bionic-unit-tests --gtest_filter=link*
Change-Id: Ib3f1e0fbc76fed9a5f27ffdd9bbf847a3e8d3665
2017-05-31 23:45:15 +00:00
Jiyong Park
08d3f97e7f Merge "linker: disable ld.config.txt in ASAN mode" into oc-dev
am: 41e0ceb5c9

Change-Id: I6e9faedbb26d94aab7064c2c8620362c776143be
2017-05-27 01:50:49 +00:00
Jiyong Park
81b175747d linker: disable ld.config.txt in ASAN mode
Currently, multiple namespaces does not support ASAN mode where some
symbols should be intercepted via LD_PRELOAD; LD_PRELOADed libs are not
preloaded into the linked namespaces other than the default namespace.
Until we fix the problem, we temporarily disable ld.config.txt in ASAN
mode.

Bug: 38114603
Test: 1. ./external/compiler-rt/lib/asan/scripts/asan_device_setup --lib
prebuilts/clang/host/linux-x86/clang-stable/lib64/clang/3.8/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: I091874dd36b36f56dff2ad899d76ff86931909ed
2017-05-27 08:40:12 +09:00
Elliott Hughes
f14633f708 Merge "Remove obsolete __stack_chk_fail_local." am: 6c01208e90 am: c80d8405da
am: a6c583f3bb

Change-Id: I2da57be8f2028ccf540d8fb8c637e89817a89242
2017-05-24 15:15:48 +00:00
Elliott Hughes
a6c583f3bb Merge "Remove obsolete __stack_chk_fail_local." am: 6c01208e90
am: c80d8405da

Change-Id: I7f98e7bf679fab61e7d48893a059c2ce75691f13
2017-05-24 15:13:19 +00:00
Elliott Hughes
4af220cfef Remove obsolete __stack_chk_fail_local.
Clang doesn't use this.

Bug: N/A
Test: x86 emulator builds and boots
Change-Id: I2865c0d568a644f61f34bdea539daff5224896bc
2017-05-23 16:43:30 -07:00
Dimitry Ivanov
fa6ebae9d9 Merge "Revert "linker: remove link from external library on unload"" into oc-dev
am: f80b2bae2f

Change-Id: Id7e4908181fb869de30676fc5c5e6abe3d24d383
2017-05-18 16:33:57 +00:00
Dimitry Ivanov
ec5ddc0a23 Revert "linker: remove link from external library on unload"
This reverts commit b37d10cc80.

Was merged from nyc-dev to master and oc-dev by mistake.

Bug: http://b/38384727
Test: bionic-unit-tests
Change-Id: I7cd352baceb3180342abb6ffec1dfa96a217961f
2017-05-18 01:02:54 +00:00
Dimitry Ivanov
5ef13ba0ca linker: remove link from external library on unload am: b37d10cc80 am: 3a644889b2 am: cb40eec87c am: 0399816edb
am: 85efd3b591

Change-Id: I115a7adb07feedf81064c0e740cfc617263eb689
2017-05-16 22:21:23 +00:00
Dimitry Ivanov
efbc04475e linker: remove link from external library on unload am: b37d10cc80 am: 3a644889b2 am: cb40eec87c am: 0399816edb
am: 85efd3b591

Change-Id: I0b41cdffdccab8b79a4d9c6327dc0f6f521c1acf
2017-05-16 22:21:22 +00:00
Dimitry Ivanov
cb40eec87c linker: remove link from external library on unload am: b37d10cc80
am: 3a644889b2

Change-Id: I7c022194739391c24a736a3a5deb906433fc5649
2017-05-16 22:12:22 +00:00
Dimitry Ivanov
3a644889b2 linker: remove link from external library on unload
am: b37d10cc80

Change-Id: I48901a8fbf4bc25fff1462e6086fc23b76ca2ba3
2017-05-16 22:08:52 +00:00
Dimitry Ivanov
b37d10cc80 linker: remove link from external library on unload
When unloading library make sure the soinfo_link to parent
from linked external libraries is removed as well.

Bug: 36104177
Bug: http://b/37433850
Test: manual
Change-Id: I601b54144acecac54744805b38313c46045c54cb
(cherry picked from commit ee398f820700de30941fd82e38bd917e1513cbc6)
2017-05-15 21:23:32 -07:00
Jiyong Park
37b91af0f3 greylist is no longer enabled by default.
greylist is needed only for application namepaces. Since we started using
linker-namesapces for vendors and other platform apps linker should not
enable greylist workaround by default.

Bug: http://b/37731053
Bug: https://issuetracker.google.com/38146125
Test: sailfish builds and boots
Test: bionic-unit-tests and linker-unit-tests pass
Change-Id: Iee83db6fb1ae754f5ade18491321d9bca3b5ead4
(cherry picked from commit e8ffe56a9c)
2017-05-09 17:59:00 -07:00
Jiyong Park
e8ffe56a9c greylist is no longer enabled by default.
greylist is needed only for application namepaces. Since we started using
linker-namesapces for vendors and other platform apps linker should not
enable greylist workaround by default.

Bug: http://b/37731053
Bug: https://issuetracker.google.com/38146125
Test: sailfish builds and boots
Test: bionic-unit-tests and linker-unit-tests pass
Change-Id: Iee83db6fb1ae754f5ade18491321d9bca3b5ead4
2017-05-08 23:22:16 -07:00
Christopher Ferris
5725481f1e Merge "Move libc_log code into libasync_safe." 2017-05-03 17:43:35 +00: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
Dimitry Ivanov
f1cb669a9c Shared namespaces inherit parent ns properties
Make shared namespace inherit namespace links and
search/permitted paths from the parent namespace.

Bug: http://b/37854032
Test: bionic_unit_tests --gtest_filter=dl*:Dl*
Change-Id: I174661d4a1dd0cbe4a378179073719aa955f3592
(cherry picked from commit ec43dd6c36)
2017-05-02 16:42:28 -07:00
Dimitry Ivanov
ec43dd6c36 Shared namespaces inherit parent ns properties
Make shared namespace inherit namespace links and
search/permitted paths from the parent namespace.

Bug: http://b/37854032
Test: bionic_unit_tests --gtest_filter=dl*:Dl*
Change-Id: I174661d4a1dd0cbe4a378179073719aa955f3592
2017-05-02 11:40:50 -07:00
Treehugger Robot
87a47e1bb2 Merge "linker: add android_get_exported_namespace" 2017-05-02 01:37:04 +00:00
Jiyong Park
01de74e76d linker: add android_get_exported_namespace
Depending on how ld.config.txt is configured, there can be multiple
built-in namespaces created by the linker from the beginning of a
process. android_get_exported_namespace is a platform only API for
getting a handle (android_namespace_t*) to one of the built-in namespaces
with given name. The returned namespace can then be given to
android_dlopen_ext in order to explicitly specify the target namespace
where the library is searched and loaded from.

Note that this function only returns 'exported' namespaces created via
ld.config.txt file. In order to export a namespace, the visible property
should be set to true:

namespace.<name>.visible = true

Namespaces are hidden by default. Hidden namespaces and namespaces
that are created programmatically, notably 'classloader-namespace',
aren't returned by this function.

Bug: 36851137
Test: confirmed that namespaces created with ld.config.txt is retrieved.
Test: linker-unit-tests passes
Merged-in: I714b510fa24f77e42c3dfc4c827b3befa8bb2951
Change-Id: I0d05fa7e0e116009edf8ea362ab46774bc617cbf
(cherry picked from commit d7c4832e6a)
2017-04-28 10:14:28 +09:00
Dimitry Ivanov
15f1db35fa Revert "Revert "loader: enable loading libraries from tmpfs""
This reverts commit 6d59318d78.

Bug: http://b/37245203
Bug: http://b/37590327
Test: bionic-unit-tests on angler and marlin
Test: boot an angler and make sure mediacodec does not crash
2017-04-24 13:35:41 -07:00
Yin-Chia Yeh
6d59318d78 Revert "loader: enable loading libraries from tmpfs"
This reverts commit bb8b22a087.

http://b/37245203
http://b/37590327
Change-Id: I36f45697f7478b830947d641942e453ed0d5466e
2017-04-22 23:55:41 +00:00
Dimitry Ivanov
bf34ba3641 loader: enable loading libraries from tmpfs
This change adds two tests for dlopen from temporary files.
1. One Uses memfd_create() can be used to load libraries directly
from memory. This requires relaxing namespace accessibility check
in order to make this work in isolated namespaces.
2. Another checks that open with O_TMPFILE works.

Bug: http://b/37245203
Test: bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: I3be1d7198ca17e7f1ba022a0d86c64d59a493506
(cherry picked from commit bb8b22a087)
2017-04-21 14:45:07 -07:00