mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
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 14b07f490c
)
This commit is contained in:
parent
d3dcd92d8f
commit
0084cc2707
4 changed files with 47 additions and 4 deletions
|
@ -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())) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
QtBuildConfigurationProvider_NoQtInstall=No Qt install available for this target
|
Loading…
Add table
Reference in a new issue