C++ aware version scripts will fail on integral template arguments

Jerry Gamache jerryg@softimage.com
Tue Aug 15 15:23:00 GMT 2000


Title: C++ aware version scripts will fail on integral template arguments





Hello binutils gurus,


If I am adressing the wrong distribution list, please kindly redirect me where this will make a difference (my last bugfix posted here got a depressing 0 replies).

I'd really like to know how the different incarnations of libiberty stay in synch, because the c++filt application built from gcc-2.95.2 works fine, while the same application, coming from binutils-000815, does not work. Both of them use a function called cplus_demangle from libiberty.

Just try to demangle GetBlip__t2TC2Zii12 with both filters to see the difference. The binutils version needs more underscores to give the same result as the gcc one (GetBlip__t2TC2Zii_12_ exactly).

It seems the fix would be to synchronize the two versions of libiberty, which brings two other questions: Whose job is it to do that? and How many other libiberties exist?

Very simple test case which breaks the version-script functionnality:


This is template.cpp:
=======================================
template<class A, int B>
class TC
{
public:
        TC() : m_b(B) {};
        A GetTP() { return m_a; };
        int GetBlip() { return m_b; };
private:
        A m_a;
        int m_b;
};


typedef TC<int,12> TCInt12;
template TCInt12;


typedef TC<double,7> TCDouble7;
template TCDouble7;
=======================================


This is version_script.def
=======================================
XSI_1_0 {
global:
        extern "C++" {
                TC*
        };
local:
        *;
};
=======================================


This is one way to test:
> g++ -c template.cpp -fPIC -o template.o
> ld template.o -shared --version-script=version_script.def -o template.so
> nm template.so
00000414 T GetBlip__t2TC2Zdi7     <<< Pass
000003d8 t GetBlip__t2TC2Zii12     <<< Failed
00000404 T GetTP__t2TC2Zdi7      <<< Pass
000003c8 t GetTP__t2TC2Zii12       <<< Failed because last param has 2 digits
00000000 A XSI_1_0
000014d8 a _DYNAMIC
000014cc a _GLOBAL_OFFSET_TABLE_
00001428 ? __FRAME_BEGIN__
00001538 a __bss_start
000003ec T __t2TC2Zdi7
000003b0 t __t2TC2Zii12
00001538 a _edata
00001538 a _end
000003b0 t gcc2_compiled.


I know I need to use g++ to get the correct static variable initialization, but the single call to ld is easier to debug.

I want to help, but I definitely need a starting point here. I don't see the need to fixup the binutils version of libiberty when the gcc one works. I will probably start by thorougly diffing the the cplus-dem.c files and see if I can come up with an acceptable patch.

Thaks for any advice.


        Jerry Gamache
        SDE Core | Linux
        AVID|Softimage






More information about the Binutils mailing list