Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will adding the -rdynamic linker option to gcc/g++ impact performance?

Tags:

I want to get the stack trace when the application crashes. I understand that the -rdynamic option enables to get the complete stack trace with the function names. But I'm concerned if there will be any impact on the performance of my application.

like image 656
Anirudh Jayakumar Avatar asked Sep 28 '12 05:09

Anirudh Jayakumar


People also ask

Does linker optimize?

Link Time Optimization (LTO) refers to program optimization during linking. The linker pulls all object files together and combines them into one program. The linker can see the whole of the program, and can therefore do whole-program analysis and optimization.

Does GCC include a linker?

c "). GCC uses a separate linker program (called ld.exe ) to perform the linking.

What does the GCC G option do?

gcc -g generates debug information to be used by GDB debugger.

Is GCC a compiler or linker?

The GNU Compiler Collection (gcc) The GNU Compiler Collection, gcc, can compile programs written in C, C++, Java and several other languages. It provides many useful command line options and syntax extensions, and also serves as a powerful frontend for the GNU linker, ld.

How to interpret warnings like errors and interrupt compilation in GCC?

Errors are compile interrupting situations. On the other side warnings do not interrupts the compile process , just provide some information about the situation. We can made gcc to interpret warnings like errors and interrupt compilation with -Werror option. Up to now we have provided the gcc options from command line interactively.

How to optimize GCC for embedded systems?

You can find all the details about optimization flags in the “Optimization Options” section of the GNU GCC docs 11. -Os, optimize for size, is generally the optimization flag you will see used for embedded systems. It enables a good balance of flags which optimize for size as well as speed.

What are the options in GCC?

Options: Description: Gcc –c: Compiles source files to object files without linking to any other object files. gcc –Idir: Includes the directories of header files: gcc –llib: link the code with the library files: gcc -o output file: Build the output generated to output file: gcc –w: Disables all warning messages during the compilation. gcc –Wall

What is the difference between GCC and Clang?

By design, Clang generally matches the set of compiler flag options available in the GNU toolchain, but there are a few that are different. For embedded projects, it’s useful to cross-compile the source code with Clang to surface additional issues that GCC may have missed.


1 Answers

Yes, there is, although it is very specific and normally not a cause of concern.

The -rdynamic option instructs the linker to add symbols to the symbol tables that are not normally needed at run time. It means there are more, possibly many more, symbols that the dynamic linker needs to weed through at run time for symbol resolution.

Specifically, since symbol table lookups in GNU based systems are implemented using a hash, having more symbols increases the chance that there would be hash collisions. Since all symols that collide in the hash table sit in a list, the run time linker needs to traverse the list and compare, using memcmp, each symbol name. Having more symbols collide in the hash meaning having longer lists and so it will take more time to resolve each dynamic symbol.

This situation is slightly worse for C++ then C, with the multitude of identically prefixed symbol names due to class names.

In practice, this only effects the very first time that a symbol is used and so, unless your application is very large and contains a lot of symbols, it will not be felt.

In the rare case that your application is that large, tricks like prelinking can be used to overcome the overhead.

like image 157
gby Avatar answered Sep 24 '22 01:09

gby