This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: nm test.o: (g++, cmath, exp, expf)

On Fri, Sep 27, 2013 at 1:22 AM, nick clifton <> wrote:
> Hi Reza,
>> When using g++, the cmath
>> exp(float)
>> exp(double)
>> functions are supposed to resolve differently(based on the parameter
>> type.)  But
>> nm test.o
>> always keeps showing only one function: exp.  How can I see that the
>> functions are really different?
> Please can you provide a full test case that demonstrates this problem ?
> (ie small source file, command line(s) used to build it and run nm + details
> of the architecure where you are running the test and the version of g++ and
> the binutils that you are using).
> This may be a name mangling bug.  Or it might be a misunderstanding about
> type promotions.  Or it could be something else entirely...
> Cheers
>   Nick

Thanks Nick.  Here it goes:
# g++ -v   gives:
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.6 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --enable-plugin --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i686
--with-tune=generic --enable-checking=release --build=i686-linux-gnu
--host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
# nm -V   gives:
GNU nm (GNU Binutils for Ubuntu) 2.22
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.
# cat test.cpp   gives:
#include <cmath>

extern double x;
extern float f;

long long m()
    return (long long)(exp(x) + exp(f));
# g++ -Wall -g -c test.cpp;  nm test.o    gives:
00000000 T _Z1mv
         U exp
         U f
         U x

Moreover, replacing long long m() with int main() and removing the
'extern's, I get similar results:
g++ -Wall -g test.cpp; nm ./a.out
08049f20 d _DYNAMIC
0804854c R _IO_stdin_used
         w _Jv_RegisterClasses
08049f10 d __CTOR_END__
08049f0c d __CTOR_LIST__
08049f18 d __DTOR_END__
08049f14 d __DTOR_LIST__
08048614 r __FRAME_END__
08049f1c d __JCR_END__
08049f1c d __JCR_LIST__
0804a014 A __bss_start
0804a00c D __data_start
08048500 t __do_global_ctors_aux
080483a0 t __do_global_dtors_aux
0804a010 d __dso_handle
         w __gmon_start__
080484f2 t __i686.get_pc_thunk.bx
00000000 a __init_array_end
00000000 a __init_array_start
080484f0 T __libc_csu_fini
08048480 T __libc_csu_init
         U __libc_start_main
0804a014 A _edata
0804a02c A _end
0804852c T _fini
08048548 R _fp_hw
08048300 T _init
08048370 T _start
0804a018 b completed.6159
0804a00c W data_start
0804a01c b dtor_idx.6161
         U exp
0804a028 B f
08048400 t frame_dummy
08048424 T main
0804a020 B x

So, I'm not sure where the C++ exp(float) versus exp(double)  are identified?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]