> Do you still need mkldexport.sh? Surely there's a better way to do that > in year 2024. Some quick googling says there's a '-bexpall' option to > 'ld', which kind of sounds like what we want. Will that work? How do > other programs do this?
We have noticed couple of caveats with these flags -bexpall/-bexpfull in other opensource tools on AIX. This option would export too many symbols causing problems because a shared library may re-export symbols from another library causing confused dependencies, duplicate symbols. We have similar discussion wrt to these flag in Cmake https://gitlab.kitware.com/cmake/cmake/-/issues/19163 Also, I tried some sample program to verify the same as below >> cat foo.c #include <stdio.h> #include <string.h> int func1() { char str1[] = "Hello ", str2[] = "world! "; strcat(str1,str2); puts(str1); return 0; } >> gcc -c foo.c -o foo.o >> gcc -shared -Wl,-bexpall -o foo.so foo.o >> dump -Tov foo.so foo.so: ***Object Module Header*** # Sections Symbol Ptr # Symbols Opt Hdr Len Flags 4 0x00000d88 120 72 0x3002 Flags=( EXEC DYNLOAD SHROBJ DEP_SYSTEM ) Timestamp = "Sep 17 10:17:35 2024" Magic = 0x1df (32-bit XCOFF) ***Optional Header*** Tsize Dsize Bsize Tstart Dstart 0x00000548 0x0000010c 0x00000004 0x10000128 0x20000670 SNloader SNentry SNtext SNtoc SNdata 0x0004 0x0000 0x0001 0x0002 0x0002 TXTalign DATAalign TOC vstamp entry 0x0005 0x0004 0x20000750 0x0001 0xffffffff maxSTACK maxDATA SNbss magic modtype 0x00000000 0x00000000 0x0003 0x010b RE ***Loader Section*** ***Loader Symbol Table Information*** [Index] Value Scn IMEX Sclass Type IMPid Name [0] 0x2000068c .data RW SECdef [noIMid] __rtinit [1] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) __cxa_finalize [2] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXI_shr_o [3] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXD_shr_o [4] 0x00000000 undef IMP DS EXTref libc.a(shr.o) __strtollmax [5] 0x00000000 undef IMP DS EXTref libc.a(shr.o) puts [6] 0x200006f4 .data EXP DS Ldef [noIMid] __init_aix_libgcc_cxa_atexit [7] 0x20000724 .data EXP DS Ldef [noIMid] _GLOBAL__AIXI_foo_so [8] 0x20000730 .data EXP DS Ldef [noIMid] _GLOBAL__AIXD_foo_so >> [9] 0x2000073c .data EXP DS SECdef [noIMid] strcat [10] 0x20000744 .data EXP DS Ldef [noIMid] func1 The code makes use of strcat from libc but re-exports the symbol (because of -bexpall). As of now due to the limitation with these flags (-bexpall / -bexpfull ? ), the solution here is to continue to extract the symbols from the object files and use that export file as part of building the shared library. (Continue to use the mkldexport.sh script to generate the export symbols). Thanks, Sriram.