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## Outputs 61 62### /linkerconfig/ld.config.txt & /linkerconfig/*/ld.config.txt 63 64TODO: a few words about the files 65 66Check 67[ld.config.format.md](https://android.googlesource.com/platform/bionic/+/master/linker/ld.config.format.md). 68 69### /linkerconfig/apex.libraries.txt 70 71The file describes libraries exposed from APEXes. libnativeloader is the main 72consumer of this file. 73 74``` 75# comment line 76jni com_android_foo libfoo_jni.so 77public com_android_bar libbar.so:libbaz.so 78``` 79 80The file is line-based and each line consists of `tag apex_namespace 81library_list`. 82 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.`