2

With IBM's ld linker there is one option -bexport :filename.

In this file we have the names of the functions we need to export at the time of linking.

But in ubuntu I am not able to find this and it gives following error /usr/bin/ld: invalid BFD target `export:stx_export'

Please suggest what can I do in ubuntu to export such files at the time of linking. Thanks in advance.

Baris Demiray
  • 1,539
  • 24
  • 35
Grv
  • 273
  • 3
  • 14
  • 1
    Documentation is here: https://gcc.gnu.org/onlinedocs/gcc/ – alk Aug 26 '15 at 13:25
  • found --dynamic-list=stx_export but i am not able to find the format of dynamic list file. i tried global:TPCALL; global:TPACALL; but it gave the error syntax error in dynamic list – Grv Aug 26 '15 at 14:23

2 Answers2

1

There is a -retain-symbols-file option in GNU ld:

AIX: -Wl,-bE:something.exp
GNU: -Wl,--retain-symbols-file=something.exp

Edit: As Employed Russian pointed out, when creating a shared lib, ld doesn't honor this file. Thank you, Employed Russian.

Note: if we use libtool with option -export-symbols it uses options like -Wl,-version-script -Wl,.libs/libfoo.ver, where libfoo.ver is created from the export file automagically:

{ global:
const_var2ptr;
const_var2ptr2;
init_var;
lt_libaix_modcall_LTX_preloaded_symbols;
uninit_var;
var2ptr;
vartest2_fun;
vartest_fun;
local: *; };
Lorinczy Zsigmond
  • 1,749
  • 1
  • 14
  • 21
  • Hey thanks for this option. but when i used this option at the time of linking ..i think it is only considering the symbols that are in the file...not corresponding the symbols linked. – Grv Aug 27 '15 at 11:34
  • Couldn't say I understand your problem... What command did you try, what result did you expect, and what happened instead? – Lorinczy Zsigmond Aug 27 '15 at 11:36
  • 1
    @LorinczyZsigmond As far as I can tell, `--retain-symbols-file` does absolutely *nothing* when linking a shared library. – Employed Russian Aug 28 '15 at 04:04
1

The standard way to achieve this on Linux is with a version script. This answer provides details.

Community
  • 1
  • 1
Employed Russian
  • 199,314
  • 34
  • 295
  • 362