Why do we need -rdynamic option in gcc? [duplicate]
Asked Answered
B

1

6

By default all symbols are exported to dynamic table, so why would we use -rdynamic flag? Even if we hide some symbols via attributes/-fvisibility=hidden - -rdynamic doesn't change result, it doesn't unhide previously hidden symbols. So what's the point in it?

Brokerage answered 18/5, 2018 at 20:37 Comment(0)
C
12

Symbols are only exported by default from shared libraries. -rdynamic tells linker to do the same for executables. Normally that's a bad idea but sometimes you want to provide APIs for dynamically loaded plugins and then this comes handy (even though one much better off using explicit visibility annotations, version script or dynamic export file).

Cyclopedia answered 18/5, 2018 at 21:13 Comment(4)
I was confused by output of nm utility, it somehow doesn't change type of symbol (T/t for exported/hidden symbols). readelf --dyn-syms works better, and shows effect of -rdynamic.Brokerage
@IbraimGaniev Yes, I personally try to avoid nm because it's often imprecise.Cyclopedia
What is an explicit export file?Sexism
@Sexism I've added a linkCyclopedia

© 2022 - 2024 — McMap. All rights reserved.