So, I have asked this question on Stack Overflow (and provided a
possible solution).  But it seems like there might be a bug in g++
involved here, so I wanted to reach out and see if anyone knows a
better way to solve this problem or if this is some kind of bug.  For
additional context, take a look at:
https://stackoverflow.com/questions/79762101/with-g-how-can-i-have-class-member-symbols-evaluated-at-runtime-instead-of-li/79762102#79762102

Long story short, this works for C-style functions:
__attribute__((weak)) void myfunc(void);

But for a C++ member function it does not (I would _expect_ this to work):
__attribute__((weak)) void myclass::myfunc(void);

I *especially* expect the above to work because _this_ works:
__attribute__ ((ifunc ("_custom_resolver"))) void myclass::myfunc(void);

I would prefer not to do this though, because the "ifunc" thing is
pretty ugly.  It is especially gross because for the constructors it
doesn't seem to use the correct mangled name, so I need to specify the
symbol manually for these cases:
__attribute__ ((ifunc ("_custom_resolver_A"))) asm("_ZN7myclassC1Ev")
myclass::myclass(void);
__attribute__ ((ifunc ("_custom_resolver_B"))) asm("_ZN7myclassC1Ei")
myclass::myclass(int);

In the void case, for some reason, g++ tries to use the symbol
_ZN7myclassC4Ev instead of _ZN7myclassC1Ev.  This feels like a bug,
but it could be that that's on purpose.  So, if anyone has any insight
as to what could be done differently here (or if I should be filing a
bug) then I'd love to hear your thoughts.

Best,
Erich

Reply via email to