aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-11-02 15:45:09 -0400
committerGravatar John Cater <jcater@google.com>2017-11-03 09:53:12 -0400
commit7bf7483d0853c753905bd6c582da7dcf878b183d (patch)
tree47865753d9427791a451713d69b5bc7f6b2298cb /src/main/java/com/google/devtools
parent1ce985a704357c35d6691a80d94ca55372593b16 (diff)
When force_pic is on, build linkstamp objects with PIC.
Previously, linkstamp objects would be built without -fPIC. When linked into a PIE binary, this leads to text relocations, which causes IFUNC resolution to segfault (the resolution function is called while the binary is mapped RW). RELNOTES: None. PiperOrigin-RevId: 174366114
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
index c7ab4bb993..cad71852a3 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/LinkCommandLine.java
@@ -488,7 +488,7 @@ public final class LinkCommandLine extends CommandLine {
return ImmutableList.copyOf(batchCommand);
}
}
-
+
private boolean isSharedNativeLibrary() {
return nativeDeps && cppConfiguration.shareNativeDeps();
}
@@ -587,7 +587,8 @@ public final class LinkCommandLine extends CommandLine {
CppModel.PREPROCESSOR_DEFINES_VARIABLE_NAME,
computeAllLinkstampDefines());
// For dynamic libraries, produce position independent code.
- if (linkTargetType == LinkTargetType.DYNAMIC_LIBRARY && ccProvider.toolchainNeedsPic()) {
+ if (cppConfiguration.forcePic()
+ || (linkTargetType == LinkTargetType.DYNAMIC_LIBRARY && ccProvider.toolchainNeedsPic())) {
linkstampVariables.addStringVariable(CppModel.PIC_VARIABLE_NAME, "");
}
return linkstampVariables.build();