Patchwork [LTO] Improve ELF diagnostics

login
register
mail settings
Submitter Gerald Pfeifer
Date Sept. 14, 2010, 9:48 a.m.
Message ID <alpine.LNX.2.00.1009141138590.17560@acrux.dbai.tuwien.ac.at>
Download mbox | patch
Permalink /patch/64686/
State New
Headers show

Comments

Gerald Pfeifer - Sept. 14, 2010, 9:48 a.m.
I coughed up the patch below while debugging an LTO failure.  "Sadly" this 
magically disappeared but I figured the patch may be generally useful.

Disclaimer: a bit above that code we have the following which, however, 
did not trigger in this case:

  elf_file->fd = open (fname, writable ? O_WRONLY|O_CREAT|O_BINARY
                                       : O_RDONLY|O_BINARY, 0666);
  if (elf_file->fd == -1)
    {
      error ("could not open file %s", fname);
      goto fail;
    }

Bootstrapped and regression tested on i386-unknown-freebsd8.1.

Okay?

Gerald

 
2010-09-14  Gerald Pfeifer  <gerald@pfeifer.com>

	* lto-elf.c (lto_obj_file_open): Also provide filename when
	elf_begin fails.
Richard Guenther - Sept. 14, 2010, 10:14 a.m.
On Tue, Sep 14, 2010 at 11:48 AM, Gerald Pfeifer <gerald@pfeifer.com> wrote:
> I coughed up the patch below while debugging an LTO failure.  "Sadly" this
> magically disappeared but I figured the patch may be generally useful.
>
> Disclaimer: a bit above that code we have the following which, however,
> did not trigger in this case:
>
>  elf_file->fd = open (fname, writable ? O_WRONLY|O_CREAT|O_BINARY
>                                       : O_RDONLY|O_BINARY, 0666);
>  if (elf_file->fd == -1)
>    {
>      error ("could not open file %s", fname);
>      goto fail;
>    }
>
> Bootstrapped and regression tested on i386-unknown-freebsd8.1.
>
> Okay?

Ok.

Thanks,
Richard.

> Gerald
>
>
> 2010-09-14  Gerald Pfeifer  <gerald@pfeifer.com>
>
>        * lto-elf.c (lto_obj_file_open): Also provide filename when
>        elf_begin fails.
>
> Index: lto/lto-elf.c
> ===================================================================
> --- lto/lto-elf.c       (revision 164225)
> +++ lto/lto-elf.c       (working copy)
> @@ -698,7 +698,7 @@
>                             NULL);
>   if (!elf_file->elf)
>     {
> -      error ("could not open ELF file: %s", elf_errmsg (0));
> +      error ("could not open %s as an ELF file: %s", fname, elf_errmsg (0));
>       goto fail;
>     }
>
Gerald Pfeifer - Sept. 18, 2010, 4:26 p.m.
On Tue, 14 Sep 2010, Richard Guenther wrote:
>>        * lto-elf.c (lto_obj_file_open): Also provide filename when
>>        elf_begin fails.
> Ok.

Thanks!  Installed as revision 164394.  For the record, testresults are at
  http://gcc.gnu.org/ml/gcc-testresults/2010-09/msg01637.html
  http://gcc.gnu.org/ml/gcc-testresults/2010-09/msg01663.html
(the second with the patch plus an svn up, thus the extra tests).

Gerald

Patch

Index: lto/lto-elf.c
===================================================================
--- lto/lto-elf.c	(revision 164225)
+++ lto/lto-elf.c	(working copy)
@@ -698,7 +698,7 @@ 
 			     NULL);
   if (!elf_file->elf)
     {
-      error ("could not open ELF file: %s", elf_errmsg (0));
+      error ("could not open %s as an ELF file: %s", fname, elf_errmsg (0));
       goto fail;
     }