mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix PR 48921.
Check also for Object files.
This commit is contained in:
parent
5fdc6c2dc5
commit
190a43899d
1 changed files with 28 additions and 1 deletions
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.AbstractCExtension;
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
import org.eclipse.cdt.utils.coff.PE;
|
import org.eclipse.cdt.utils.coff.PE;
|
||||||
import org.eclipse.cdt.utils.coff.PEArchive;
|
import org.eclipse.cdt.utils.coff.PEArchive;
|
||||||
|
import org.eclipse.cdt.utils.coff.PEConstants;
|
||||||
import org.eclipse.cdt.utils.coff.PE.Attribute;
|
import org.eclipse.cdt.utils.coff.PE.Attribute;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
@ -75,7 +76,33 @@ public class PEParser extends AbstractCExtension implements IBinaryParser {
|
||||||
* @see org.eclipse.cdt.core.IBinaryParser#isBinary(byte[], org.eclipse.core.runtime.IPath)
|
* @see org.eclipse.cdt.core.IBinaryParser#isBinary(byte[], org.eclipse.core.runtime.IPath)
|
||||||
*/
|
*/
|
||||||
public boolean isBinary(byte[] array, IPath path) {
|
public boolean isBinary(byte[] array, IPath path) {
|
||||||
return PE.isExeHeader(array) || PEArchive.isARHeader(array);
|
boolean isBin = PE.isExeHeader(array) || PEArchive.isARHeader(array);
|
||||||
|
// It maybe an object file try the known machine types.
|
||||||
|
if (!isBin && array.length > 1) {
|
||||||
|
int f_magic = (((array[1] & 0xff) << 8) | (array[0] & 0xff));
|
||||||
|
switch (f_magic) {
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_ALPHA:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_ARM:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_ALPHA64:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_I386:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_IA64:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_M68K:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_MIPS16:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_MIPSFPU:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_MIPSFPU16:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_POWERPC:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_R3000:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_R4000:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_R10000:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_SH3:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_SH4:
|
||||||
|
case PEConstants.IMAGE_FILE_MACHINE_THUMB:
|
||||||
|
// Ok;
|
||||||
|
isBin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isBin;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue