X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Mon, 16 Mar 2009 13:43:34 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: peflags utility Message-ID: <20090316124334.GU9322@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <49A9AA0C DOT 9020904 AT cwilson DOT fastmail DOT fm> <20090301102035 DOT GB10046 AT calimero DOT vinschen DOT de> <49AE18D8 DOT 3010009 AT cwilson DOT fastmail DOT fm> <49AE191D DOT 2000307 AT cwilson DOT fastmail DOT fm> <20090304084923 DOT GA10046 AT calimero DOT vinschen DOT de> <20090304111849 DOT GB10046 AT calimero DOT vinschen DOT de> <49AE9742 DOT 4070108 AT cwilson DOT fastmail DOT fm> <20090304152955 DOT GE10046 AT calimero DOT vinschen DOT de> <49AF4961 DOT 1020108 AT cwilson DOT fastmail DOT fm> <49BDF28C DOT 8030300 AT cwilson DOT fastmail DOT fm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49BDF28C.8030300@cwilson.fastmail.fm> User-Agent: Mutt/1.5.19 (2009-02-20) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Mar 16 02:32, Charles Wilson wrote: > Here's revision 3. I've revised the UI to be more like what was > eventually accepted by binutils. One difference is that the ld options > allow only to set flags: > ld --tsaware > > With peflags we can set, clear, or display them: > peflags --tsaware : display > peflags --tsaware=1 : set > peflags --tsaware=0 : clear > > If this is more-or-less ok, I'll get started on the peflagsall script, > and send it all with updated docu as a patch for Jason to use in the > next rebase release. > > gcc -o peflags.exe -DVERSION='"2.4.5"' peflags.c Looks good, except for three minor details I found. Patch attached. - The output is missing a trailing \n. - Error output is missing an error description: $ ./peflags --tsaware=1 /bin/tcsh Error: could not update pe characteristics (/bin/tcsh) Yes, but... why? The patch adds errno output, like this: $ ./peflags --tsaware=1 /bin/tcsh Error: could not update pe characteristics (/bin/tcsh): Device or resource busy - The get/set characteristics function are calling close(fd) even if open failed. This leads to wrong errno output after applying the above errno output. Corinna --- peflags.c.ORIG 2009-03-16 13:18:06.000000000 +0100 +++ peflags.c 2009-03-16 13:37:55.000000000 +0100 @@ -317,16 +317,16 @@ do_mark (const char *pathname) if (set_coff_characteristics (pathname,new_coff_characteristics) != 0) { fprintf (stderr, - "Error: could not update coff characteristics (%s)\n", - pathname); + "Error: could not update coff characteristics (%s): %s\n", + pathname, strerror (errno)); return 1; } if (new_pe_characteristics != old_pe_characteristics) if (set_pe_characteristics (pathname,new_pe_characteristics) != 0) { fprintf (stderr, - "Error: could not update pe characteristics (%s)\n", - pathname); + "Error: could not update pe characteristics (%s): %s\n", + pathname, strerror (errno)); return 1; } } @@ -393,6 +393,7 @@ do_mark (const char *pathname) else printf ("pe(0x%04x) ", old_pe_characteristics); } + puts (""); } return 0; @@ -704,7 +705,7 @@ get_characteristics(const char *pathname fd = open (pathname, O_RDONLY|O_BINARY); if (fd == -1) - goto done; + return status; if (pe_get32 (fd, 0x3c, &pe_header_offset) != 0) goto done; @@ -741,7 +742,7 @@ set_coff_characteristics(const char *pat get_characteristics already did that */ fd = open (pathname, O_RDWR|O_BINARY); if (fd == -1) - goto done; + return status; if (pe_get32 (fd, 0x3c, &pe_header_offset) != 0) goto done; @@ -774,7 +775,7 @@ set_pe_characteristics(const char *pathn get_characteristics already did that */ fd = open (pathname, O_RDWR|O_BINARY); if (fd == -1) - goto done; + return status; if (pe_get32 (fd, 0x3c, &pe_header_offset) != 0) goto done; -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/