From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30524 invoked by alias); 17 Feb 2006 22:02:26 -0000 Received: (qmail 30516 invoked by uid 22791); 17 Feb 2006 22:02:25 -0000 X-Spam-Check-By: sourceware.org Received: from out4.smtp.messagingengine.com (HELO out4.smtp.messagingengine.com) (66.111.4.28) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 17 Feb 2006 22:02:25 +0000 Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149]) by frontend1.messagingengine.com (Postfix) with ESMTP id 6F8F8D34D5F for ; Fri, 17 Feb 2006 17:02:22 -0500 (EST) Received: from frontend2.messagingengine.com ([10.202.2.151]) by frontend1.internal (MEProxy); Fri, 17 Feb 2006 17:02:22 -0500 Received: from [127.0.0.1] (user-0c6sj7r.cable.mindspring.com [24.110.76.251]) by frontend2.messagingengine.com (Postfix) with ESMTP id 1ADC357146F; Fri, 17 Feb 2006 17:02:21 -0500 (EST) Message-ID: <43F6473F.8030508@cwilson.fastmail.fm> Date: Fri, 17 Feb 2006 22:02:00 -0000 From: Charles Wilson User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: RFA: ensure binary objects opened in binary mode Content-Type: multipart/mixed; boundary="------------090502060909090700090105" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-02/txt/msg00338.txt.bz2 This is a multi-part message in MIME format. --------------090502060909090700090105 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1308 gdb uses solib_open() to open solibs via open(), openp(), or ops->find_and_open_solib(), using the O_RDONLY flag. Later, bfd_open uses fdopen(filedescriptor_from_solib_open, "rb") to change the text/binary mode (to binary) on platforms where that matters -- like cygwin and mingw. Now, cygwin's fdopen implementation does the right thing and does, in fact, change the mode to binary. So, on cygwin, this "bug" has no practical effect; this is not true for mingw, where the mode is NOT changed to binary (which leads to all sorts of problems parsing the file). However, even on cygwin, it's still *wrong* for gdb to open a solib (which is by definition a binary object) in text mode -- even if it gets "fixed" later by bfd_open(). So IMO this patch is "the right thing" for both cygwin and mingw, even tho there is no observable change in cygwin's behavior -- and it DOES fix a serious bug on mingw. Oh, and about the #ifndef O_BINARY stuff in this .c file: look at gdb/source.c before commenting. Also, as this patch adds only three non-blank lines and modifies only six more (all in exactly the same way), I believe it falls under the FSF definition of trivial. 2006-02-17 Charles Wilson <...> * gdb/solib.c(solib_open): ensure solib files are opened in binary mode. -- Chuck --------------090502060909090700090105 Content-Type: text/plain; name="gdb-6.4.50.20060131-cvs.solib.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdb-6.4.50.20060131-cvs.solib.patch" Content-length: 2586 Index: gdb/solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.83 diff -u -r1.83 solib.c --- gdb/solib.c 21 Jan 2006 22:23:27 -0000 1.83 +++ gdb/solib.c 1 Feb 2006 21:27:52 -0000 @@ -47,6 +47,10 @@ #include "observer.h" #include "readline/readline.h" +#ifndef O_BINARY +# define O_BINARY 0 +#endif + /* Architecture-specific operations. */ /* Per-architecture data key. */ @@ -171,7 +175,7 @@ } /* Now see if we can open it. */ - found_file = open (temp_pathname, O_RDONLY, 0); + found_file = open (temp_pathname, O_RDONLY|O_BINARY, 0); } /* If the search in solib_absolute_prefix failed, and the path name is @@ -192,32 +196,32 @@ /* If not found, search the solib_search_path (if any). */ if (found_file < 0 && solib_search_path != NULL) found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST, - in_pathname, O_RDONLY, 0, &temp_pathname); + in_pathname, O_RDONLY|O_BINARY, 0, &temp_pathname); /* If not found, next search the solib_search_path (if any) for the basename only (ignoring the path). This is to allow reading solibs from a path that differs from the opened path. */ if (found_file < 0 && solib_search_path != NULL) found_file = openp (solib_search_path, OPF_TRY_CWD_FIRST, - lbasename (in_pathname), O_RDONLY, 0, + lbasename (in_pathname), O_RDONLY|O_BINARY, 0, &temp_pathname); /* If not found, try to use target supplied solib search method */ if (found_file < 0 && ops->find_and_open_solib) - found_file = ops->find_and_open_solib (in_pathname, O_RDONLY, + found_file = ops->find_and_open_solib (in_pathname, O_RDONLY|O_BINARY, &temp_pathname); /* If not found, next search the inferior's $PATH environment variable. */ if (found_file < 0 && solib_absolute_prefix == NULL) found_file = openp (get_in_environ (inferior_environ, "PATH"), - OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY, 0, + OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY|O_BINARY, 0, &temp_pathname); /* If not found, next search the inferior's $LD_LIBRARY_PATH environment variable. */ if (found_file < 0 && solib_absolute_prefix == NULL) found_file = openp (get_in_environ (inferior_environ, "LD_LIBRARY_PATH"), - OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY, 0, + OPF_TRY_CWD_FIRST, in_pathname, O_RDONLY|O_BINARY, 0, &temp_pathname); /* Done. If not found, tough luck. Return found_file and --------------090502060909090700090105--