• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# LinkerConfig
2
3## Introduction
4
5Linkerconfig is a program to generate linker configuration based on the runtime
6environment. Linkerconfig generates one or more ld.config.txt files and some
7other files under /linkerconfig during init. Linker will read this generated
8configuration file(s) to find out link relationship between libraries and
9executable.
10
11## Inputs
12
13TODO: explain inputs (e.g. /system/etc/public.libraries.txt,
14/apex/apex-info-list.xml, ..)
15
16### linker.config.json
17
18Linker configuration file can be used to add extra information while linkerconfig
19creates linker configuration with the module. This module can be defined as
20`linker_config` from Soong, and it will be translated as protobuf file at build
21time.
22
23A linker configuration file(linker.config.json) is compiled into a protobuf at build time
24by `conv_linker_config`. You can find the compiled file under `<base>/etc/linker.config.pb`.
25For example, `/apex/com.android.art/etc/linker.config.pb` is a configuration for the `com.android.art`
26APEX.
27
28`/system/etc/linker.config.pb`(or its source module `system_linker_config`) is special because
29its `provideLibs` key is generated at build time.
30
31#### Format
32
33linker.config.json file is in json format which can contain properties as below.
34
35| Property Name | Type | Description                                          | Allowed module |
36| ------------- | ---- | ---------------------------------------------------- | -------------- |
37| permittedPaths| List<string> | Additional permitted paths | APEX |
38| visible       | bool | Force APEX namespace to be visible from all sections if the value is true | APEX |
39| provideLibs   | List<string> | Libraries providing from the module | System |
40| requireLibs   | List<string> | Libraries required from the module | System |
41
42#### Example
43
44##### APEX module
45```
46{
47    "permittedPaths" : [ "/a", "/b/c", "/d/e/f"],
48    "visible": true
49}
50```
51
52##### System
53```
54{
55    "provideLibs" : [ "a.so", "b.so", "c.so" ],
56    "requireLibs" : [ "foo.so", "bar.so", "baz.so" ]
57}
58```
59
60### public.libraries.txt
61
62`linkerconfig` reads both `/system/etc/public.libraries.txt` and `/vendor/etc/public.libraries.txt` to identify
63libraries that are provided by APEX and accessible from apps via `libnativeloader`.
64
65`linkerconfig` generates `apex.libraries.config.txt` file which lists public libraries provided APEX. `libnativeloader`, then,
66links those libraries from classloader-namespace to providing APEXes.
67
68## Outputs
69
70### /linkerconfig/ld.config.txt & /linkerconfig/*/ld.config.txt
71
72TODO: a few words about the files
73
74Check
75[ld.config.format.md](https://android.googlesource.com/platform/bionic/+/master/linker/ld.config.format.md).
76
77### /linkerconfig/apex.libraries.txt
78
79The file describes libraries exposed from APEXes. libnativeloader is the main
80consumer of this file.
81
82```
83# comment line
84jni com_android_foo libfoo_jni.so
85public com_android_bar libbar.so:libbaz.so
86```
87
88The file is line-based and each line consists of `tag apex_namespace
89library_list`.
90
91-   `tag` explains what `library_list` is.
92-   `apex_namespace` is the namespace of the apex. Note that it is mangled like
93    `com_android_foo` for the APEX("com.android.foo").
94-   `library_list` is colon-separated list of library names.
95    -   if `tag` is `jni`, `library_list` is the list of JNI libraries exposed
96        by `apex_namespace`.
97    -   if `tag` is `public`, `library_list` is the list of public libraries
98        exposed by `apex_namespace`. Here, public libraries are the libs listed
99        in `/system/etc/public.libraries.txt.`