ARM assembly learning (IV)

Publisher:温柔心情Latest update time:2016-07-12 Source: eefocusKeywords:arm Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Android JNI Implementation

1. Static implementation of jni: first get the declaration of the native method from Java, and then implement the declared method through JNI.
2. Dynamic implementation of jni: first implement the native method through JNI overloading JNI_OnLoad(), and then call the native method directly in Java.

If the static implementation is used, it is easy to search for the exported function in IDA without encryption. If the dynamic
implementation is used, it can also play a certain role in hiding. The exported part does not directly show the function name called by the Java layer, but the bound function name.

Native layer:
register related functions in JNI_OnLoad

JNIEXPORT jstring JNICALL native_hello(JNIEnv *env, jclass clazz)
{
return (*env)->NewStringUTF(env, "hello load jni.");
}

// Binding table for Java and JNI functions

static JNINativeMethod method_table[] = {
{ "HelloLoad", "()Ljava/lang/String;", (void*)native_hello },//绑定
};


Java layer:
//Methods registered in jni

public native String HelloLoad();


2. Calling Arm assembly code in Android

Android.mk file

# This file is jni/Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_ARM_MODE := arm

# Name of the local module
LOCAL_MODULE := hello-jni
# The files that make up the source code
LOCAL_SRC_FILES := hello-jni.c multiple.s

include $(BUILD_SHARED_LIBRARY)

multiple.s conforms to GNU syntax

@ This file is jni/multiple.s
.text
.align    2
.global    armFunction
.type    armFunction, %function
armFunction:
@ Multiply by 10. Input value and return value in r0
stmfd    sp!, {fp,ip,lr}
mov r3, r0, asl #3
add    r0, r3, r0, asl #1
ldmfd    sp!, {fp,ip,lr}
bx    lr
.size    armFunction, .-armFunction

Directly call armFunction(input) in c

Keywords:arm Reference address:ARM assembly learning (IV)

Previous article:ARM assembly learning (V)
Next article:ARM assembly learning (Part 3)

Recommended ReadingLatest update time:2024-11-23 10:51

ARM9(S3C2440) Touch Screen
How touch screens work Touch screens are divided into types: resistive, capacitive, surface acoustic wave, infrared scanning, etc. The most commonly used is the 4-wire resistive touch screen.     Touch screen workflow (1) Set the touch screen interface to wait for interrupt mode and wait for the touch scree
[Microcontroller]
ARM Study Notes 12——GNU ARM Assembly Pseudo-Operation
1. .section   1.1 Syntax format      .section section_name ]]    1.2 Function     Define a segment. Each segment starts with the segment name and ends with the next segment name or the end of the file.     The segment flags allowed by the ELF format are: a: allocatable                w: writable segment   
[Microcontroller]
Design of autonomous obstacle avoidance robot fish based on ARM-Linux
With the development and progress of science and technology, intelligent machines with special functions have emerged, such as the pet robot dog produced by Sony that can "feel", "learn" and "feed" with self-awareness, and the SAFFIR firefighting robot upgraded and modified based on the CHARLI-L1 robot developed by Vir
[Microcontroller]
Design of autonomous obstacle avoidance robot fish based on ARM-Linux
DMA working principle of arm7-PDC method
dma current group ptr and len PDC_RPR PDC_RCR dma next group of spare ptr and len PDC_RNPR PDC_RNCR   When the device starts, PDC_RCR will decrease from the maximum until it reaches 1. When another data is received, PDC_RPR will be automatically set to the value in PDC_RNPR by the CPU,   and PDC_RCR will be set
[Microcontroller]
Design of wireless home gateway based on ARM-UClinux
introduction   With the rapid development of network technology and information appliances, more and more families are demanding to establish home networks. The home gateway is the core of the entire home network. It mainly realizes Internet access, remote control, and the functions of connecting heterogeneous subnets
[Analog Electronics]
Design of wireless home gateway based on ARM-UClinux
Design of farmland production detection management system based on ARM, WiFi and Bluetooth
In recent years, the further development of agriculture in Xinjiang has been seriously restricted due to the stagnation of farmland production management technology and management model, the uneven level of agricultural production management personnel, the lack of basic agricultural data information, and the inability
[Microcontroller]
Design of farmland production detection management system based on ARM, WiFi and Bluetooth
Design of ECG Defibrillation Simulation System Based on ARM9
With the development of society, people's awareness of medical care is getting stronger and stronger, so the training of doctors has become a very important link. As a major aspect of doctor training, ECG defibrillation technology can often save people from danger in an emergency if the operation is standardized and
[Medical Electronics]
Design of ECG Defibrillation Simulation System Based on ARM9
Design and implementation of graphics generation circuit based on Zynq
1. Introduction Graphics display plays an important role in aircraft cockpit display systems . The size of the main display is increasing, the resolution is improving, and it is increasingly developing towards large screen, integration, information and intelligence . With the improvement of resolution, the amount of
[Microcontroller]
Design and implementation of graphics generation circuit based on Zynq
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号