这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@andvgal
Copy link
Contributor

@andvgal andvgal commented Jun 30, 2022

During some DEX rewriting using the latest features, exceptions get thrown because of missing handling of some reference types.

Fixed that, and also went through the code to fix all other missing stuff. In some cases, maybe no real opcode would be coded such way that some code path would be triggered, but this way is more safe.

Also, likely fixed a bug of interning METHOD_HANDLE type.

@andvgal andvgal force-pushed the misc-ref-handling-fix branch from f6923e3 to e5c9118 Compare July 25, 2022 06:56
@andvgal andvgal changed the title Fixing missing reference type handling Fixing missing reference type handling for rewriting purposes Jul 25, 2022
@andvgal
Copy link
Contributor Author

andvgal commented Jul 25, 2022

@JesusFreke perhaps, with this one, it would be good to release v2.5.3 as a number of important fixes have piled up.

@andvgal andvgal force-pushed the misc-ref-handling-fix branch from e5c9118 to 8d139eb Compare July 27, 2022 03:52
@salvogiangri
Copy link

@andvgal the following error happens to me when trying to build with the applied 8d139eb patch:

> Task :dexlib2:compileJava FAILED
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:47: error: cannot find symbol
public class InstructionRewriter implements Rewriter<Instruction> {
                                            ^
  symbol: class Rewriter
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:48: error: cannot find symbol
    @Nonnull protected final Rewriters rewriters;
                             ^
  symbol:   class Rewriters
  location: class InstructionRewriter
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:50: error: cannot find symbol
    public InstructionRewriter(@Nonnull Rewriters rewriters) {
                                        ^
  symbol:   class Rewriters
  location: class InstructionRewriter
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:318: error: class InstructionRewriter.RewrittenInstruction4rcc is already defined in class InstructionRewriter
    protected class RewrittenInstruction4rcc extends BaseRewrittenDualReferenceInstruction<Instruction4rcc>
              ^
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:54: error: method does not override or implement a method from a supertype
    @Nonnull @Override public Instruction rewrite(@Nonnull Instruction instruction) {
             ^
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:95: error: cannot find symbol
                        (MethodProtoReference)reference);
                         ^
  symbol:   class MethodProtoReference
  location: class InstructionRewriter
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:98: error: cannot find symbol
                        rewriters, (MethodHandleReference)reference);
                                    ^
  symbol:   class MethodHandleReference
  location: class InstructionRewriter
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:100: error: cannot find symbol
                return rewriters.getCallSiteReferenceRewriter().rewrite((CallSiteReference)reference);
                                                                         ^
  symbol:   class CallSiteReference
  location: class InstructionRewriter
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/InstructionRewriter.java:102: error: cannot find symbol
                throw new ExceptionWithContext("Invalid reference type: %d",
                          ^
  symbol:   class ExceptionWithContext
  location: class InstructionRewriter
/home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/rewriter/RewriterModule.java:70: error: incompatible types: InstructionRewriter cannot be converted to Rewriter<Instruction>
        return new InstructionRewriter(rewriters);
               ^
Note: /home/mesa/Scrivania/Android/Sorgenti/m/smali/dexlib2/src/main/java/org/jf/dexlib2/analysis/CustomInlineMethodResolver.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
10 errors

Any idea on what could be the cause?

@andvgal
Copy link
Contributor Author

andvgal commented Mar 20, 2023

@blackmesa123 pardon, I missed GH notification, if there was any.

Note: this PR had incomplete code changes unfortunately (not pushed).

A new PR has been submitted against Google's upstream google/smali#11
So, closing,

@andvgal andvgal closed this Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants