bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/19526] Using "gcc -o /dev/null" gives "ld: final link failed: F


From: dave.anglin at bell dot net
Subject: [Bug ld/19526] Using "gcc -o /dev/null" gives "ld: final link failed: File truncated" error
Date: Sat, 30 Jan 2016 18:15:00 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=19526

--- Comment #8 from dave.anglin at bell dot net ---
On 2016-01-30, at 8:51 AM, address@hidden wrote:

> https://sourceware.org/bugzilla/show_bug.cgi?id=19526
> 
> --- Comment #7 from Andreas Schwab <address@hidden> ---
> The linker should not allow writing the output to a non-regular file in the
> first place.  Changing the behaviour depending on the type of output file 
> would
> be wrong.


Currently in bfd/opncls.c, there is the following code

  if (abfd->direction == write_direction
      && (abfd->flags & (EXEC_P | DYNAMIC)) != 0)
    {
      struct stat buf;

      if (stat (abfd->filename, &buf) == 0
          /* Do not attempt to change non-regular files.  This is
             here especially for configure scripts and kernel builds
             which run tests with "ld [...] -o /dev/null".  */
          && S_ISREG(buf.st_mode))
        {
          unsigned int mask = umask (0);

          umask (mask);
          chmod (abfd->filename,
                 (0777
                  & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask))));
        }
    }

to support "ld [...] -o /dev/null".

It seems to me we either have to match x86 behaviour, or the linker should not
allow writing
to a non-regular file.

Dave
--
John David Anglin       address@hidden

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]