[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Objdump "bad mangled name" if static C++ functions
From: |
Craig Carey |
Subject: |
Objdump "bad mangled name" if static C++ functions |
Date: |
Tue, 24 Jun 2003 04:35:18 +1200 |
Here is a simple GCC C++ program that objdump crashes on.
For this example showing an objdump bug, g++ does not get a
"-ggdb" option.
I am observing that Objdump with the "-g" option can't process
a 170,091 KiB [*.a] library file that I try it on. It would be
nice to get that running for the barely used low level feature
of GCC (GNAT) Ada 95 that allows direct binding to C++ code &
'classes' (i.e. without using C, etc).
$ cat gor.h
--------------------------------------
#define EXPORT __declspec(dllexport)
class EXPORT cla {
public:
static char* fun ();
~cla ();
};
--------------------------------------
$ cat gor.cpp
------------------------------------------
#include "gor.h"
char* cla::fun () { return "cla::fun"; }
cla::~cla() { }
------------------------------------------
$ g++.exe -g -c -Wall gor.cpp -o gor.o 2>&1 | head -30
$ nm -g gor.o
----------------------------
0000000a T __ZN3cla3funEv
0000001a T __ZN3claD1Ev
00000014 T __ZN3claD2Ev
----------------------------
$ objdump -g gor.o
---------------------------------------------------------
...
bad mangled name `3cla_ZN3cla3funEv'
...
---------------------------------------------------------
The bug is in binutil's "stabs.c".
The invalid symbol name is Not in the *.o file.
The stabs.c code creates that symbol.
It seemed to be incorrectly deciding that a static function
is a 'static' thing of another kind. Then it prepends extra text
and crashes on detecting unexpected preceding text.
At 2003-06-22 01:10 +1200 Sunday, Craig Carey wrote:
Subject: Objdump fails on C++ -ggdb object files
...
>
>File: "string.h" :
>-----------------------------------------------------------------------
>class __declspec(dllexport) T1 {
> public:
> int W1;
> ~T1() { }
> static T1 P1();
>};
>-----------------------------------------------------------------------
>
>File: "string.cpp" :
>-----------------------------------------------------------------------
>#include "string.h"
>
>T1 T1::P1() {
> T1 res;
> return res;
>}
>-----------------------------------------------------------------------
>
...
>$ L:/gcc/bin/g++ -c -ggdb -Wall -o string.o string.cpp
...
>bad mangled name `2T1_ZN2T12P1Ev'
...
Craig Carey