public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* objdump : inaccurate demangling for foo(char* const)
@ 2003-09-19  3:50 Alex Vinokur
  2003-09-19  5:42 ` Alex Vinokur
  2003-09-19 18:19 ` Rolf Campbell
  0 siblings, 2 replies; 7+ messages in thread
From: Alex Vinokur @ 2003-09-19  3:50 UTC (permalink / raw)
  To: cygwin

==========================================
Windows 2000 Professional
CYGWIN_NT-5.0 1.5.4(0.94/3/2)
GNU gcc version 3.2 20020927 (prerelease)
GNU objdump 2.14.90 20030901
==========================================


It seems that objdump inaccurately demangles foo(char* const).
  Low-level symbol name of foo(char* const) is valid : __Z3fooPc
  But user-level symbol name obtained after demangling is inaccurate : foo(char*).



====== C++ code : BEGIN ======
// File t.cpp

void foo3 (char*) {}

====== C++ code : END ========



====== Compilation : BEGIN ======

$ g++ -c t.cpp

====== Compilation : END ========



====== objdump : BEGIN ======

$ objdump -d t.o

t.o:     file format pe-i386

Disassembly of section .text:

00000000 <__Z3fooPc>:    // OK
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
   5: 90                    nop
   6: 90                    nop
   7: 90                    nop
   8: 90                    nop
   9: 90                    nop
   a: 90                    nop
   b: 90                    nop
   c: 90                    nop
   d: 90                    nop
   e: 90                    nop
   f: 90                    nop





$ objdump -Cd t.o


t.o:     file format pe-i386

Disassembly of section .text:

00000000 <foo(char*)>:    // Must be foo(char* const)
   0: 55                    push   %ebp
   1: 89 e5                 mov    %esp,%ebp
   3: 5d                    pop    %ebp
   4: c3                    ret
   5: 90                    nop
   6: 90                    nop
   7: 90                    nop
   8: 90                    nop
   9: 90                    nop
   a: 90                    nop
   b: 90                    nop
   c: 90                    nop
   d: 90                    nop
   e: 90                    nop
   f: 90                    nop

====== objdump : END ========

--
   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================





--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: objdump : inaccurate demangling for foo(char* const)
  2003-09-19  3:50 objdump : inaccurate demangling for foo(char* const) Alex Vinokur
@ 2003-09-19  5:42 ` Alex Vinokur
  2003-09-19 10:19   ` Ronald Landheer-Cieslak
  2003-09-19 21:08   ` Alexander Osipenko
  2003-09-19 18:19 ` Rolf Campbell
  1 sibling, 2 replies; 7+ messages in thread
From: Alex Vinokur @ 2003-09-19  5:42 UTC (permalink / raw)
  To: cygwin


"Alex Vinokur" <alexvn@connect.to> wrote in message news:bkdtn1$597$2@sea.gmane.org...
> ==========================================
> Windows 2000 Professional
> CYGWIN_NT-5.0 1.5.4(0.94/3/2)
> GNU gcc version 3.2 20020927 (prerelease)
> GNU objdump 2.14.90 20030901
> ==========================================
>

Updated question about objdump.

Low-level and user-level symbol names of foo2(char* const) are foo2(char*)

--------- C++ code ---------
void foo1 (char*) {}
void foo2 (char* const) {}
----------------------------


--------- objdump : Fragments ---------
$ objdump -Cd t.o

t.o:     file format pe-i386

Disassembly of section .text:

00000000 <__Z4foo1Pc>:    // OK

00000006 <__Z4foo2Pc>:    // char*, not char* const


$ objdump -d t.o

t.o:     file format pe-i386

Disassembly of section .text:

00000000 <foo1(char*)>:    // OK


00000006 <foo2(char*)>:    // Not char* const

--------------------------------------

So, is it inaccuracy or convention?


   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: objdump : inaccurate demangling for foo(char* const)
  2003-09-19  5:42 ` Alex Vinokur
@ 2003-09-19 10:19   ` Ronald Landheer-Cieslak
  2003-09-19 17:15     ` Hannu E K Nevalainen (garbage mail)
  2003-09-19 21:08   ` Alexander Osipenko
  1 sibling, 1 reply; 7+ messages in thread
From: Ronald Landheer-Cieslak @ 2003-09-19 10:19 UTC (permalink / raw)
  To: cygwin

AFAIK, const is a compiler directive - there is nothing in the assembler
that make a symbol const. You should see const more like a promise: "I
promise I won't change the value of this variable". That promise can be 
broken by a const-cast, and the assembler code doesn't know anything about
it (AFAIK, there is no const in assembler, but I might be mistaken there).

rlc

On Fri, Sep 19, 2003 at 07:31:12AM +0300, Alex Vinokur wrote:
> 
> "Alex Vinokur" <alexvn@connect.to> wrote in message news:bkdtn1$597$2@sea.gmane.org...
> > ==========================================
> > Windows 2000 Professional
> > CYGWIN_NT-5.0 1.5.4(0.94/3/2)
> > GNU gcc version 3.2 20020927 (prerelease)
> > GNU objdump 2.14.90 20030901
> > ==========================================
> >
> 
> Updated question about objdump.
> 
> Low-level and user-level symbol names of foo2(char* const) are foo2(char*)
> 
> --------- C++ code ---------
> void foo1 (char*) {}
> void foo2 (char* const) {}
> ----------------------------
> 
> 
> --------- objdump : Fragments ---------
> $ objdump -Cd t.o
> 
> t.o:     file format pe-i386
> 
> Disassembly of section .text:
> 
> 00000000 <__Z4foo1Pc>:    // OK
> 
> 00000006 <__Z4foo2Pc>:    // char*, not char* const
> 
> 
> $ objdump -d t.o
> 
> t.o:     file format pe-i386
> 
> Disassembly of section .text:
> 
> 00000000 <foo1(char*)>:    // OK
> 
> 
> 00000006 <foo2(char*)>:    // Not char* const
> 
> --------------------------------------
> 
> So, is it inaccuracy or convention?
> 
> 
>    =====================================
>    Alex Vinokur
>      mailto:alexvn@connect.to
>      http://mathforum.org/library/view/10978.html
>    =====================================
> 
> 
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Problem reports:       http://cygwin.com/problems.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/

-- 
You will have a long and boring life.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: objdump : inaccurate demangling for foo(char* const)
  2003-09-19 10:19   ` Ronald Landheer-Cieslak
@ 2003-09-19 17:15     ` Hannu E K Nevalainen (garbage mail)
  0 siblings, 0 replies; 7+ messages in thread
From: Hannu E K Nevalainen (garbage mail) @ 2003-09-19 17:15 UTC (permalink / raw)
  To: cygwin

> From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com]On Behalf
> Of Ronald Landheer-Cieslak

> AFAIK, const is a compiler directive - there is nothing in the assembler
> that make a symbol const. You should see const more like a promise: "I
> promise I won't change the value of this variable". That promise can be
> broken by a const-cast,

 K&R, 2nd edition, p211 last paragraph, last sentence: "Except that it
should diagnose explicit attempts to change const objects, a compiler may
ignore these qualifiers."

> and the assembler code doesn't know anything about
> it (AFAIK, there is no const in assembler, but I might be mistaken there).

 This is very true, at least for the M68K assemblers that I know of. Nor
have I seen such a thing in x86 assemblers (less knowledge).
But: SECTION's (a program data/code "hunk" - in Amiga terms) can be set to
readonly - which _may_ be enforced depending on set assembler options (i.e.
to generate stuff for ROM).

/Hannu E K Nevalainen, B.Sc. EE -and- long standing M68K <'020 assembler
"guru".
-- UTC+01, DST -> UTC+02  --
--END OF MESSAGE--


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: objdump : inaccurate demangling for foo(char* const)
  2003-09-19  3:50 objdump : inaccurate demangling for foo(char* const) Alex Vinokur
  2003-09-19  5:42 ` Alex Vinokur
@ 2003-09-19 18:19 ` Rolf Campbell
  2003-09-20  8:17   ` Alex Vinokur
  1 sibling, 1 reply; 7+ messages in thread
From: Rolf Campbell @ 2003-09-19 18:19 UTC (permalink / raw)
  To: cygwin

foo(char* const) is no different from foo(char*), from the perspective 
of linking/overloading.

Did you mean foo(char const *)?

Alex Vinokur wrote:
> ==========================================
> Windows 2000 Professional
> CYGWIN_NT-5.0 1.5.4(0.94/3/2)
> GNU gcc version 3.2 20020927 (prerelease)
> GNU objdump 2.14.90 20030901
> ==========================================
> 
> 
> It seems that objdump inaccurately demangles foo(char* const).
>   Low-level symbol name of foo(char* const) is valid : __Z3fooPc
>   But user-level symbol name obtained after demangling is inaccurate : foo(char*).
> 
> 
> 
> ====== C++ code : BEGIN ======
> // File t.cpp
> 
> void foo3 (char*) {}
> 
> ====== C++ code : END ========
> 
> 
> 
> ====== Compilation : BEGIN ======
> 
> $ g++ -c t.cpp
> 
> ====== Compilation : END ========
> 
> 
> 
> ====== objdump : BEGIN ======
> 
> $ objdump -d t.o
> 
> t.o:     file format pe-i386
> 
> Disassembly of section .text:
> 
> 00000000 <__Z3fooPc>:    // OK
>    0: 55                    push   %ebp
>    1: 89 e5                 mov    %esp,%ebp
>    3: 5d                    pop    %ebp
>    4: c3                    ret
>    5: 90                    nop
>    6: 90                    nop
>    7: 90                    nop
>    8: 90                    nop
>    9: 90                    nop
>    a: 90                    nop
>    b: 90                    nop
>    c: 90                    nop
>    d: 90                    nop
>    e: 90                    nop
>    f: 90                    nop
> 
> 
> 
> 
> 
> $ objdump -Cd t.o
> 
> 
> t.o:     file format pe-i386
> 
> Disassembly of section .text:
> 
> 00000000 <foo(char*)>:    // Must be foo(char* const)
>    0: 55                    push   %ebp
>    1: 89 e5                 mov    %esp,%ebp
>    3: 5d                    pop    %ebp
>    4: c3                    ret
>    5: 90                    nop
>    6: 90                    nop
>    7: 90                    nop
>    8: 90                    nop
>    9: 90                    nop
>    a: 90                    nop
>    b: 90                    nop
>    c: 90                    nop
>    d: 90                    nop
>    e: 90                    nop
>    f: 90                    nop
> 
> ====== objdump : END ========
> 
> --
>    =====================================
>    Alex Vinokur
>      mailto:alexvn@connect.to
>      http://mathforum.org/library/view/10978.html
>    =====================================
> 
> 
> 
> 
> 



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: objdump : inaccurate demangling for foo(char* const)
  2003-09-19  5:42 ` Alex Vinokur
  2003-09-19 10:19   ` Ronald Landheer-Cieslak
@ 2003-09-19 21:08   ` Alexander Osipenko
  1 sibling, 0 replies; 7+ messages in thread
From: Alexander Osipenko @ 2003-09-19 21:08 UTC (permalink / raw)
  To: cygwin

YES, there ARE a noticeable difference between GCC 3.2  and MS VisualC 7.1

struct A {
    virtual void foo(char* a) { std::cout << "A"; }
};

struct B: public A {
    virtual void foo(char* const a) { std::cout << "B"; }
};

int main() {
    B b;
    A* a = &b;
    a->foo("");
}

This example prints "A" in MSVC, and "B" in GCC.

In the plain case, the behavior is identical:

void foo1(char* a) {}
void foo2(char* const a) {}

From the caller function point of view, signatures of this functions (except name,
apparently)
should be identical - no matter, that parameter can't be changed _inside_ the function.
If you can pass a pointer to foo1() , so you can pass it to foo2() and vice versa.

If you declare pointers
  typedef void (*PF1)(char*);
  typedef void (*PF2)(char*const);
you can assign any foo to each PF.

IMHO, GCC seems  more consistent.

Of course, this is not the issue of cygwin port of GCC, you should ask GCC mailing list.
Let me know, if you'll find the correct answer.

=======
Alex.



"Alex Vinokur" <alexvn@connect.to> wrote in message news:bke0qt$8l6$1@sea.gmane.org...
>
> "Alex Vinokur" <alexvn@connect.to> wrote in message news:bkdtn1$597$2@sea.gmane.org...
> > ==========================================
> > Windows 2000 Professional
> > CYGWIN_NT-5.0 1.5.4(0.94/3/2)
> > GNU gcc version 3.2 20020927 (prerelease)
> > GNU objdump 2.14.90 20030901
> > ==========================================
> >
>
> Updated question about objdump.
>
> Low-level and user-level symbol names of foo2(char* const) are foo2(char*)
>
> --------- C++ code ---------
> void foo1 (char*) {}
> void foo2 (char* const) {}
> ----------------------------
>
>
> --------- objdump : Fragments ---------
> $ objdump -Cd t.o
>
> t.o:     file format pe-i386
>
> Disassembly of section .text:
>
> 00000000 <__Z4foo1Pc>:    // OK
>
> 00000006 <__Z4foo2Pc>:    // char*, not char* const
>
>
> $ objdump -d t.o
>
> t.o:     file format pe-i386
>
> Disassembly of section .text:
>
> 00000000 <foo1(char*)>:    // OK
>
>
> 00000006 <foo2(char*)>:    // Not char* const
>
> --------------------------------------
>
> So, is it inaccuracy or convention?
>
>
>    =====================================
>    Alex Vinokur
>      mailto:alexvn@connect.to
>      http://mathforum.org/library/view/10978.html
>    =====================================
>
>
>
>




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: objdump : inaccurate demangling for foo(char* const)
  2003-09-19 18:19 ` Rolf Campbell
@ 2003-09-20  8:17   ` Alex Vinokur
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Vinokur @ 2003-09-20  8:17 UTC (permalink / raw)
  To: cygwin


"Rolf Campbell" <Endlisnis@mailc.net> wrote in message news:bkfh75$v8o$1@sea.gmane.org...
> foo(char* const) is no different from foo(char*), from the perspective
> of linking/overloading.
>
> Did you mean foo(char const *)?
>

I meant foo(char* const). not foo(char const *).
Thanks.

   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-09-20  6:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-19  3:50 objdump : inaccurate demangling for foo(char* const) Alex Vinokur
2003-09-19  5:42 ` Alex Vinokur
2003-09-19 10:19   ` Ronald Landheer-Cieslak
2003-09-19 17:15     ` Hannu E K Nevalainen (garbage mail)
2003-09-19 21:08   ` Alexander Osipenko
2003-09-19 18:19 ` Rolf Campbell
2003-09-20  8:17   ` Alex Vinokur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).