Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-01-24 13:02:11 -0500
committerDoug Schaefer2017-06-02 12:08:10 -0400
commit0084cc2707d33b70236e8adb1b716a31ae4f63d9 (patch)
treed5a6d576c8a63afa2b22a49a9a3cc044178e3052
parentd3dcd92d8f41e7ead0fc1e0388ffc4cf74f1906b (diff)
downloadorg.eclipse.cdt-0084cc2707d33b70236e8adb1b716a31ae4f63d9.tar.gz
org.eclipse.cdt-0084cc2707d33b70236e8adb1b716a31ae4f63d9.tar.xz
org.eclipse.cdt-0084cc2707d33b70236e8adb1b716a31ae4f63d9.zip
Bug 510987 - Properly support PIE executables as build output
When checking whether gathering the build output from a CBuildConfiguration, if a binary is a shared library and is an ELF file, dig deeper and see if it has an INTERP section in the program header. That tells us it's actually a PIE executable and add it to the list. As a rider to this bill, improve the error message when a Qt install can't be found for a given toolchain/target. Change-Id: I8fd0bf2d204e9425b02916d7b17f4309a5ad9dd5 (cherry picked from commit 14b07f490cfb1a1fc85ede42bea43bc2bfbd22e9)
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java27
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/Messages.java15
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java8
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/messages.properties1
4 files changed, 47 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
index 6f6a1fb38b..57b0c81158 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
@@ -32,6 +32,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.ProblemMarkerInfo;
@@ -53,6 +54,9 @@ import org.eclipse.cdt.internal.core.build.Messages;
import org.eclipse.cdt.internal.core.model.BinaryRunner;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.internal.core.parser.ParserSettings2;
+import org.eclipse.cdt.utils.elf.Elf;
+import org.eclipse.cdt.utils.elf.Elf.PHdr;
+import org.eclipse.cdt.utils.elf.parser.ElfBinaryShared;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IContainer;
@@ -246,8 +250,27 @@ public abstract class CBuildConfiguration extends PlatformObject
IPath outputPath = getBuildContainer().getFullPath();
List<IBinary> outputs = new ArrayList<>();
for (IBinary binary : binaries.getBinaries()) {
- if (binary.isExecutable() && outputPath.isPrefixOf(binary.getPath())) {
- outputs.add(binary);
+ if (outputPath.isPrefixOf(binary.getPath())) {
+ if (binary.isExecutable()) {
+ outputs.add(binary);
+ } else if (binary.isSharedLib()) {
+ // Special case of PIE executable that looks like shared
+ // library
+ IBinaryParser.IBinaryObject bin = binary.getAdapter(IBinaryParser.IBinaryObject.class);
+ if (bin instanceof ElfBinaryShared) {
+ try {
+ Elf elf = new Elf(bin.getPath().toOSString());
+ for (PHdr phdr : elf.getPHdrs()) {
+ if (phdr.p_type == PHdr.PT_INTERP) {
+ outputs.add(binary);
+ break;
+ }
+ }
+ } catch (IOException e) {
+ CCorePlugin.log(e);
+ }
+ }
+ }
}
}
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/Messages.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/Messages.java
new file mode 100644
index 0000000000..fe38c1ebcf
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/Messages.java
@@ -0,0 +1,15 @@
+package org.eclipse.cdt.internal.qt.core.build;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.qt.core.build.messages"; //$NON-NLS-1$
+ public static String QtBuildConfigurationProvider_NoQtInstall;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java
index 0a266365ce..a26a8a9c16 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/QtBuildConfigurationProvider.java
@@ -10,6 +10,7 @@ package org.eclipse.cdt.internal.qt.core.build;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
@@ -23,7 +24,9 @@ import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
public class QtBuildConfigurationProvider implements ICBuildConfigurationProvider {
@@ -101,9 +104,10 @@ public class QtBuildConfigurationProvider implements ICBuildConfigurationProvide
launchMode);
configManager.addBuildConfiguration(config, qtConfig);
return qtConfig;
+ } else {
+ throw new CoreException(
+ new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.QtBuildConfigurationProvider_NoQtInstall));
}
-
- return null;
}
private IQtInstall getQtInstall(IToolChain toolChain) {
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/messages.properties b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/messages.properties
new file mode 100644
index 0000000000..315dfe3dff
--- /dev/null
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/internal/qt/core/build/messages.properties
@@ -0,0 +1 @@
+QtBuildConfigurationProvider_NoQtInstall=No Qt install available for this target

Back to the top