<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Defaults output file permissions to 0775 unlike GNU objcopy which mirrors the input file's permissions"
   href="https://bugs.llvm.org/show_bug.cgi?id=42082">bug 42082</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>i@maskray.me
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>FIXED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Defaults output file permissions to 0775 unlike GNU objcopy which mirrors the input file's permissions"
   href="https://bugs.llvm.org/show_bug.cgi?id=42082#c4">Comment # 4</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Defaults output file permissions to 0775 unlike GNU objcopy which mirrors the input file's permissions"
   href="https://bugs.llvm.org/show_bug.cgi?id=42082">bug 42082</a>
              from <span class="vcard"><a class="email" href="mailto:i@maskray.me" title="Fangrui Song <i@maskray.me>"> <span class="fn">Fangrui Song</span></a>
</span></b>
        <pre>Fixed by D62718/r365162 and follow-ups. The description of r365162 is
incorrect.

GNU objcopy has some tricky rules to decide the output permission.

  if (i_ehdrp->e_type == ET_EXEC)
    abfd->flags |= EXEC_P;
  else if (i_ehdrp->e_type == ET_DYN)
    abfd->flags |= DYNAMIC;

// bfd/opncls.c
static inline void
_maybe_make_executable (bfd * abfd)
{
  /* If the file was open for writing and is now executable,
     make it so.  */
  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))));
        }
    }
}

llvm-objcopy simply copies the permission of the input to the output.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>