blob: d560c576425f7bb5841f1d0afc8ca0fae9b0001e [file] [log] [blame] [view]
Kiyoung Kimf9920e22020-08-31 13:55:25 +09001# 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
Jooyung Han52ccfa72020-09-01 13:49:27 +090011## Inputs
Kiyoung Kimf9920e22020-08-31 13:55:25 +090012
Kiyoung Kim81b9f842020-09-14 11:22:19 +090013TODO: explain inputs (e.g. /system/etc/public.libraries.txt,
14/apex/apex-info-list.xml, ..)
Kiyoung Kimf9920e22020-08-31 13:55:25 +090015
Kiyoung Kim197857e2020-10-06 17:07:25 +090016### linker.config.json
Kiyoung Kimf9920e22020-08-31 13:55:25 +090017
Kiyoung Kim197857e2020-10-06 17:07:25 +090018Linker configuration file can be used to add extra information while linkerconfig
19creates linker configuration with the module. This module can be defined as
Jooyung Hanbeba1df2021-04-15 03:12:07 +090020`linker_config` from Soong, and it will be translated as protobuf file at build
Kiyoung Kim197857e2020-10-06 17:07:25 +090021time.
Kiyoung Kimf9920e22020-08-31 13:55:25 +090022
Jooyung Hanbeba1df2021-04-15 03:12:07 +090023A 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
Jooyung Han52ccfa72020-09-01 13:49:27 +090031#### Format
Kiyoung Kimf9920e22020-08-31 13:55:25 +090032
Kiyoung Kim197857e2020-10-06 17:07:25 +090033linker.config.json file is in json format which can contain properties as below.
Kiyoung Kim81b9f842020-09-14 11:22:19 +090034
Kiyoung Kimd7fb1c12020-10-21 09:59:12 +090035| 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 |
Kiyoung Kim81b9f842020-09-14 11:22:19 +090041
Jooyung Han52ccfa72020-09-01 13:49:27 +090042#### Example
Kiyoung Kimf9920e22020-08-31 13:55:25 +090043
Kiyoung Kimd7fb1c12020-10-21 09:59:12 +090044##### APEX module
Kiyoung Kimf9920e22020-08-31 13:55:25 +090045```
Kiyoung Kim197857e2020-10-06 17:07:25 +090046{
47 "permittedPaths" : [ "/a", "/b/c", "/d/e/f"],
48 "visible": true
49}
Kiyoung Kimf9920e22020-08-31 13:55:25 +090050```
51
Kiyoung Kimd7fb1c12020-10-21 09:59:12 +090052##### System
53```
54{
55 "provideLibs" : [ "a.so", "b.so", "c.so" ],
56 "requireLibs" : [ "foo.so", "bar.so", "baz.so" ]
57}
58```
59
Jooyung Han52ccfa72020-09-01 13:49:27 +090060## Outputs
Kiyoung Kimf9920e22020-08-31 13:55:25 +090061
Jooyung Han52ccfa72020-09-01 13:49:27 +090062### /linkerconfig/ld.config.txt & /linkerconfig/*/ld.config.txt
63
64TODO: a few words about the files
Kiyoung Kimf9920e22020-08-31 13:55:25 +090065
66Check
67[ld.config.format.md](https://android.googlesource.com/platform/bionic/+/master/linker/ld.config.format.md).
68
Jooyung Han52ccfa72020-09-01 13:49:27 +090069### /linkerconfig/apex.libraries.txt
70
Kiyoung Kim81b9f842020-09-14 11:22:19 +090071The file describes libraries exposed from APEXes. libnativeloader is the main
72consumer of this file.
Jooyung Han52ccfa72020-09-01 13:49:27 +090073
74```
75# comment line
76jni com_android_foo libfoo_jni.so
77public com_android_bar libbar.so:libbaz.so
78```
79
Kiyoung Kim81b9f842020-09-14 11:22:19 +090080The file is line-based and each line consists of `tag apex_namespace
81library_list`.
Jooyung Han52ccfa72020-09-01 13:49:27 +090082
Kiyoung Kim81b9f842020-09-14 11:22:19 +090083- `tag` explains what `library_list` is.
84- `apex_namespace` is the namespace of the apex. Note that it is mangled like
85 `com_android_foo` for the APEX("com.android.foo").
86- `library_list` is colon-separated list of library names.
87 - if `tag` is `jni`, `library_list` is the list of JNI libraries exposed
88 by `apex_namespace`.
89 - if `tag` is `public`, `library_list` is the list of public libraries
90 exposed by `apex_namespace`. Here, public libraries are the libs listed
91 in `/system/etc/public.libraries.txt.`