Re: Segmentation fault in __libc_start_main with -static

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 29 Jan 2010, Carlos O'Donell wrote:

> On Wed, Jan 27, 2010 at 12:06 PM, John David Anglin
> > The original code:
> >
> >  258:   2b 60 00 00     addil L%0,dp,r1
> >  25c:   34 23 00 00     ldo 0(r1),r3
> >  260:   0c 60 10 82     ldw 0(r3),rp
> >
> > __nptl_nthreads is undefined weak:
> >
> >         w __nptl_nthreads
> 
> The symbol is defined in libpthread.so, specifically by
> nptl/pthread_create.c "unsigned int __nptl_nthreads = 1;"
> 
> Application link map shows:
>  .data          0x000a1648       0x14
> /usr/lib/gcc/hppa-linux-gnu/4.3.4/../../../libpthread.a(pthread_create.o)
>                 0x000a1648                __nptl_nthreads
> 
> I don't see any segmentation fault, nor do I see an undefined weak
> __nptl_nthreads:

Think you missed that I said the application was being linked with
-static.  As a result, pthread_create.o won't be loaded from libpthread.a
just to resolve __nptl_nthreads.

This is the application:

// This test only applies to glibc (NPTL) targets.
// { dg-do run { target *-*-linux* } }
// { dg-options "-pthread" }

#include <pthread.h>
#include <cxxabi.h>
extern "C" int printf (const char *, ...);

int main()
{
  try
    {
      pthread_exit (0);
    }
  catch (abi::__forced_unwind &)
    {
      printf ("caught forced unwind\n");
      throw;
    }
  catch (...)
    {
      printf ("caught ...\n");
      return 1;
    }
}

This is the gcc link command:

/home/dave/gnu/gcc/objdir/gcc/testsuite/g++/../../collect-ld -static -o ./forced.xgs /usr/lib/crt1.o /usr/lib/crti.o /home/dave/gnu/gcc/objdir/gcc/testsuite/g++/../../crtbeginT.o -L/home/dave/gnu/gcc/objdir/hppa-linux/./libstdc++-v3/src/.libs -L/home/dave/gnu/gcc/objdir/hppa-linux/./libstdc++-v3/src/.libs -L/home/dave/gnu/gcc/objdir/hppa-linux/./libiberty -L/home/dave/gnu/gcc/objdir/gcc/testsuite/g++/../.. -L/home/dave/gnu/gcc/objdir/hppa-linux/./libstdc++-v3/src/.libs /tmp/ccmLwpAe.o -lstdc++ -lm --start-group -lgcc -lgcc_eh -lpthread -lc --end-group /home/dave/gnu/gcc/objdir/gcc/testsuite/g++/../../crtend.o /usr/lib/crtn.o

Compile with:

g++ -o xx -static -pthread xx.C

Given what you said, the same fault would likely occur on x86.

Dave
-- 
J. David Anglin                                  dave.anglin@xxxxxxxxxxxxxx
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)
--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SoC]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux