bug-binutils
[Top][All Lists]
Advanced

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

ar: wrong permissions on output file with binutils 2.36


From: Adam Sampson
Subject: ar: wrong permissions on output file with binutils 2.36
Date: Fri, 29 Jan 2021 22:33:07 +0000

Hi binutils maintainers,

I've just run into an interesting problem when building plan9port with
binutils 2.36: it uses "ar rcs" to build static libraries, but one of
the libraries -- lib9.a, which has a very long list of objects -- ends
up with permission 0600 rather than the intended 0644.

Here's a script that reproduces the problem for me on amd64 GNU/Linux
with GCC 10.2.0:

-----
#!/bin/sh

echo "int x;" >t.c
gcc -c t.c
for i in $(seq 100 299); do
        cp t.o $i.o
done

rm -f libt.a
ar rcs libt.a 1*.o
ls -l libt.a

rm -f libt.a
ar rcs libt.a [12]*.o
ls -l libt.a
-----

This produces the output:

-rw-r--r-- 1 root root 101072 Jan 29 22:23 libt.a
-rw------- 1 root root 202072 Jan 29 22:23 libt.a

Tracing through the ar code, this seems to be fallout from this change:
https://lists.gnu.org/archive/html/bug-binutils/2021-01/msg00089.html

In write_archive, with the shorter argument list, iarch->iostream is
non-NULL; with the longer list, iarch->iostream is NULL, and skip_stat
is set to TRUE, so the permissions don't get set.

It looks from the libbfd code like ->iostream can legitimately be NULL
while the file is open, so I think the new test in write_archive is
incorrect.

Thanks very much,

-- 
Adam Sampson <ats@offog.org>                         <http://offog.org/>



reply via email to

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