在elf文件的notes部分中修改build-id [英] modify build-id in the notes section of the elf file

查看:151
本文介绍了在elf文件的notes部分中修改build-id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在ELF文件的notes部分中修改build-id.我看到有很多工具可以读取elf,但不能对其进行修改.我发现了 elfedit ,但它似乎并没有满足我的需要.甚至有可能吗?

I need to modify a build-id in the notes section of the ELF file. I see there are plenty of tools to read elf but not to modify them. I found elfedit but it doesn't seem to do what I need. Is it even possible?

这是 readelf

$ readelf -n myelffile 
Displaying notes found in: .note.ABI-tag
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 3.14.0

Displaying notes found in: .note.gnu.build-id
  Owner                Data size        Description
  GNU                  0x00000014       NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: d75a086c288c582036b0562908304bc3a8033235

我正在尝试修改 .note.gnu.build-id部分.

推荐答案

有可能吗?

是的.这是较容易的修改之一,因为注释中的数据完全是任意的,并且没有其他数据引用它.

Yes. This is one of the easier modifications, since the data in the note is completely arbitrary, and no other data refer to it.

您要做的就是找到 .note 部分,依次解码每个音符,直到找到具有 NT_GNU_BUILD_ID 类型的音符,然后用相同的内容覆盖其数据,您选择的长度字节.

All you have to do is find the .note section, decode each note in turn until you find the one with NT_GNU_BUILD_ID type, and overwrite its data with same-length bytes of your choosing.

您是否知道链接器-build-id 0x .... 选项,该选项可让您在链接时放入所需的十六进制数据?如果您可以重新链接二进制文件,则无需修改build-id注释,因为链接器会在初始链接期间将数据愉快地放在那里.

Are you aware of the linker --build-id 0x.... option which allows you to put in whatever hex data you desire at link time? If you can relink your binary, then you wouldn't need to modify the build-id note, as the linker will happily put your data there during the initial link.

这篇关于在elf文件的notes部分中修改build-id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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