xref: /aosp_15_r20/bionic/linker/ld.config.format.md (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1*8d67ca89SAndroid Build Coastguard Worker# Linker config file format
2*8d67ca89SAndroid Build Coastguard Worker
3*8d67ca89SAndroid Build Coastguard WorkerThis document describes format of /system/etc/ld.config.txt file. This file can be used to customize
4*8d67ca89SAndroid Build Coastguard Workerlinker-namespace setup for dynamic executables.
5*8d67ca89SAndroid Build Coastguard Worker
6*8d67ca89SAndroid Build Coastguard Worker## Overview
7*8d67ca89SAndroid Build Coastguard Worker
8*8d67ca89SAndroid Build Coastguard WorkerThe configuration consists of 2 parts
9*8d67ca89SAndroid Build Coastguard Worker1. Mappings - maps executable locations to sections
10*8d67ca89SAndroid Build Coastguard Worker2. Sections - contains linker-namespace configuration
11*8d67ca89SAndroid Build Coastguard Worker
12*8d67ca89SAndroid Build Coastguard Worker## Mappings
13*8d67ca89SAndroid Build Coastguard Worker
14*8d67ca89SAndroid Build Coastguard WorkerThis part of the document maps location of an executable to a section. Here is an example
15*8d67ca89SAndroid Build Coastguard Worker
16*8d67ca89SAndroid Build Coastguard WorkerThe format is `dir.<section_name>=<directory>`
17*8d67ca89SAndroid Build Coastguard Worker
18*8d67ca89SAndroid Build Coastguard WorkerThe mappings should be defined between start of ld.config.txt and the first section.
19*8d67ca89SAndroid Build Coastguard Worker
20*8d67ca89SAndroid Build Coastguard Worker## Section
21*8d67ca89SAndroid Build Coastguard Worker
22*8d67ca89SAndroid Build Coastguard WorkerEvery section starts with `[section_name]` (which is used in mappings) and it defines namespaces
23*8d67ca89SAndroid Build Coastguard Workerconfiguration using set of properties described in example below.
24*8d67ca89SAndroid Build Coastguard Worker
25*8d67ca89SAndroid Build Coastguard Worker## Example
26*8d67ca89SAndroid Build Coastguard Worker
27*8d67ca89SAndroid Build Coastguard Worker```
28*8d67ca89SAndroid Build Coastguard Worker# The following line maps section to a dir. Binaries ran from this location will use namespaces
29*8d67ca89SAndroid Build Coastguard Worker# configuration specified in [example_section] below
30*8d67ca89SAndroid Build Coastguard Workerdir.example_section=/system/bin/example
31*8d67ca89SAndroid Build Coastguard Worker
32*8d67ca89SAndroid Build Coastguard Worker# Section starts
33*8d67ca89SAndroid Build Coastguard Worker[example_section]
34*8d67ca89SAndroid Build Coastguard Worker
35*8d67ca89SAndroid Build Coastguard Worker# When this flag is set to true linker will set target_sdk_version for this binary to
36*8d67ca89SAndroid Build Coastguard Worker# the version specified in <dirname>/.version file, where <dirname> = dirname(executable_path)
37*8d67ca89SAndroid Build Coastguard Worker#
38*8d67ca89SAndroid Build Coastguard Worker# default value is false
39*8d67ca89SAndroid Build Coastguard Workerenable.target.sdk.version = true
40*8d67ca89SAndroid Build Coastguard Worker
41*8d67ca89SAndroid Build Coastguard Worker# This property can be used to declare additional namespaces. Note that there is always the default
42*8d67ca89SAndroid Build Coastguard Worker# namespace. The default namespace is the namespace for the main executable. This list is
43*8d67ca89SAndroid Build Coastguard Worker# comma-separated.
44*8d67ca89SAndroid Build Coastguard Workeradditional.namespaces = ns1
45*8d67ca89SAndroid Build Coastguard Worker
46*8d67ca89SAndroid Build Coastguard Worker# Each namespace property starts with "namespace.<namespace-name>" The following is configuration
47*8d67ca89SAndroid Build Coastguard Worker# for the default namespace
48*8d67ca89SAndroid Build Coastguard Worker
49*8d67ca89SAndroid Build Coastguard Worker# Is namespace isolated - the default value is false
50*8d67ca89SAndroid Build Coastguard Workernamespace.default.isolated = true
51*8d67ca89SAndroid Build Coastguard Worker
52*8d67ca89SAndroid Build Coastguard Worker# Default namespace search path. Note that ${LIB} here is substituted with "lib" for 32bit targets
53*8d67ca89SAndroid Build Coastguard Worker# and with "lib64" for 64bit ones.
54*8d67ca89SAndroid Build Coastguard Workernamespace.default.search.paths = /system/${LIB}:/system/other/${LIB}
55*8d67ca89SAndroid Build Coastguard Worker
56*8d67ca89SAndroid Build Coastguard Worker# ... same for asan
57*8d67ca89SAndroid Build Coastguard Workernamespace.default.asan.search.paths = /data/${LIB}:/data/other/${LIB}
58*8d67ca89SAndroid Build Coastguard Worker
59*8d67ca89SAndroid Build Coastguard Worker# Permitted path
60*8d67ca89SAndroid Build Coastguard Workernamespace.default.permitted.paths = /system/${LIB}
61*8d67ca89SAndroid Build Coastguard Worker
62*8d67ca89SAndroid Build Coastguard Worker# ... asan
63*8d67ca89SAndroid Build Coastguard Workernamespace.default.asan.permitted.paths = /data/${LIB}
64*8d67ca89SAndroid Build Coastguard Worker
65*8d67ca89SAndroid Build Coastguard Worker# This declares linked namespaces - comma separated list.
66*8d67ca89SAndroid Build Coastguard Workernamespace.default.links = ns1
67*8d67ca89SAndroid Build Coastguard Worker
68*8d67ca89SAndroid Build Coastguard Worker# For every link define list of shared libraries. This is list of the libraries accessible from
69*8d67ca89SAndroid Build Coastguard Worker# default namespace but loaded in the linked namespace.
70*8d67ca89SAndroid Build Coastguard Workernamespace.default.link.ns1.shared_libs = libexternal.so:libother.so
71*8d67ca89SAndroid Build Coastguard Worker
72*8d67ca89SAndroid Build Coastguard Worker# This part defines config for ns1
73*8d67ca89SAndroid Build Coastguard Workernamespace.ns1.isolated = true
74*8d67ca89SAndroid Build Coastguard Workernamespace.ns1.search.paths = /vendor/${LIB}
75*8d67ca89SAndroid Build Coastguard Workernamespace.ns1.asan.search.paths = /data/vendor/${LIB}
76*8d67ca89SAndroid Build Coastguard Workernamespace.ns1.permitted.paths = /vendor/${LIB}
77*8d67ca89SAndroid Build Coastguard Workernamespace.ns1.asan.permitted.paths = /data/vendor/${LIB}
78*8d67ca89SAndroid Build Coastguard Worker
79*8d67ca89SAndroid Build Coastguard Worker# and links it to default namespace
80*8d67ca89SAndroid Build Coastguard Workernamespace.ns.links = default
81*8d67ca89SAndroid Build Coastguard Workernamespace.ns.link.default.shared_libs = libc.so:libdl.so:libm.so:libstdc++.so
82*8d67ca89SAndroid Build Coastguard Worker
83*8d67ca89SAndroid Build Coastguard Worker# [Deprecated] This defines what libraries are allowed to be loaded from ns1
84*8d67ca89SAndroid Build Coastguard Workernamespace.ns1.whitelisted = libsomething.so
85*8d67ca89SAndroid Build Coastguard Worker# This defines what libraries are allowed to be loaded from ns1
86*8d67ca89SAndroid Build Coastguard Workernamespace.ns1.allowed_libs = libsomething2.so
87*8d67ca89SAndroid Build Coastguard Worker```
88*8d67ca89SAndroid Build Coastguard Worker
89