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?
Asked
Active
Viewed 3,664 times
5

yugr
- 19,769
- 3
- 51
- 96

Ibraim Ganiev
- 8,934
- 3
- 33
- 52
1 Answers
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).

yugr
- 19,769
- 3
- 51
- 96
-
1I 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. – Ibraim Ganiev May 18 '18 at 21:36
-
1@IbraimGaniev Yes, I personally try to avoid `nm` because it's often imprecise. – yugr May 19 '18 at 09:10
-
What is an explicit export file? – rostamn739 Apr 27 '20 at 06:19
-
@rostamn739 I've added a link – yugr Jul 16 '20 at 03:54