[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: the mangling of ‘va_list’ has changed in GCC 4.4


On ketvirtadienis 28 Sausis 2010 10:23:20 Fathi Boudra wrote:
> On Wed, Jan 27, 2010 at 11:11 PM, Riku Voipio <riku.voipio@iki.fi> wrote:
> > Interesting. Do you have a example on howto do that?
> http://git.debian.org/?p=pkg-kde/qt4-x11.git;a=blob;f=debian/patches/92_arm
> el_gcc43_valist_compat.diff;h=1db7aa33b73193a8ac0ff563f7a81bff40bfab61;hb=b
> 3e8073df9201386aa420d5f4cab839615a0c6c5

I have recently came across .symver directive [1][2] that is more 
straightforward way to achieve the same thing. In that case, only source file 
(.cpp) needs to be changed. For example:

$ cat test.h
void myprint(const char* fmt, va_list list);

$ cat libtest.cpp
#include <cstdarg>
#include "test.h"

void myprint(const char* fmt, va_list list) {

// va_list mangling has been changed in g++ 4.4
// Add ABI <= g++-4.3 compatibility hack
#if defined __ARM_EABI__ && defined __GNUC__ && (__GNUC__ > 4 || __GNUC__ == 4 
&& __GNUC_MINOR__ >= 4)
__asm__(".symver _Z7myprintPKcSt9__va_list, _Z7myprintPKcPv@@");

"_Z7myprintPKcSt9__va_list" ( myprint(char const*, std::__va_list) )
 here is the new mangling while "_Z7myprintPKcPv ( myprint(char const*, void*) 
)" is the old mangling. When this code is built under g++-4.4, the resulting 
binary will have both symbols with _Z7myprintPKcPv and 
'_Z7myprintPKcSt9__va_list' referring to the same address:

$ objdump -T libtest.so | grep _Z7myprint
000006d8 g    DF .text  00000058  Base        _Z7myprintPKcSt9__va_list
000006d8 g    DF .text  00000058  Base        _Z7myprintPKcPv

1. http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/gnu-
2. http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gnu-

Modestas Vainius <modestas@vainius.eu>

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply to: