Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 1 | # LinkerConfig |
| 2 | |
| 3 | ## Introduction |
| 4 | |
| 5 | Linkerconfig is a program to generate linker configuration based on the runtime |
| 6 | environment. Linkerconfig generates one or more ld.config.txt files and some |
| 7 | other files under /linkerconfig during init. Linker will read this generated |
| 8 | configuration file(s) to find out link relationship between libraries and |
| 9 | executable. |
| 10 | |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 11 | ## Inputs |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 12 | |
Kiyoung Kim | 81b9f84 | 2020-09-14 11:22:19 +0900 | [diff] [blame] | 13 | TODO: explain inputs (e.g. /system/etc/public.libraries.txt, |
| 14 | /apex/apex-info-list.xml, ..) |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 15 | |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 16 | ### linker.config.json |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 17 | |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 18 | Linker configuration file can be used to add extra information while linkerconfig |
| 19 | creates linker configuration with the module. This module can be defined as |
Jooyung Han | beba1df | 2021-04-15 03:12:07 +0900 | [diff] [blame] | 20 | `linker_config` from Soong, and it will be translated as protobuf file at build |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 21 | time. |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 22 | |
Jooyung Han | beba1df | 2021-04-15 03:12:07 +0900 | [diff] [blame] | 23 | A linker configuration file(linker.config.json) is compiled into a protobuf at build time |
| 24 | by `conv_linker_config`. You can find the compiled file under `<base>/etc/linker.config.pb`. |
| 25 | For example, `/apex/com.android.art/etc/linker.config.pb` is a configuration for the `com.android.art` |
| 26 | APEX. |
| 27 | |
| 28 | `/system/etc/linker.config.pb`(or its source module `system_linker_config`) is special because |
| 29 | its `provideLibs` key is generated at build time. |
| 30 | |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 31 | #### Format |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 32 | |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 33 | linker.config.json file is in json format which can contain properties as below. |
Kiyoung Kim | 81b9f84 | 2020-09-14 11:22:19 +0900 | [diff] [blame] | 34 | |
Kiyoung Kim | d7fb1c1 | 2020-10-21 09:59:12 +0900 | [diff] [blame] | 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 | |
Kiyoung Kim | 81b9f84 | 2020-09-14 11:22:19 +0900 | [diff] [blame] | 41 | |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 42 | #### Example |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 43 | |
Kiyoung Kim | d7fb1c1 | 2020-10-21 09:59:12 +0900 | [diff] [blame] | 44 | ##### APEX module |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 45 | ``` |
Kiyoung Kim | 197857e | 2020-10-06 17:07:25 +0900 | [diff] [blame] | 46 | { |
| 47 | "permittedPaths" : [ "/a", "/b/c", "/d/e/f"], |
| 48 | "visible": true |
| 49 | } |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 50 | ``` |
| 51 | |
Kiyoung Kim | d7fb1c1 | 2020-10-21 09:59:12 +0900 | [diff] [blame] | 52 | ##### System |
| 53 | ``` |
| 54 | { |
| 55 | "provideLibs" : [ "a.so", "b.so", "c.so" ], |
| 56 | "requireLibs" : [ "foo.so", "bar.so", "baz.so" ] |
| 57 | } |
| 58 | ``` |
| 59 | |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 60 | ## Outputs |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 61 | |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 62 | ### /linkerconfig/ld.config.txt & /linkerconfig/*/ld.config.txt |
| 63 | |
| 64 | TODO: a few words about the files |
Kiyoung Kim | f9920e2 | 2020-08-31 13:55:25 +0900 | [diff] [blame] | 65 | |
| 66 | Check |
| 67 | [ld.config.format.md](https://android.googlesource.com/platform/bionic/+/master/linker/ld.config.format.md). |
| 68 | |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 69 | ### /linkerconfig/apex.libraries.txt |
| 70 | |
Kiyoung Kim | 81b9f84 | 2020-09-14 11:22:19 +0900 | [diff] [blame] | 71 | The file describes libraries exposed from APEXes. libnativeloader is the main |
| 72 | consumer of this file. |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 73 | |
| 74 | ``` |
| 75 | # comment line |
| 76 | jni com_android_foo libfoo_jni.so |
| 77 | public com_android_bar libbar.so:libbaz.so |
| 78 | ``` |
| 79 | |
Kiyoung Kim | 81b9f84 | 2020-09-14 11:22:19 +0900 | [diff] [blame] | 80 | The file is line-based and each line consists of `tag apex_namespace |
| 81 | library_list`. |
Jooyung Han | 52ccfa7 | 2020-09-01 13:49:27 +0900 | [diff] [blame] | 82 | |
Kiyoung Kim | 81b9f84 | 2020-09-14 11:22:19 +0900 | [diff] [blame] | 83 | - `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.` |