From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9111 invoked by alias); 22 Jun 2011 17:52:59 -0000 Received: (qmail 9090 invoked by uid 22791); 22 Jun 2011 17:52:58 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,TW_FN,TW_IB,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Jun 2011 17:52:43 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id D9ECB346; Wed, 22 Jun 2011 19:52:41 +0200 (CEST) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id u-MJ7fMYEo-o; Wed, 22 Jun 2011 19:52:37 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 446E2345; Wed, 22 Jun 2011 19:52:37 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.4+Sun/8.14.4/Submit) id p5MHqa3L020329; Wed, 22 Jun 2011 19:52:36 +0200 (MEST) From: Rainer Orth To: gcc-patches@gcc.gnu.org Cc: java-patches@gcc.gnu.org, Hans Boehm Subject: [boehm-gc] Use __rld_obj_head for IRIX GC_register_dynamic_libraries (PR libgcj/49451) Date: Wed, 22 Jun 2011 17:52:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org X-SW-Source: 2011-q2/txt/msg00084.txt.bz2 As reported in PR libgcj/49451, the FileHandleGcTest test fails on IRIX since boehm-gc tries to open /proc/ when the process is already out of file descriptors. Looking around, I've found a way for boehm-gc to determine the list of shared libraries without using /proc, just as Solaris and Tru64 UNIX do. It uses __rld_obj_head, which provides the same info as _DYNAMIC on Solaris, though in a slightly different way. Fortunately, the current Solaris code can be made to work on IRIX with very few changes. The initial version allowed make check in boehm-gc to work without problems, but failed when running any libjava test, which SEGVed in a way that gdb couldn't catch ;-( After some digging around, it turned out that the addresses in the loaded shared objects may need an offset added similar to the Solaris case, to take into account that the actual virtual address and the quickstart one in the object don't match, if I read the comment correctly. The gdb sources provided an important clue in gdb/solib-irix.c (fetch_lm_info). The version below passes both make check on mips-sgi-irix6.5 for both N32 and N64 multilibs, the previously failing FileHandleGcTest test now passes as expected, and a couple of other libjava tests work, too. A full make check for libjava is currently running, ok for mainline if that passes? Please note that the O32 code is currently untested since support for that ABI has been removed in GCC 4.6. This is harmless for the in-tree copy, but might be an issue upstream. I'll probably give it a try on the 4.5 branch. Thanks. Rainer 2011-06-17 Rainer Orth PR libgcj/49451 * include/private/gcconfig.h [IRIX5 && _MIPS_SZPTR == 64] (ELF_CLASS): Define. * dyn_load.c [IRIX5]: Include . Include for O32, for N32, N64. [SUNOS5DL && USE_PROC_FOR_LIBRARIES] (obj_offset): Define. [SUNOS4 && USE_PROC_FOR_LIBRARIES] (obj_offset): Define. [IRIX5 && !USE_PROC_FOR_LIBRARIES] (struct link_map): Define. (__rld_obj_head): Declare. (l_next, l_addr, obj_offset): Define. (GC_FirstDLOpenedLinkMap): New function. [SUNOS4 || SUNOS5DL] (GC_register_dynamic_libraries): Also use on IRIX5. Use obj_offset. [IRIX5 || (USE_PROC_FOR_LIBRARIES && !LINUX] (GC_register_dynamic_libraries): Don't use /proc version on IRIX5. diff --git a/boehm-gc/dyn_load.c b/boehm-gc/dyn_load.c --- a/boehm-gc/dyn_load.c +++ b/boehm-gc/dyn_load.c @@ -82,6 +82,15 @@ # define l_addr lm_addr # define l_name lm_name #endif +#ifdef IRIX5 +# include +# if _MIPS_SIM == _MIPS_SIM_ABI32 /* O32 ABI */ + /* Don't include here. */ +# include +# else /* N32 or N64 ABIs */ +# include +# endif +#endif #if defined(NETBSD) # include @@ -139,6 +148,8 @@ GC_register_has_static_roots_callback Elf32_Dyn _DYNAMIC; #endif +#define obj_offset(lm) ((unsigned long)(lm->l_addr)) + static struct link_map * GC_FirstDLOpenedLinkMap() { @@ -192,6 +203,8 @@ GC_FirstDLOpenedLinkMap() struct link_dynamic _DYNAMIC; #endif +#define obj_offset(lm) ((unsigned long)(lm->l_addr)) + static struct link_map * GC_FirstDLOpenedLinkMap() { @@ -226,9 +239,59 @@ static ptr_t GC_first_common() #endif /* SUNOS4 ... */ -# if defined(SUNOS4) || defined(SUNOS5DL) +#if defined(IRIX5) && !defined(USE_PROC_FOR_LIBRARIES) + +/* Provide struct link map. */ +# if _MIPS_SIM == _MIPS_SIM_ABI32 /* O32 ABI */ +/* Provide our own version of struct obj_list in with + correctly typed data member. */ +struct obj_list { + struct obj *data; + struct obj_list *next; + struct obj_list *prev; +} objList; + +struct link_map { + objList l_ol; +}; + +extern objList *__rld_obj_head; + +/* Map field names */ +# define l_next l_ol.next +# define l_addr l_ol.data->o_pelfhdr + +# define obj_offset(lm) \ + ((unsigned long)(lm->l_ol.o_praw - (char *)lm->l_ol.o_base_address)) +# else /* N32 or N64 ABIs */ +struct link_map { + ElfW(Obj_Info) l_oi; +}; + +extern ElfW(Obj_Info) *__rld_obj_head; + +/* Map field names */ +# define l_next l_oi.oi_next +# define l_addr l_oi.oi_ehdr + +/* See gdb/solib-irix.c (fetch_lm_info). */ +# define obj_offset(lm) \ + ((unsigned long)(lm->l_oi.oi_ehdr - lm->l_oi.oi_orig_ehdr)) +# endif + +static struct link_map * +GC_FirstDLOpenedLinkMap() +{ + return (struct link_map *)__rld_obj_head; +} + +#endif /* IRIX5 ... */ + +# if defined(SUNOS4) || defined(SUNOS5DL) || defined(IRIX5) /* Add dynamic library data sections to the root set. */ -# if !defined(PCR) && !defined(GC_SOLARIS_PTHREADS) && defined(THREADS) +# if !defined(PCR) \ + && !defined(GC_SOLARIS_PTHREADS) && !defined(GC_IRIX_THREADS) \ + && defined(THREADS) # ifndef SRC_M3 --> fix mutual exclusion with dlopen # endif /* We assume M3 programs don't call dlopen for now */ @@ -241,7 +304,7 @@ void GC_register_dynamic_libraries() for (lm = GC_FirstDLOpenedLinkMap(); - lm != (struct link_map *) 0; lm = lm->l_next) + lm != (struct link_map *) 0; lm = (struct link_map *) lm->l_next) { # ifdef SUNOS4 struct exec *e; @@ -252,7 +315,7 @@ void GC_register_dynamic_libraries() ((char *) (N_BSSADDR(*e) + e->a_bss + lm->lm_addr)), TRUE); # endif -# ifdef SUNOS5DL +# if defined(SUNOS5DL) || defined(IRIX5) ElfW(Ehdr) * e; ElfW(Phdr) * p; unsigned long offset; @@ -261,7 +324,7 @@ void GC_register_dynamic_libraries() e = (ElfW(Ehdr) *) lm->l_addr; p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff)); - offset = ((unsigned long)(lm->l_addr)); + offset = obj_offset(lm); for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) { switch( p->p_type ) { case PT_LOAD: @@ -589,7 +652,7 @@ void GC_register_dynamic_libraries() #endif /* LINUX */ -#if defined(IRIX5) || (defined(USE_PROC_FOR_LIBRARIES) && !defined(LINUX)) +#if defined(USE_PROC_FOR_LIBRARIES) && !defined(LINUX) #include #include @@ -718,7 +781,7 @@ void GC_register_dynamic_libraries() fd = -1; } -# endif /* USE_PROC || IRIX5 */ +# endif /* USE_PROC */ # if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32) diff --git a/boehm-gc/include/private/gcconfig.h b/boehm-gc/include/private/gcconfig.h --- a/boehm-gc/include/private/gcconfig.h +++ b/boehm-gc/include/private/gcconfig.h @@ -1445,6 +1445,9 @@ # if CPP_WORDSZ != 64 # define ALIGN_DOUBLE # endif +# if _MIPS_SZPTR == 64 +# define ELF_CLASS ELFCLASS64 +# endif # else # define ALIGNMENT 4 # define ALIGN_DOUBLE -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University