This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

RE: egcs-1.1 under cygwin, why save inline symbol names?


> ----------
> From: 	Mumit Khan[SMTP:khan@xraylith.wisc.edu]
> Sent: 	Tuesday, October 06, 1998 8:26 PM
> To: 	Jan Reimers
> Subject: 	RE: egcs-1.1 under cygwin, why save inline template
> symbol names?
> 
> Jan,
> 
> Thanks for the testcase. You'll get the same symbols for Linux and I
> assume for other ELF systems as well that support some sort of weak
> symbols.
> 
> Here's what I get under Linux using egcs-1.1:
> 
>   % gcc -c test.cc
>   % nm test.o
>   00000000 ? .LFB2
>   00000000 ? .LFB3
>   0000001b ? .LFE2
>   00000014 ? .LFE3
>   00000000 ? __FRAME_BEGIN__
>   00000000 W func2__H21e01e1_RCt1A21eY011eY11_v
>   00000000 W func__Ct1A21e01e1
>   00000000 t gcc2_compiled.
>   00000000 T main
> 
Try with -O2, here is what I get under RH5.1 with the eh-frame stuff
removed for clarity (in hideous detail):

	~/test>g++ -v -O2 -c -fno-exceptions test.cc

Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/specs

gcc version
egcs-2.91.57 19980901 (egcs-1.1 release)


/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/cpp -lang-c++ -v
-undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91
-D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix
-D__linux -Asystem(posix) -D__OPTIMIZE__ -Asystem(unix) -Acpu(i386)
-Amachine(i386) -Di386 -D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686
-D__i686__ -D__pentiumpro -D__pentiumpro__ test.cc /tmp/ccgfz1JO.ii

GNU
CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (i386
Linux/ELF)

#include "..." search starts here:

#include <...> search
starts here:

 /usr/local/include/g++

 /usr/local/include


/usr/local/i686-pc-linux-gnu/include


/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/include


/usr/include

End of search list.


/usr/local/lib/gcc-lib/i686-pc-linux-gnu/egcs-2.91.57/cc1plus
/tmp/ccgfz1JO.ii -quiet -dumpbase test.cc -O2 -version -fno-exceptions
-o /tmp/ccG0GlRu.s

GNU C++ version egcs-2.91.57 19980901 (egcs-1.1
release) (i686-pc-linux-gnu) compiled by GNU C version egcs-2.92.07
19980920 (gcc2 ss-980609 experimental).

 as -V -Qy -o test.o
/tmp/ccG0GlRu.s

GNU assembler version 2.9.1 (i686-pc-linux-gnu), using
BFD version 2.9.1.0.4

~/test>nm -C test.o

00000000 t
gcc2_compiled.

00000000 T main



Totally clean, no symbols for inline
functions.  This is as I expect.  Just to make 100% sure, I also looked
at the assembly code:



~/test>g++ -S -O2 -fno-exceptions
test.cc

~/test>cat test.s

        .file   "test.cc"

        .version
"01.01"

gcc2_compiled.:

.text

        .align 4

.globl main

        .type
main,@function

main:

        pushl %ebp

        movl %esp,%ebp


xorl %eax,%eax

        movl %ebp,%esp

        popl %ebp


ret

.Lfe1:

        .size    main,.Lfe1-main

        .ident  "GCC: (GNU)
egcs-2.91.57 19980901 (egcs-1.1 release)"

Again no sign of the inline function names.




> and for cygwin32:
> 
>   % i386-cygwin32-gcc -c test.cc
>   % i386-cygwin32-nm test.o
>   00000000 b .bss
>   00000000 d .data
>   00000000 t .text
>   00000000 t .text$func2__H21e01e1_RCt1A21eY011eY11_v
>   00000000 t .text$func__Ct1A21e01e1
>   00000000 t __gnu_compiled_cplusplus
> 	   U __main
>   00000000 T func2__H21e01e1_RCt1A21eY011eY11_v
>   00000000 T func__Ct1A21e01e1
>   00000000 T main
>   00000000 t gcc2_compiled.
> 
> Btw, something is fishy with your setup (you must be missing a few of
> my
> patches). You don't show the linkonce symbols:
> 
>   00000000 t .text$func2__H21e01e1_RCt1A21eY011eY11_v
>   00000000 t .text$func__Ct1A21e01e1
> 
> which will eventually bite you as multiply-defined symbols.
> 
> Regards,
> Mumit
> 
> 
I really don't understand this.  Why does an inline function have to be
a linkonce symbol, it is not being instantiated, its just getting
inlined, there should be nothing to link.  What purpose do all these
symbols serve? The linker can't use them, because the functions are
never defined/instantiated at -O2 optimization.

Here is the assembly file under cygwin-B19

bash-2.01$ g++ -O2 -fno-exceptions -S test.cc
	bash-2.01$ cat test.s
	        .file   "test.cc"
	gcc2_compiled.:
	___gnu_compiled_cplusplus:
	        .def    ___main;        .scl    2;      .type   32;
.endef
	.text
	        .align 4
	.globl _main
	        .def    _main;  .scl    2;      .type   32;     .endef
	_main:
	        pushl %ebp
	        movl %esp,%ebp
	        call ___main
	        movl %ebp,%esp
	        xorl %eax,%eax
	        popl %ebp
	        ret
	        .def    _func__Ct1A21e01e1;     .scl    3;      .type
32;     .endef
	        .def    _func2__H21e01e1_RCt1A21eY011eY11_v;    .scl
3;      .type32;
	        .endef
	bash-2.01$

My complaint is with the ".def"'s at the end.  What purpose do they
serve?  When expression templates used are they add up to an enourmous
amount of wasted space.  I have also concluded that this has nothin to
do templates, non-template inlines do the same thing.

I hope this makes some sense, and is usefull.

Best Regards


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