Remove the "rewrite labels" functionality.

If anyone still needs to rewrite labels from the old format to the new format, they can grab an older version of smali to use

git-svn-id: https://smali.googlecode.com/svn/trunk@539 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
JesusFreke@JesusFreke.com 2009-12-31 22:34:50 +00:00
parent da3b7b1150
commit b471d5d91f
4 changed files with 3 additions and 1658 deletions

View File

@ -50,28 +50,6 @@
</includes> </includes>
</configuration> </configuration>
</execution> </execution>
<execution>
<id>smaliLexer_old</id>
<goals>
<goal>antlr</goal>
</goals>
<configuration>
<includes>
<include>org/jf/smali/smaliLexer_old.g</include>
</includes>
</configuration>
</execution>
<execution>
<id>labelConverter</id>
<goals>
<goal>antlr</goal>
</goals>
<configuration>
<includes>
<include>org/jf/smali/labelConverter.g</include>
</includes>
</configuration>
</execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>

View File

@ -1,62 +0,0 @@
/*
* [The "BSD licence"]
* Copyright (c) 2009 Ben Gruver
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
parser grammar labelConverter;
options {
output=template;
rewrite=true;
tokenVocab=smaliLexer_old;
}
@header {
package org.jf.smali;
}
@members {
private String convertLabel(String label) {
if (label.charAt(0) != ':') {
return ':' + label.substring(0, label.length()-1);
} else {
return label;
}
}
}
top :
((LABEL)=>label | .)*;
label :
(LABEL)=>LABEL
-> template(label={convertLabel($LABEL.text)})
"<label>";

File diff suppressed because it is too large Load Diff

View File

@ -83,7 +83,6 @@ public class main {
} }
boolean sort = false; boolean sort = false;
boolean rewriteLabels = false;
boolean fixStringConst = true; boolean fixStringConst = true;
boolean fixGoto = true; boolean fixGoto = true;
@ -107,33 +106,17 @@ public class main {
return; return;
} }
if (commandLine.hasOption("r")) {
rewriteLabels = true;
}
if (commandLine.hasOption("o")) { if (commandLine.hasOption("o")) {
if (rewriteLabels) {
System.err.println("The --output/-o option is not compatible with the --rewrite-labels/-r option. Ignoring");
} else {
outputDexFile = commandLine.getOptionValue("o"); outputDexFile = commandLine.getOptionValue("o");
} }
}
if (commandLine.hasOption("d")) { if (commandLine.hasOption("d")) {
if (rewriteLabels) {
System.err.println("The --dump/-d option is not compatible with the --rewrite-labels/-r option. Ignoring");
} else {
dumpFileName = commandLine.getOptionValue("d", outputDexFile + ".dump"); dumpFileName = commandLine.getOptionValue("d", outputDexFile + ".dump");
} }
}
if (commandLine.hasOption("s")) { if (commandLine.hasOption("s")) {
if (rewriteLabels) {
System.err.println("The --sort/-s option is not compatible with the --rewrite-labels/-r option. Ignoring");
} else {
sort = true; sort = true;
} }
}
if (commandLine.hasOption("c")) { if (commandLine.hasOption("c")) {
fixStringConst = false; fixStringConst = false;
@ -162,13 +145,6 @@ public class main {
} }
} }
if (rewriteLabels) {
if (doRewriteLabels(filesToProcess)) {
System.exit(1);
}
System.exit(0);
}
DexFile dexFile = new DexFile(); DexFile dexFile = new DexFile();
boolean errors = false; boolean errors = false;
@ -250,45 +226,6 @@ public class main {
} }
} }
private static boolean doRewriteLabels(Set<File> files)
throws Exception {
boolean errorOccurred = false;
for (File file: files) {
ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(file));
input.name = file.getAbsolutePath();
smaliLexer_old lexer = new smaliLexer_old(input);
if (lexer.getNumberOfLexerErrors() > 0) {
errorOccurred = true;
continue;
}
TokenRewriteStream tokens = new TokenRewriteStream(lexer);
labelConverter parser = new labelConverter(tokens);
parser.top();
if (parser.getNumberOfSyntaxErrors() > 0) {
errorOccurred = true;
continue;
}
FileWriter writer = null;
try
{
writer = new FileWriter(file);
writer.write(tokens.toString());
} finally {
if (writer != null) {
writer.close();
}
}
}
return !errorOccurred;
}
private static boolean assembleSmaliFile(File smaliFile, DexFile dexFile) private static boolean assembleSmaliFile(File smaliFile, DexFile dexFile)
throws Exception { throws Exception {
ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(smaliFile)); ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(smaliFile));
@ -369,10 +306,6 @@ public class main {
.withDescription("sort the items in the dex file into a canonical order before writing") .withDescription("sort the items in the dex file into a canonical order before writing")
.create("s"); .create("s");
Option rewriteLabelOption = OptionBuilder.withLongOpt("rewrite-labels")
.withDescription("rewrite the input smali files, converting any labels in the old (pre .97) format to the new format")
.create("r");
Option noFixStringConstOption = OptionBuilder.withLongOpt("no-fix-string-const") Option noFixStringConstOption = OptionBuilder.withLongOpt("no-fix-string-const")
.withDescription("Don't replace string-const instructions with string-const/jumbo where appropriate") .withDescription("Don't replace string-const instructions with string-const/jumbo where appropriate")
.create("c"); .create("c");
@ -386,7 +319,6 @@ public class main {
options.addOption(dumpOption); options.addOption(dumpOption);
options.addOption(outputOption); options.addOption(outputOption);
options.addOption(sortOption); options.addOption(sortOption);
options.addOption(rewriteLabelOption);
options.addOption(noFixStringConstOption); options.addOption(noFixStringConstOption);
options.addOption(noFixGotoOption); options.addOption(noFixGotoOption);
} }