如何使静态链接的ELF文件加载LD

如何使静态链接的ELF文件加载LD

本文介绍了如何使静态链接的ELF文件加载LD_PRELOAD .so的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有静态链接的二进制文件(ELF文件),没有动态段,.dymsym节,并且不执行LD_PRELOAD命令等.我该如何创建假的虚拟动态段来激活动态加载程序并执行LD_PRELOAD命令?

I have static linked binary (ELF file) it doesn't have dynamic segment, .dymsym sections and it doesn't perform LD_PRELOAD command and etc.How could i create fake dummy dynamic segment to activate dynamic loader and perform LD_PRELOAD command?

推荐答案

你不能.

即使可以,使LD_PRELOAD预先加载某些内容也会 没用:通常您希望在LD_PRELOAD ed库中插入一些符号,但这要求这些符号必须 unresolved ,或者至少已导出到其动态符号表中.静态链接的可执行文件没有任何未解析的符号,也没有动态的符号表.

Even if you could, getting LD_PRELOAD to preload something would still be useless: usually you want to interpose some symbols in your LD_PRELOADed library, but that requires these symbols to be unresolved in the main binary, or at least exported in its dynamic symbol table. A statically linked executable doesn't have any unresolved symbols, nor a dynamic symbol table by definition.

这篇关于如何使静态链接的ELF文件加载LD_PRELOAD .so的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 08:30