如何重命名 arm elf .so 文件中的动态符号? [英] How to rename dynamic symbols in arm elf .so file?

查看:31
本文介绍了如何重命名 arm elf .so 文件中的动态符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Android APK 中修改一个 so.任务是重命名so中的动态符号(即函数名).

I need to modify a so inside an Android APK. The task is to rename the dynamic symbols in side the so (which is the function name).

例如,从 Java_com_example_abc_.... 更改为 Java_com_yahoo_zzz_....

For example, change from Java_com_example_abc_.... to Java_com_yahoo_zzz_....

我尝试用WinHex直接搜索替换文字,apk启动报错.好像 .hash 部分也需要更新,但是我不知道如何更新 .hash 部分.

I try to use WinHex directly search and replace text words, the apk startup error. Seems like the .hash section also needs to be updated, but i do not know how to update the .hash section.

我的问题是重命名动态符号的正确或优选方法是什么?

My question is what is the correct or preferable way to rename the dynamic Symbol?

我被卡了3天了,请帮帮我,非常感谢!

I heave been stuck for 3 days, please help me, thank you very much!

发现一个帖子可能相关,但他没有给出替代解决方案.https://sourceware.org/ml/binutils/2006-03/msg00266.html

Found a post might related, but he didn't gave the alternative solution. https://sourceware.org/ml/binutils/2006-03/msg00266.html

推荐答案

我被卡住了 3 天,请帮帮我,

I heave been stuck for 3 days, please help me,

您要实现的目标有效是不可能的.

What you are trying to achieve is effectively impossible.

ELF 文件内部结构复杂,你要做的就是把它拆开,重新组装零件.一个类比是将 Intel CPU 分解为晶体管,然后再将它们重新组装成 AMD CPU.

ELF files have complicated internal structure, and what you want to do requires that you break it up and re-assemble the parts. An analogy would be to break an Intel CPU into transistors and re-assemble an AMD CPU from them.

发现一个帖子可能相关

相关的.引用:

基本上它执行以下操作:

Basically it does the following:

  1. 循环 .dynsym 并重新创建 .dynstr
  2. 从头开始重新创建 .hash 表
  3. 计算新的 lma/vma,新的内存布局(.dynstr 大小已更改!)
  4. 根据新布局修复 .dynamic 的内容
  5. 修复 .rel.dyn
  6. 修复 .rel.plt
  7. 再次修复 .dynsym
  8. 写出新的部分内容

在 copy_section 中:将重写的部分排除在复制之外.

In copy_section: exclude the rewritten sections from being copyied.

目前它似乎创建了一个语法上有效的 ELF 文件,但作为.plt 和 .got 之间的距离发生变化,相对寻址在.plt 坏了.此外,.got 必须再次修复.

Currently it seems to create a syntactically valid ELF file, but as the distance between .plt and .got changes, the relative addressing in .plt is broken. Additionally the .got has to be fixed again.

所以作者设法将一些看起来像 AMD CPU 的东西粘在一起,但它不起作用.

So the author managed to glue together something that looks like an AMD CPU, but which doesn't work.

当然,您可以再花 2 周时间了解作者做了什么,然后再花 3 周时间修复剩余的碎片.在那之后,你可能得到一些有时有效的东西.

Sure, you can spend another 2 weeks to understand what the author did, and then another 3 weeks to fix the remaining broken pieces. And after that, you may get something that kind of sometimes works.

你的时间很可能花在别处更好.

Your time is likely better spent elsewhere.

这篇关于如何重命名 arm elf .so 文件中的动态符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆