mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-10 09:13:58 -09:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
@@ -16,10 +16,7 @@
|
||||
package ghidra.app.cmd.function;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import ghidra.app.util.PseudoDisassembler;
|
||||
@@ -27,11 +24,7 @@ import ghidra.framework.cmd.BackgroundCommand;
|
||||
import ghidra.framework.model.DomainObject;
|
||||
import ghidra.program.database.function.OverlappingFunctionException;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.block.BasicBlockModel;
|
||||
import ghidra.program.model.block.CodeBlock;
|
||||
import ghidra.program.model.block.CodeBlockReference;
|
||||
import ghidra.program.model.block.CodeBlockReferenceIterator;
|
||||
import ghidra.program.model.block.SimpleBlockModel;
|
||||
import ghidra.program.model.block.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
@@ -695,6 +688,7 @@ public class CreateThunkFunctionCmd extends BackgroundCommand {
|
||||
ExternalManager extMgr = program.getExternalManager();
|
||||
ExternalLocation extLoc =
|
||||
extMgr.addExtFunction(Library.UNKNOWN, s.getName(), null, s.getSource());
|
||||
s.delete(); // remove original symbol from EXTERNAL block
|
||||
return extLoc.getExternalSpaceAddress();
|
||||
}
|
||||
catch (DuplicateNameException | InvalidInputException e) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.framework.plugintool.util.PluginStatus;
|
||||
import ghidra.program.database.data.ProgramDataTypeManager;
|
||||
import ghidra.program.model.data.*;
|
||||
import ghidra.program.model.lang.LanguageCompilerSpecPair;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.util.*;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
@@ -300,16 +301,25 @@ public class CParserPlugin extends ProgramPlugin {
|
||||
|
||||
/*
|
||||
* Parse into the current programs data type manager
|
||||
*
|
||||
* Always uses the program's processor architecture
|
||||
*/
|
||||
protected void parse(String[] filenames, String[] includePaths, String options,
|
||||
String languageIDString, String compilerIDString) {
|
||||
protected void parse(String[] filenames, String[] includePaths, String options) {
|
||||
if (currentProgram == null) {
|
||||
Msg.showInfo(getClass(), parseDialog.getComponent(), "No Open Program",
|
||||
"A program must be open to \"Parse to Program\"");
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* always use the processor/compiler for the program when parsing to program
|
||||
*/
|
||||
LanguageCompilerSpecPair languageCompilerSpecPair = currentProgram.getLanguageCompilerSpecPair();
|
||||
String procID = languageCompilerSpecPair.languageID.getIdAsString();
|
||||
String compilerID = languageCompilerSpecPair.compilerSpecID.getIdAsString();
|
||||
|
||||
int result = OptionDialog.showOptionDialog(parseDialog.getComponent(), "Confirm",
|
||||
"Parse C source to \"" + currentProgram.getDomainFile().getName() + "\"?", "Continue");
|
||||
"Parse C source to \"" + currentProgram.getDomainFile().getName() + "\"?" + "\n\n" +
|
||||
"Using program architecture: " + procID + " / " + compilerID, "Continue");
|
||||
|
||||
if (result == OptionDialog.CANCEL_OPTION) {
|
||||
return;
|
||||
@@ -320,8 +330,8 @@ public class CParserPlugin extends ProgramPlugin {
|
||||
.setFileNames(filenames)
|
||||
.setIncludePaths(includePaths)
|
||||
.setOptions(options)
|
||||
.setLanguageID(languageIDString)
|
||||
.setCompilerID(compilerIDString);
|
||||
.setLanguageID(procID)
|
||||
.setCompilerID(compilerID);
|
||||
|
||||
tool.execute(parseTask);
|
||||
}
|
||||
|
||||
@@ -804,22 +804,22 @@ class ParseDialog extends ReusableDialogComponentProvider {
|
||||
paths = expandPaths(paths);
|
||||
pathPanel.setPaths(paths);
|
||||
|
||||
if (languageIDString == null || compilerIDString == null) {
|
||||
Msg.showWarn(getClass(), rootPanel, "Program Architecture not Specified",
|
||||
"A Program Architecture must be specified in order to parse to a file.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (parseToFile) {
|
||||
if (parseToFile) {
|
||||
if (languageIDString == null || compilerIDString == null) {
|
||||
Msg.showWarn(getClass(), rootPanel, "Program Architecture not Specified",
|
||||
"A Program Architecture must be specified in order to parse to a file.");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = getSaveFile();
|
||||
if (file != null) {
|
||||
plugin.parse(paths, includePaths, options, languageIDString, compilerIDString,
|
||||
file.getAbsolutePath());
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
plugin.parse(paths, includePaths, options, languageIDString, compilerIDString);
|
||||
}
|
||||
|
||||
plugin.parse(paths, includePaths, options);
|
||||
}
|
||||
|
||||
private String[] expandPaths(String[] paths) {
|
||||
|
||||
@@ -1726,10 +1726,10 @@ PPToken MacroVals() : {Token s,t,u=new Token();u.image="";}
|
||||
}
|
||||
|
||||
PPToken Pragma() :
|
||||
{Token t;}
|
||||
{ t=<PRAGMA_EXPRN> {
|
||||
PPToken pt = new PPToken(t);
|
||||
if (emitExecSwitch==true) println("#pragma " + defs.expand(t.image,true)); return pt;
|
||||
{Token t,u=null; }
|
||||
{ (LOOKAHEAD(2)(t=<PRAGMA_EXPRN> { if (u==null) { u = t; } else { u.image += t.image; } } ))+ {
|
||||
PPToken pt = new PPToken(u);
|
||||
if (emitExecSwitch==true) println("#pragma " + defs.expand(u.image,true)); return pt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1908,7 +1908,7 @@ PPToken NewLines() :
|
||||
t=<EOLCMNTNL> | // newline coming from //
|
||||
t=<ERRLINE> |
|
||||
t=<LINLINE> |
|
||||
t=<PRGLINE> |
|
||||
t=<PRAGLINE> |
|
||||
t=<IFDLINE> |
|
||||
t=<IFNDLINE> |
|
||||
t=<DIRLINE> |
|
||||
@@ -2691,13 +2691,19 @@ TOKEN : {
|
||||
|
||||
<PRAGMA>
|
||||
TOKEN : {
|
||||
<PRAGMA_EXPRN: <NOTWS> (<NOTENDL>)* > : DEFAULT |
|
||||
<PRGLINE: <ENDL> > : DEFAULT
|
||||
<PRAGMA_EXPRN:
|
||||
<WSP> ( ~["\\","\n","\r","/"," ","\t"] |
|
||||
(<CMT><NOTENDLSTAR>)
|
||||
)+ > : PRAGMA |
|
||||
<PRAGLINE: <ENDL> > : DEFAULT
|
||||
}
|
||||
|
||||
<PRAGMA>
|
||||
SKIP : {
|
||||
<_WSP1: <WSP> > : PRAGMA
|
||||
<_LCMTPRAG: <CMT><CMT>> : LINECOMMENT |
|
||||
<_SCMT_PRAG: (<STARTCMT> (<NOTENDLSTAR> | ("*" ~["/"]) | ("/"))+ <ENDCMT>) > : PRAGMA |
|
||||
<_COD_WSP: <WSP>> : PRAGMA |
|
||||
<_COD_PRAG: <COD>> : PRAGMA
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -127,6 +127,15 @@ public class PreProcessorTest extends AbstractGenericTest {
|
||||
"\" second line\"\n" +
|
||||
"\" third line\"\n" +
|
||||
"\" fourth line\")") != -1);
|
||||
|
||||
assertTrue("multi line #pragma failed ", results
|
||||
.indexOf("#pragma multiple lines pragma") != -1);
|
||||
|
||||
assertTrue("#pragma with comment failed ", results
|
||||
.indexOf("#pragma no comment here") != -1);
|
||||
|
||||
assertTrue("#pragma with EOL comment failed ", results
|
||||
.indexOf("#pragma with no EOL comment here") != -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -106,6 +106,14 @@ int foo;
|
||||
|
||||
#pragma once
|
||||
|
||||
#pragma multiple \
|
||||
lines \
|
||||
pragma
|
||||
|
||||
#pragma no comment here /* no comment / here */
|
||||
|
||||
#pragma with no EOL comment here // no comment here
|
||||
|
||||
#define PTYPE 4
|
||||
|
||||
#define TYPE2 2 /* 2 */
|
||||
|
||||
@@ -505,7 +505,7 @@ def checkGradleVersion() {
|
||||
GradleVersion min = null;
|
||||
GradleVersion max = null;
|
||||
try {
|
||||
min = GradleVersion.version("${rootProject.GRADLE_MIN}")
|
||||
min = GradleVersion.version("${GRADLE_MIN}")
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
String defaultMin = "1.0"
|
||||
@@ -513,8 +513,8 @@ def checkGradleVersion() {
|
||||
min = GradleVersion.version(defaultMin)
|
||||
}
|
||||
try {
|
||||
if (rootProject.GRADLE_MAX) {
|
||||
max = GradleVersion.version("${rootProject.GRADLE_MAX}")
|
||||
if (GRADLE_MAX) {
|
||||
max = GradleVersion.version("${GRADLE_MAX}")
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
|
||||
Reference in New Issue
Block a user