简体   繁体   English

gcc链接选项/ LOCAL_CFLAGS -rdynamic有什么作用

[英]What does gcc linking option / LOCAL_CFLAGS -rdynamic do

I am working on an android NDK project. 我正在开发一个Android NDK项目。 When I try to modify the project file (Android.mk) I found the linking option -rdynamic after reading the reference, I still not sure the meaning of the flag. 当我尝试修改项目文件(Android.mk)时,在阅读参考文献后发现链接选项-rdynamic,我仍然不确定该标志的含义。

The project I am working on. 我正在从事的项目。 It has two parts: - Multiple client applications. 它分为两个部分:-多个客户端应用程序。 - Multiple shared libraries. -多个共享库。 (each client has a corresponding shared library) - Background daemon processes: a process manager and a launcher. (每个客户端都有一个对应的共享库)-后台守护进程:一个进程管理器和一个启动器。

First, a client application. 首先,一个客户端应用程序。 Once the client starts to run, it is able to communicate with the manager process. 客户端开始运行后,便可以与管理器进程进行通信。 The manager will use dlopen() to load corresponding shared library based on the launcher process. 管理器将根据启动程序使用dlopen()加载相应的共享库。 After that, the manager will create a new launcher process. 之后,管理员将创建一个新的启动程序。

I felt that the link flag has something to do with the background process, but not sure. 我觉得链接标志与后台进程有关,但不确定。

Thanks 谢谢


reference: 参考:
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options
-rdynamic -动态
Pass the flag -export-dynamic to the ELF linker, on targets that support it. 在支持它的目标上,将标志-export-dynamic传递给ELF链接器。 This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. 这指示链接器将所有符号(不仅是已使用的符号)添加到动态符号表中。 This option is needed for some uses of dlopen or to allow obtaining backtraces from within a program. 对于dlopen的某些用途或为了从程序内部获取回溯,此选项是必需的。

Adding -rdynamic to LOCAL_CFLAGS will do nothing, as -rdynamic is a linker flag. 添加-rdynamicLOCAL_CFLAGS不会做任何事情,因为-rdynamic是一个链接器标志。 You need to add it to LOCAL_LDFLAGS . 您需要将其添加到LOCAL_LDFLAGS

For a more thorough explanation of -rdynamic , see https://stackoverflow.com/a/12636790/632035 (I know the question isn't the same, but the answer explains the flag well). 有关-rdynamic的更全面的说明,请参阅https://stackoverflow.com/a/12636790/632035 (我知道问题并不相同,但是答案很好地解释了该标志)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM