Linux 使用 LD_PRELOAD 指定多个文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8474363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 03:36:23  来源:igfitidea点击:

Specifying multiple files with LD_PRELOAD

clinuxdynamicx86

提问by MetallicPriest

I know how to override one library with LD_PRELOAD, for example, as follows.

例如,我知道如何使用 LD_PRELOAD 覆盖一个库,如下所示。

LD_PRELOAD=./getpid.so ./testpid

Now my question is how to override multiple files. Say I want to override both getpid and getid, how would I specify that?

现在我的问题是如何覆盖多个文件。假设我想覆盖 getpid 和 getid,我该如何指定?

回答by codaddict

One option is to have the overridden version of both getpidand getidin a single .sowhich you give to LD_PRELOAD.

一种选择是将两者的覆盖版本放在一个单独的版本中,getpid并提供给.getid.soLD_PRELOAD

回答by William Pursell

According to the ld.somanpage, it is a space separated list. So:

根据ld.so联机帮助页,它是一个空格分隔的列表。所以:

LD_PRELOAD="path1 path2"

ought to work.

应该工作。