From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6577 invoked by alias); 29 Jul 2003 06:11:08 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 6564 invoked from network); 29 Jul 2003 06:11:07 -0000 Received: from unknown (HELO lacrosse.corp.redhat.com) (66.187.233.200) by sources.redhat.com with SMTP; 29 Jul 2003 06:11:07 -0000 Received: from free.redhat.lsd.ic.unicamp.br (aoliva.cipe.redhat.com [10.0.1.10]) by lacrosse.corp.redhat.com (8.11.6/8.9.3) with ESMTP id h6T6AxK12784; Tue, 29 Jul 2003 02:10:59 -0400 Received: from free.redhat.lsd.ic.unicamp.br (free.redhat.lsd.ic.unicamp.br [127.0.0.1]) by free.redhat.lsd.ic.unicamp.br (8.12.9/8.12.9) with ESMTP id h6T6Awa3003721; Tue, 29 Jul 2003 03:10:58 -0300 Received: (from aoliva@localhost) by free.redhat.lsd.ic.unicamp.br (8.12.9/8.12.9/Submit) id h6T6AZDc003717; Tue, 29 Jul 2003 03:10:35 -0300 To: binutils@sources.redhat.com, bug-dejagnu@gnu.org Cc: gdb-patches@sources.redhat.com Subject: wrapper functions that ``call themselves'' break mn10300 -mrelax From: Alexandre Oliva Organization: GCC Team, Red Hat Date: Tue, 29 Jul 2003 06:11:00 -0000 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2003-07/txt/msg00558.txt.bz2 --=-=-= Content-length: 1927 I couldn't figure out what exactly broke the long-standing fact that dejagnu/testglue.c, used in mn10300-sim and several other dejagnu baseboards, contains wrapper functions that call the original unwrapped names, e.g., __wrap_abort() calls __real_abort() and then abort(). Also, __wrap_main() calls __real_main() and then exit() (as opposed to either __wrap_exit() or __real_exit()). This causes a very serious problem to the mn10300 linker, when doing linker relaxations. The problem is that say __wrap_exit is added to the symbol table of the testglue.o abfd twice: once when the symbol is first defined, and once when elf_merge_symbol() calls bfd_wrapped_link_hash_lookup() for the undefined symbol entry corresponding to abort() or exit() is encountered, that is mapped to the same hash. This causes a problem when mn10300 attempts to do adjust the symbol values within their sections, after removing some bytes from before them, near the end of mn10300_elf_relax_delete_bytes(). I've been trying to find a clean and efficient way to get elf_merge_symbols() to skip such duplicate definitions, but I couldn't think of any. I'm not even sure it would be correct to arrange for elf_merge_symbols() to remove duplicate entries from the symhashes array of a bfd. Even if it is, there's no efficient way to remove duplicates, other than creating a per-bfd hash table. Does anyone have any clever ideas? As for dejagnu, I managed to work around the problem by replacing explicit references to exit() and abort() with references to ORIG_EXIT() and ORIG_ABORT(), but I'm not sure this would be appropriate either. Another work around, that fixed the problem in this particular platform, was to tell dejagnu that the mn10300 sim does actually return the exit status from the programs, which I found to be true but not reflected in the mn10300-sim.exp baseboard file. Here's the patch for the file. Ok for the GDB tree? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=dejagnu-mn10300-sim-no-wrapper.patch Content-length: 954 Index: dejagnu/ChangeLog from Alexandre Oliva * baseboards/mn10300-sim.exp: We don't need_status_wrapper. Index: dejagnu/baseboards/mn10300-sim.exp =================================================================== RCS file: /cvs/uberbaum/dejagnu/baseboards/mn10300-sim.exp,v retrieving revision 1.2 diff -u -p -r1.2 mn10300-sim.exp --- dejagnu/baseboards/mn10300-sim.exp 21 Apr 2002 08:46:47 -0000 1.2 +++ dejagnu/baseboards/mn10300-sim.exp 29 Jul 2003 06:09:59 -0000 @@ -26,8 +26,8 @@ set_board_info ldflags "[libgloss_link_ # Simulator linker script. set_board_info ldscript "-Tsim.ld" -# The simulator doesn't return exit statuses and we need to indicate this. -set_board_info needs_status_wrapper 1 +# The simulator does return exit statuses. +#set_board_info needs_status_wrapper 1 # We can't pass args to the simulator or get exit status back from the # simulator, nor does the simulator support real signals. --=-=-= Content-length: 289 -- Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/ Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org} CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org} Free Software Evangelist Professional serial bug killer --=-=-=--