- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法让 objcopy --rename-sym
工作。
在一个新的 Android 项目中,我创建了目录 jni 和文件 stub.c:
#include <jni.h>
#include "dlog.h"
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
DLOG("~~~~~~~~~~~~~~~~~~~~~~~ JNI_OnLoad ~~~~~~~~~~~~~~~~~~~~~~~~~");
return JNI_VERSION_1_6;
}
int myfunc() { return 0; }
命令 ~/an/ndk-build -j 4
说:
[armeabi-v7a] Install : libTest.so => libs/armeabi-v7a/libTest.so
[armeabi] Install : libTest.so => libs/armeabi/libTest.so
[x86] Install : libTest.so => libs/x86/libTest.so
[mips] Install : libTest.so => libs/mips/libTest.so
(有链接:
an -> ~/android-ndk-r9d/
ax -> android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86/bin/
ay -> ~/android-ndk-r9d/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/
)
然后我做
~/ax/arm-linux-androideabi-objcopy --redefine-sym myfunc=ourfunc libTest.so libTest-x.so
并获得一个相同 libTest-x.so。当然,我尝试了 ~/ay/*objcopy
,结果相同。我没有收到任何错误消息。 myfunc() 仍然存在,没有 ourfunc()。
如何重命名 .so 文件中的函数?
最佳答案
重命名函数的最简单方法是在不更改长度和哈希值的情况下更改名称。
保持相同的哈希值有点棘手,您必须了解 elf_hash()
的工作原理::
elfhash.c:
#include <stdio.h>
unsigned long
elf_hash(const unsigned char *name)
{
unsigned long h = 0 , g ;
while (*name)
{
h = ( h << 4 ) + * name ++ ;
if (g = h & 0xf0000000) {
h ^= g >> 24 ;
}
h &= ~g ;
}
return h ;
}
int main(int argc, char**argv) {
char* name = argv[1];
printf("[%s]\n",name);
unsigned long hash = elf_hash(name);
printf("0x%lx\n",hash);
return 0;
}
[[编辑:更新版本位于
https://github.com/18446744073709551615/reDroid/blob/master/hosttools/elfhash.c
(它找到一个具有相同哈希值的名称)
]]
gcc
它,用法是:
$ ./a.out myFunc
[myFunc]
0x74ddc43
$ ./a.out myFums
[myFums]
0x74ddc43
$ ./a.out myFuoC # Note: a different hash value
[myFuoC]
0x74ddc33
$ ./a.out myFupC
[myFupC]
0x74ddc43
ASCII表的相关部分是:
! " # $ % & ' ( ) * + , - . /
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
@ A B C D E F G H I J K L M N O
P Q R S T U V W X Y Z [ \ ] ^ _
` a b c d e f g h i j k l m n o
p q r s t u v w x y z { | } ~
然后要么
sed s/myFunc/myFums/g <libStuff.so >libStufx.so
或通过 hexedit libStuff.so
手动替换。
关于android NDK : objcopy --rename-sym does not work (need to rename a function in a . 所以文件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23008846/
我最近注意到rlang::sym在匿名函数中似乎不起作用,我也不明白为什么。这是一个例子,非常笨拙和丑陋,但我认为它说明了这一点 require(tidyverse) data % m
我有两个目录,每个目录都包含一个日期分区的展开表。正如预期的那样,每个目录都有自己的 sym 文件。这些表完全相同。 我想将其合并到一个目录中,但这样做时遇到问题。最初我尝试在另一个目录中创建分区的软
我想创建许多变量,例如 x1、x2、x3 以在 syms 旁边使用,因此它看起来像这样: 符号 x1 x2 x3 x4 ... x50 x51....xn n 是我需要的变量数量。 有什么办法可以做到
我正在编写一个 R 脚本,我需要允许用户指定将被手动处理的变量的名称,即 var % replace_na(list(sym(var) = 0)) 但是没用... 最佳答案 我们还可以将replace
我有一些大文件需要连接成一个巨大的文件以通过不接受标准输入的软件包。如有必要,我宁愿不复制硬盘驱动器上现有文件的内容,并且正在寻找一种快捷方式,它基本上可以在打开时静默执行 cat files*.tx
library(tidyverse) input_name expr: ^filter(data, "birth_year" == 19) env: global 第 6 行 exp
我一直在互联网上寻找解决此问题的方法,但找不到任何我能理解的内容。我正在做一个教程并复制老师输入的所有内容,所以我只是在学习..但是当我这样做时,它一直给我这个错误。因为我是新手,所以我不知道这到底意
我正在尝试对 Linux 系统上崩溃的二进制文件“TestApp”进行事后分析。 我有一个二进制文件和共享对象的副本,它们被复制到路径中的设备上: /usr/public/target 此文件夹包含被
我搜索了一些“输入参数太多”。问题,但我还没有找到答案... 我是 matlab 的新手,所以我有以下问题 我想使用 principalvalue 方法进行集成,但我收到以下消息 syms w f
我在尝试使符号替换变得更快时遇到了很多麻烦 - 也就是说,用 in 替换符号表达式中的变量并得到一个 double 值。 我正在创建一个复杂的函数 f,并计算它的雅可比 df。这是一个合理的速度,我可
仅适用于 Matplotlib <1.4.0! 我有一个奇怪的效果,如果我改变用于绘制它们的符号,离群值的颜色会改变。 ( Documentation for Boxplot ) 在我看来像是一个错误
我在 stash@{4} 中有一组更改,我想应用这些更改,但这些更改会 merge 到工作副本(或新提交)中这样可以通过预处理器符号选择任一版本。 (这是 GNU diff 和 diff3 程序的一个
本文整理了Java中com.ximpleware.xpath.Yylex.sym()方法的一些代码示例,展示了Yylex.sym()的具体用法。这些代码示例主要来源于Github/Stackoverf
我正在尝试使用此踏板中的代码( Using Matlab to plot a cylinder bounded by a plane )使用 fsurf 的示例。 当我更改声明的 syms 变量的名称
我定义了以下功能: function y = pos(c) % function outputs the maximum of c and 0 %ie. pos(c)=0 if c is negati
当我付出时, syms z 我最终得到了, Undefined function 'syms' for input arguments of type 'char'. 有人可以帮忙吗?提前致谢。
我的研究涉及将问题从标量公式转换为矩阵公式,反之亦然。有时找到相应的矩阵模式和对其执行必要的操作可能会变得不明显且难以可视化(尤其是当生成的矩阵模式很大且稀疏时)。为了验证我的推导,我通常使用 MAT
本文整理了Java中com.ximpleware.extended.xpath.Yylex.sym()方法的一些代码示例,展示了Yylex.sym()的具体用法。这些代码示例主要来源于Github/S
为什么我会收到此错误消息? #!perl6 use v6; my @a = 1..3; my @b = 7..10; my @c = 'a'..'d'; for zip(@a;@b;@c) -> $n
“!!”是什么意思在R中使用,为什么要使用它? 具体来说,我正在看一个涉及短语的函数a = !!sym("x"),其中"x"是字符串。我以为sym通过将字符串转换为对象来工作,因此a = sym("x
我是一名优秀的程序员,十分优秀!