Skip to content

Commit 19a9278

Browse files
committed
added native code option and check in SootMethod.isConcrete()
1 parent 8748aec commit 19a9278

File tree

6 files changed

+58
-1
lines changed

6 files changed

+58
-1
lines changed

doc/soot_options.html

+4
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,10 @@ <H2><A name="section_2">Input Options</A></H2>
688688
<td><tt>-drop-bodies-after-load </tt><br></td>
689689
<td colspan="2">Drop the method source after it has served its purpose of loading the method body</td>
690690
</tr>
691+
<tr>
692+
<td><tt>-nc </tt><br><tt>-native-code </tt><br></td>
693+
<td colspan="2">Enables native methods to be concrete. Needed for analyzing the Java Native Interface.</td>
694+
</tr>
691695
</table>
692696
<H2><A name="section_3">Output Options</A></H2>
693697
<table border="3">

eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/ui/PhaseOptionsDialog.java

+27
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,12 @@ private boolean createNewConfig() {
12121212
if (boolRes != defBoolRes) {
12131213
getConfig().put(getInput_Optionsdrop_bodies_after_load_widget().getAlias(), new Boolean(boolRes));
12141214
}
1215+
boolRes = getInput_Optionsnative_code_widget().getButton().getSelection();
1216+
defBoolRes = false;
1217+
1218+
if (boolRes != defBoolRes) {
1219+
getConfig().put(getInput_Optionsnative_code_widget().getAlias(), new Boolean(boolRes));
1220+
}
12151221
stringRes = getInput_Optionssoot_classpath_widget().getText().getText();
12161222
defStringRes = "";
12171223

@@ -4915,6 +4921,16 @@ public BooleanOptionWidget getInput_Optionsdrop_bodies_after_load_widget() {
49154921
return Input_Optionsdrop_bodies_after_load_widget;
49164922
}
49174923

4924+
private BooleanOptionWidget Input_Optionsnative_code_widget;
4925+
4926+
private void setInput_Optionsnative_code_widget(BooleanOptionWidget widget) {
4927+
Input_Optionsnative_code_widget = widget;
4928+
}
4929+
4930+
public BooleanOptionWidget getInput_Optionsnative_code_widget() {
4931+
return Input_Optionsnative_code_widget;
4932+
}
4933+
49184934

49194935
private ListOptionWidget Input_Optionsprocess_dir_widget;
49204936

@@ -9047,6 +9063,17 @@ private Composite Input_OptionsCreate(Composite parent) {
90479063

90489064
setInput_Optionsdrop_bodies_after_load_widget(new BooleanOptionWidget(editGroupInput_Options, SWT.NONE, new OptionData("Drop method source after loading bodies", "", "","drop-bodies-after-load", "\nEach method is associated with a method source for loading its \nbody. When this option is disabled, a reference to this source \nis kept around even after the body has already been loaded. This \nis a waste of memory for most use cases. When this option is \nenabled, the reference is dropped, allowing for garbage \ncollection of the method source. On the other hand, if the body \nis ever released, it cannot easily be recovered (i.e., loaded \nagain) easily.", defaultBool)));
90499065

9066+
defKey = ""+" "+""+" "+"nc native-code";
9067+
defKey = defKey.trim();
9068+
9069+
if (isInDefList(defKey)) {
9070+
defaultBool = getBoolDef(defKey);
9071+
} else {
9072+
defaultBool = false;
9073+
}
9074+
9075+
setInput_Optionsnative_code_widget(new BooleanOptionWidget(editGroupInput_Options, SWT.NONE, new OptionData("Enable native code", "", "","nc native-code", "\nThis option is needed, when analyzing native code. Particularly \nwhen using the Java Native Interface (JNI). If this option is \nenabled (set true), it allows native methods to be concrete. \nThis flag will be checked in the SootMethod.isConcrete() method, \nallowing native methods to have a body.", defaultBool)));
9076+
90509077
data = new OptionData [] {
90519078

90529079
new OptionData("Class File",

src/main/generated/options/soot/AntTask.java

+4
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ public void setdrop_bodies_after_load(boolean arg) {
346346
if(arg) addArg("-drop-bodies-after-load");
347347
}
348348

349+
public void setnative_code(boolean arg) {
350+
if(arg) addArg("-native-code");
351+
}
352+
349353
public void setoutput_dir(String arg) {
350354
addArg("-output-dir");
351355
addArg(arg);

src/main/generated/options/soot/options/Options.java

+10
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ else if (false
547547
|| option.equals("no-drop-bodies-after-load")
548548
)
549549
drop_bodies_after_load = false;
550+
else if (false
551+
|| option.equals("nc")
552+
|| option.equals("native-code")
553+
)
554+
native_code = true;
550555
else if (false
551556
|| option.equals("d")
552557
|| option.equals("output-dir")
@@ -1664,6 +1669,10 @@ public int src_prec() {
16641669
private boolean drop_bodies_after_load = true;
16651670
public void set_drop_bodies_after_load(boolean setting) { drop_bodies_after_load = setting; }
16661671

1672+
public boolean native_code() { return native_code; }
1673+
private boolean native_code = false;
1674+
public void set_native_code(boolean setting) { native_code = setting; }
1675+
16671676
public String output_dir() { return output_dir; }
16681677
public void set_output_dir(String setting) { output_dir = setting; }
16691678
private String output_dir = "";
@@ -1898,6 +1907,7 @@ public String getUsage() {
18981907
+ padOpt("-polyglot", "Use Java 1.4 Polyglot frontend instead of JastAdd")
18991908
+ padOpt("-permissive-resolving", "Use alternative sources when classes cannot be found using the normal resolving strategy")
19001909
+ padOpt("-drop-bodies-after-load", "Drop the method source after it has served its purpose of loading the method body")
1910+
+ padOpt("-nc, -native-code", "Enables native methods to be concrete. Needed for analyzing the Java Native Interface.")
19011911
+ "\nOutput Options:\n"
19021912
+ padOpt("-d ARG -output-dir ARG", "Store output files in ARG")
19031913
+ padOpt("-f ARG -output-format ARG", "Set output format for Soot")

src/main/java/soot/SootMethod.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public boolean isPhantom() {
230230
* Returns true if this method is not phantom, abstract or native, i.e. this method can have a body.
231231
*/
232232
public boolean isConcrete() {
233-
return !isPhantom() && !isAbstract();
233+
return !isPhantom() && !isAbstract() && (!isNative() || Options.v().native_code());
234234
}
235235

236236
/**

src/main/xml/options/soot_options.xml

+12
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,18 @@
929929
recovered (i.e., loaded again) easily.
930930
</long_desc>
931931
</boolopt>
932+
<boolopt>
933+
<name>Enable native code</name>
934+
<alias>nc</alias>
935+
<alias>native-code</alias>
936+
<default>false</default>
937+
<short_desc>Enables native methods to be concrete. Needed for analyzing the Java Native Interface.</short_desc>
938+
<long_desc>
939+
This option is needed, when analyzing native code. Particularly when using the Java Native Interface (JNI).
940+
If this option is enabled (set true), it allows native methods to be concrete. This flag will be checked in the
941+
SootMethod.isConcrete() method, allowing native methods to have a body.
942+
</long_desc>
943+
</boolopt>
932944
</section>
933945
<section>
934946
<name>Output Options</name>

0 commit comments

Comments
 (0)