aboutsummaryrefslogtreecommitdiff
path: root/linker/linker_utils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Don't resolve already resolved paths when parsing ld.config.txtJiyong Park2019-05-171-35/+42
| | | | | | | | | | | | | | | | | | | When parsing ld.config.txt, paths in *.search.paths properties are resolved using resolved_paths(). This is causing a number of newfstatat system calls during a process start-up and is contributing about 3.6% of the entire linker initialization time. Optimize the overhead by not resolving already resolved paths; resolved paths are cached. Bug: 132348336 Test: strace -C -e newfstatat ls shows the number of the syscalls is reduced from 131 to 99 Test: simpleperf record --call-graph fp -f 10000000 -o /data/perf.data ls simpleperf report -g -i /data/perf.data shows percentage of get_paths() from 2.9% to 2.5% Change-Id: I79823255a89f6e2a63b80c74e6768850276ab536
* Merge "linker: changes to init work arounds"Tom Cherry2018-11-291-2/+2
|\
| * linker: changes to init work aroundsTom Cherry2018-11-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change three things regarding the work around to the fact that init is special: 1) Only first stage init is special, so we change the check to include accessing /proc/self/exe, which if is available, means that we're not first stage init and do not need any work arounds. 2) Fix the fact that /init may be a symlink and may need readlink() 3) Suppress errors from realpath_fd() since these are expected to fail due to /proc not being mounted. Bug: 80395578 Test: sailfish boots without the audit generated from calling stat() on /init and without the errors from realpath_fd() Change-Id: I266f1486b142cb9a41ec791eba74122bdf38cf12
* | Fix: search path is not added when one of its parent is not accessibleJiyong Park2018-11-161-0/+7
|/ | | | | | | | | | | | | | When /foo/bar/baz is added to the search paths and if getattr (stat()) is not allowed on one of its parent paths, i.e., /foo and /foo/baz, the path was thought as non-existent and wasn't added to the search paths of the namespace. Fixing the bug by adding the path if the path (though not the parents) does exist. Bug: 119656753 Test: m apex.test; m; device boots. Change-Id: I21bca1fee9aa20688ce9b72192d3173821ad91a3
* Fix normalize_path's handling of "/.."Ryan Prichard2018-10-081-2/+2
| | | | | | | | | | Currently it normalizes the path to a string with a single uninitialized byte. It should instead normalize it to "/". Bug: none Test: /data/nativetest/linker-unit-tests/linker-unit-tests32 Test: /data/nativetest64/linker-unit-tests/linker-unit-tests64 Change-Id: I06e0f7598d16acfa21875dad53efbc293cfeb44d
* dynamic linker is running for initJiyong Park2018-06-081-0/+5
| | | | | | | | | | | | | | | | | init is now built as a dynamic executable, so the dynamic linker has to be able to run in the init process. However, since init is launched so early, even /dev/* and /proc/* file systems are not mounted and thus some APIs that rely on the paths do not work. The dynamic linker now goes alternative path when it is running in the init process. For example, /proc/self/exe is not read for the init since we always now the path of the init (/init). Also, arc4random* APIs are not used since the APIs rely on /dev/urandom. Linker now does not randomize library loading order and addresses when running in the init process. Bug: 80454183 Test: `adb reboot recovery; adb devices` shows the device ID Change-Id: I29b6d70e4df5f7f690876126d5fe81258c1d3115
* Be clearer about linker warnings.Elliott Hughes2018-02-281-16/+12
| | | | | | | | | | | | Explicitly say "warning" for warnings, explicitly say what action we're going to take (such as "(ignoring)"), always provide a link to our documentation when there is one, explicitly say what API level the behavior changes at, and explicitly say why we're allowing the misbehavior for now. Bug: http://b/71852862 Test: ran tests, looked at logcat Change-Id: I1795a5af45deb904332b866d7d666690dae4340b
* Extract format_string function.Dimitry Ivanov2017-03-131-0/+24
| | | | | | | Extract format_string function and add a test. Test: run linker-unit-tests Change-Id: I794a29aaf62e184438ce1a9224b88aa0586c17b5
* Unify linker files under one license (BSD)Dimitry Ivanov2017-02-151-10/+22
| | | | | | | | | Historically we had part of the linker licensed under BSD and another part under Apache 2 license. This commit makes all the linker code licensed under BSD license. Test: m Change-Id: I11b8163ae75966b5768d3fe992679de376106515
* Silently ignore empty path elementsDimitry Ivanov2016-09-071-0/+5
| | | | | | | | | | | resolve_paths function used to print a warning if an input path was empty. This commit fixes this by explicitly skipping empty paths during path resolution. Test: Run adb shell LD_LIBRARY_PATH=: /system/bin/ping Test: make sure there are no warnings Bug: http://b/31346121 Change-Id: Ifd79040943dc62fc6e07d9828ff91d1050572809
* Extract soinfo and globals to separate files.Dimitry Ivanov2016-08-081-0/+68
| | | | | | | | | | | | | | Move soinfo and globals out of linker.cpp to separate files. Breaking up huge linker.cpp into smaller peaces in order to make it easier to extract part of the code that belongs to libdl.so and remove parts of the code that do not belong to linker (refactoring part 2 of many) Change-Id: I868417f4b8d2b84d0e8265e354bc7977161497e2
* Sync linker with internal branchDimitry Ivanov2016-08-011-2/+2
| | | | | | | | This change includes dlwarning implementation and the compatibility greylist for apps targeting pre-N. Change-Id: Ibf02a07cc58cbbb1a5aef4ac34558c5d43e4305f Test: Run bionic-unit-tests --gtest_filter=dl*:Dl*
* Add permitted_when_isolated_path to linker namespacesDimitry Ivanov2015-12-091-3/+12
| | | | | | | | | | The permitted_when_isolated_path is a way to white-list directories not present in search-path. It is ignored for not isolated namespaces. Bug: http://b/25853516 Bug: http://b/22548808 Change-Id: Ib1538037268eea69323ea49968a34a4a1d1938a5
* Move some utility functions to linker_utilsDmitriy Ivanov2015-11-201-0/+20
| | | | | | Also adds unit-tests for page_start, page_offset, and safe_add Change-Id: Ia1325b4682d367328a01599a19848e4ffcd2c0ea
* Introducing linker namespacesDmitriy Ivanov2015-11-151-1/+45
| | | | | Bug: http://b/22548808 Change-Id: Ia3af3c0a167f1d16447a3d83bb045d143319b1e1
* Make dt_runpath work for libraries opened from apkDmitriy Ivanov2015-10-071-0/+63
This patch also fixes realpath for libraries opened directly from apks. Bug: http://b/21960914 Bug: http://b/21961857 Change-Id: I35ade661c87f1d448191f385811f6e9fd3cacf11