This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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: GCC 3.4 and glibc/nptl: Cancellation broken


On Fri, Jan 23, 2004 at 03:21:05PM +0100, Michael Matz wrote:
> At the very least this is extremely fragile.  IMHO glibc's pthread 
> shouldn't circumvent ELF lookup rules by explicitely dlopening libgcc_s.  
> Instead it should first look with RTLD_DEFAULT for the necessary symbols, 
> and only if that results in nothing should it load libgcc_s itself (if 
> this really is necessary at all).

Usually binaries don't export their symbol tables, so this wouldn't change
much.

> > As soon as I implement (or anyone else beats me to do it)
> > http://sources.redhat.com/ml/binutils/2003-12/msg00211.html
> > GCC driver should link all non-static binaries with:
> > --start-only-if-used -lgcc_s --end-only-if-used
> > and things will work just fine.
> 
> How would this fix it?  No matter if the executable is also linked against 
> libgcc_s, it still would be linked against libgcc_eh, so would provide the 
> _Unwind_* symbols on it's own, which should then be choosen, instead of 
> the symbols of libgcc_s.

ATM on sufficiently recent Linux GCC uses:
*link_gcc_c_sequence:
%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}

*lib:
%{pthread:-lpthread} %{shared:-lc} \
%{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}

*libgcc:
%{static|static-libgcc:-lgcc -lgcc_eh} \
%{!static:%{!static-libgcc:%{!shared:%{!shared-libgcc:-lgcc -lgcc_eh} \
				     %{shared-libgcc:-lgcc_s%M -lgcc}} \
			   %{shared:%{shared-libgcc:-lgcc_s%M} \
				    %{!shared-libgcc:-lgcc}}}}

My suggestion is to use following as soon as ld supports
--start-only-if-used/--end-only-if-used instead:

*libgcc:
%{static|static-libgcc:-lgcc -lgcc_eh} \
%{!static:%{!static-libgcc:%{!shared-libgcc:-lgcc --start-only-if-used -lgcc_s%M --end-only-if-used} \
			   %{shared-libgcc:-lgcc_s%M %{!shared:-lgcc}}}}

That way, -static or -static-libgcc will link in libgcc.a and libgcc_eh.a,
but nothing else.  The program/shared library will have DT_NEEDED
libgcc_s.so.1 if linked with -shared-libgcc or if some symbol from
libgcc_s.so.1 minus libgcc.a was needed by the executable or shared library
(e.g. if it used -fexceptions and __attribute__((cleanup)) ).

Without --start-only-if-used/--end-only-if-used, the above change
with those switches removed would lead to all binaries and all libraries
to have DT_NEEDED libgcc_s.so.1, although they usually don't need it
(at least for C code, C++ defaults to -shared-libgcc anyway).

	Jakub


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