aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-08-28 07:37:01 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-28 07:37:01 +0000
commit52c920fb2ceded026320791609b3f10d13fce381 (patch)
treed225efa5669b4fb69fccab7c8e778fd667979f70
parent264bcfbaf9fbf1349a820bf1608c813b3b102af3 (diff)
parenta7282fe4466715829b0071d74c98ee423d27a516 (diff)
downloadbuild_soong-52c920fb2ceded026320791609b3f10d13fce381.tar.gz
build_soong-52c920fb2ceded026320791609b3f10d13fce381.tar.bz2
build_soong-52c920fb2ceded026320791609b3f10d13fce381.zip
release-request-c924aaac-f0a2-4215-8dc4-e314f22460d9-for-git_oc-mr1-release-4301796 snap-temp-L23200000097143969
Change-Id: I0a82c495265904d6c7231edfc11778266f895049
-rw-r--r--cc/linker.go48
-rw-r--r--cc/sanitize.go3
-rw-r--r--cc/stl.go12
3 files changed, 25 insertions, 38 deletions
diff --git a/cc/linker.go b/cc/linker.go
index 5250d2d6..79b80fa3 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -48,8 +48,8 @@ type BaseLinkerProperties struct {
No_default_compiler_flags *bool
// list of system libraries that will be dynamically linked to
- // shared library and executable modules. If unset, generally defaults to libc
- // and libm. Set to [] to prevent linking against libc and libm.
+ // shared library and executable modules. If unset, generally defaults to libc,
+ // libm, and libdl. Set to [] to prevent linking against the defaults.
System_shared_libs []string
// allow the module to contain undefined symbols. By default,
@@ -153,34 +153,32 @@ func (linker *baseLinker) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
}
if !ctx.static() {
- // libdl should always appear after libc in dt_needed list - see below
- // the only exception is when libc is not in linker.Properties.System_shared_libs
- // such as for libc module itself
- if inList("libc", linker.Properties.System_shared_libs) {
- _, deps.SharedLibs = removeFromList("libdl", deps.SharedLibs)
+ systemSharedLibs := linker.Properties.System_shared_libs
+ if systemSharedLibs == nil {
+ systemSharedLibs = []string{"libc", "libm", "libdl"}
}
- if linker.Properties.System_shared_libs != nil {
- if !inList("libdl", linker.Properties.System_shared_libs) &&
- inList("libc", linker.Properties.System_shared_libs) {
- linker.Properties.System_shared_libs = append(linker.Properties.System_shared_libs,
- "libdl")
+ if inList("libdl", deps.SharedLibs) {
+ // If system_shared_libs has libc but not libdl, make sure shared_libs does not
+ // have libdl to avoid loading libdl before libc.
+ if inList("libc", systemSharedLibs) {
+ if !inList("libdl", systemSharedLibs) {
+ ctx.PropertyErrorf("shared_libs",
+ "libdl must be in system_shared_libs, not shared_libs")
+ }
+ _, deps.SharedLibs = removeFromList("libdl", deps.SharedLibs)
}
- deps.LateSharedLibs = append(deps.LateSharedLibs,
- linker.Properties.System_shared_libs...)
- } else if !ctx.sdk() && !ctx.vndk() {
- deps.LateSharedLibs = append(deps.LateSharedLibs, "libc", "libm", "libdl")
}
- }
- if ctx.sdk() {
- deps.SharedLibs = append(deps.SharedLibs,
- "libc",
- "libm",
- "libdl",
- )
- }
- if ctx.vndk() {
+ // If libc and libdl are both in system_shared_libs make sure libd comes after libc
+ // to avoid loading libdl before libc.
+ if inList("libdl", systemSharedLibs) && inList("libc", systemSharedLibs) &&
+ indexList("libdl", systemSharedLibs) < indexList("libc", systemSharedLibs) {
+ ctx.PropertyErrorf("system_shared_libs", "libdl must be after libc")
+ }
+
+ deps.LateSharedLibs = append(deps.LateSharedLibs, systemSharedLibs...)
+ } else if ctx.sdk() || ctx.vndk() {
deps.LateSharedLibs = append(deps.LateSharedLibs, "libc", "libm", "libdl")
}
}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 916fe718..9c3b8e52 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -264,9 +264,6 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
if Bool(sanitize.Properties.Sanitize.Address) {
deps.StaticLibs = append(deps.StaticLibs, asanLibs...)
}
- if Bool(sanitize.Properties.Sanitize.Address) || Bool(sanitize.Properties.Sanitize.Thread) {
- deps.SharedLibs = append(deps.SharedLibs, "libdl")
- }
}
return deps
diff --git a/cc/stl.go b/cc/stl.go
index 9e671456..16c377cc 100644
--- a/cc/stl.go
+++ b/cc/stl.go
@@ -107,8 +107,6 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
}
if ctx.staticBinary() {
deps.StaticLibs = append(deps.StaticLibs, "libm", "libc", "libdl")
- } else {
- deps.SharedLibs = append(deps.SharedLibs, "libdl")
}
}
case "":
@@ -118,15 +116,9 @@ func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
// The system STL doesn't have a prebuilt (it uses the system's libstdc++), but it does have
// its own includes. The includes are handled in CCBase.Flags().
deps.SharedLibs = append([]string{"libstdc++"}, deps.SharedLibs...)
- case "ndk_libc++_shared":
- deps.SharedLibs = append(deps.SharedLibs, stl.Properties.SelectedStl,
- "libdl")
- case "ndk_libc++_static":
- deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl)
- deps.SharedLibs = append(deps.SharedLibs, "libdl")
- case "ndk_libstlport_shared":
+ case "ndk_libc++_shared", "ndk_libstlport_shared":
deps.SharedLibs = append(deps.SharedLibs, stl.Properties.SelectedStl)
- case "ndk_libstlport_static", "ndk_libgnustl_static":
+ case "ndk_libc++_static", "ndk_libstlport_static", "ndk_libgnustl_static":
deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl)
default:
panic(fmt.Errorf("Unknown stl: %q", stl.Properties.SelectedStl))