To do this in a more automated way, you can use the following script to create a list of all the characters that are newer in your GLIBC than in this version (set on line 2). It creates a glibc.h file (the file name specified by the script argument) that contains all the necessary .symver . You can then add -include glibc.h to your CFLAGS to make sure that it goes into your entire compilation.
This is sufficient if you are not using any static libraries that were compiled without the above. If you do this and you do not want to recompile, you can use objcopy to create a copy of the library with characters renamed to old versions. The second script on the bottom line creates a version of your libstdc++.a that will reference the old glibc characters. Adding -L. (or -Lpath/to/libstdc++.a/ ) will force your program to statically link libstdC ++ without binding a bunch of new characters. If you do not need this, delete the last two lines and the line printf ... redeff .
#!/bin/bash maxver=2.9 headerf=${1:-glibc.h} set -e for lib in libc.so.6 libm.so.6 libpthread.so.0 libdl.so.2 libresolv.so.2 librt.so.1; do objdump -T /usr/lib/$lib done | awk -v maxver=${maxver} -vheaderf=${headerf} -vredeff=${headerf}.redef -f <(cat <<'EOF' BEGIN { split(maxver, ver, /\./) limit_ver = ver[1] * 10000 + ver[2]*100 + ver[3] } /GLIBC_/ { gsub(/\(|\)/, "",$(NF-1)) split($(NF-1), ver, /GLIBC_|\./) vers = ver[2] * 10000 + ver[3]*100 + ver[4] if (vers > 0) { if (symvertext[$(NF)] != $(NF-1)) count[$(NF)]++ if (vers <= limit_ver && vers > symvers[$(NF)]) { symvers[$(NF)] = vers symvertext[$(NF)] = $(NF-1) } } } END { for (s in symvers) { if (count[s] > 1) { printf("__asm__(\".symver %s,%s@%s\");\n", s, s, symvertext[s]) > headerf printf("%s %s@%s\n", s, s, symvertext[s]) > redeff } } } EOF ) sort ${headerf} -o ${headerf} objcopy --redefine-syms=${headerf}.redef /usr/lib/libstdc++.a libstdc++.a rm ${headerf}.redef
patstew Sep 16 '16 at 18:07 2016-09-16 18:07
source share