Add linker configuration from system_ext

Current linkerconfig does not add linker configuration from system_ext
partition, so any libraries offered from system_ext partition cannot
automatically linked into other APEXes. This change adds provide /
require libs from system_ext's linker configuration.

Bug: 332916117
Test: Test config generated as suggested
Change-Id: If180019b60a352dff6f488466d32e4a01ec4bd8a
61 files changed
tree: 819af6bf898dca108d7f431cdf55311782bf2492
  1. contents/
  2. devicetest/
  3. generator/
  4. modules/
  5. testdata/
  6. .clang-format
  7. .gitignore
  8. Android.bp
  9. linkerconfig_diff_test.xml
  11. OWNERS
  12. PREUPLOAD.cfg



Linkerconfig is a program to generate linker configuration based on the runtime environment. Linkerconfig generates one or more ld.config.txt files and some other files under /linkerconfig during init. Linker will read this generated configuration file(s) to find out link relationship between libraries and executable.


TODO: explain inputs (e.g. /system/etc/public.libraries.txt, /apex/apex-info-list.xml, ..)


Linker configuration file can be used to add extra information while linkerconfig creates linker configuration with the module. This module can be defined as linker_config from Soong, and it will be translated as protobuf file at build time.

A linker configuration file(linker.config.json) is compiled into a protobuf at build time by conv_linker_config. You can find the compiled file under <base>/etc/linker.config.pb. For example, /apex/ is a configuration for the APEX.

/system/etc/linker.config.pb(or its source module system_linker_config) is special because its provideLibs key is generated at build time.


linker.config.json file is in json format which can contain properties as below.

Property NameTypeDescriptionAllowed module
permittedPathsListAdditional permitted pathsAPEX
visibleboolForce APEX namespace to be visible from all sections if the value is trueAPEX
provideLibsListLibraries providing from the moduleSystem
requireLibsListLibraries required from the moduleSystem


APEX module
    "permittedPaths" : [ "/a", "/b/c", "/d/e/f"],
    "visible": true
    "provideLibs" : [ "", "", "" ],
    "requireLibs" : [ "", "", "" ]


linkerconfig reads both /system/etc/public.libraries.txt and /vendor/etc/public.libraries.txt to identify libraries that are provided by APEX and accessible from apps via libnativeloader.

linkerconfig generates apex.libraries.config.txt file which lists public libraries provided APEX. libnativeloader, then, links those libraries from classloader-namespace to providing APEXes.


/linkerconfig/ld.config.txt & /linkerconfig/*/ld.config.txt

TODO: a few words about the files



The file describes libraries exposed from APEXes. libnativeloader is the main consumer of this file.

# comment line
jni com_android_foo
public com_android_bar

The file is line-based and each line consists of tag apex_namespace library_list.

  • tag explains what library_list is.
  • apex_namespace is the namespace of the apex. Note that it is mangled like com_android_foo for the APEX(“”).
  • library_list is colon-separated list of library names.
    • if tag is jni, library_list is the list of JNI libraries exposed by apex_namespace.
    • if tag is public, library_list is the list of public libraries exposed by apex_namespace. Here, public libraries are the libs listed in /system/etc/public.libraries.txt.