[lug] objdump, nm, and const

Tkil tkil at scrye.com
Tue Jun 17 17:24:36 MDT 2003


>>>>> "DS" == D Stimits <stimits at attbi.com> writes:

DS> Is it possible with objdump or nm to verify the argument as being
DS> marked const or not being marked const?

If a function is declared with C linkage (as are all native C library
interfaces), its name is not mangled into a type-safe linkable name,
so there's no way to tell the difference:

| extern "C" void extern_c_takes_const     ( const char * ) {}
| extern "C" void extern_c_takes_non_const (       char * ) {}
| 
| void cpp_takes_const     ( const char * ) {}
| void cpp_takes_non_const (       char * ) {}

looking at it with nm:

| $ g++ -c ds1.cc
| $ nm ds1.o
| 00000000 T extern_c_takes_const
| 00000006 T extern_c_takes_non_const
| 0000000c T _Z15cpp_takes_constPKc
| 00000012 T _Z19cpp_takes_non_constPc

t.




More information about the LUG mailing list