什么是内存语义dladdr()
?
#define _GNU_SOURCE
#include <dlfcn.h>
int dladdr(void *addr, Dl_info *info);
typedef struct {
const char *dli_fname; /* Pathname of shared object that contains address */
void *dli_fbase; /* Base address at which shared object is loaded */
const char *dli_sname; /* Name of symbol whose definition overlaps addr */
void *dli_saddr; /* Exact address of symbol named in dli_sname */
} Dl_info;
从阅读手册页,不清楚是否dli_fname
:
- 指向一个常量字符串并且永远不需要被释放
- 指向堆数组,用户负责删除它
- 指向全局数组(可能不是,因为它声称是可重入的)
我想同样的问题也适用于dli_sname
,但我怀疑它确实指向一个常量字符串(符号本身)。
用户是否负责删除dli_fname
返回的dladdr()
?