Bug 25873 - ar segfaults when liblto_plugin.so.0.0.0 is a symlink in /usr/lib/bfd-plugins
Summary: ar segfaults when liblto_plugin.so.0.0.0 is a symlink in /usr/lib/bfd-plugins
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-25 01:19 UTC by Tom Stellard
Modified: 2020-04-28 15:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Stellard 2020-04-25 01:19:51 UTC
ar segfaults when using a plugin from /usr/lib/bfd-plugins that is a symlink.  Here is how to reproduce:

echo "int foo(){}" | gcc -flto -O2 -c -x c -o foo.o -
echo "int bar(){}" | gcc -flto -O2 -c -x c -o bar.o -
ln -s /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so.0.0.0 /usr/lib/bfd-plugins/
ar crs foo.a foo.o bar.o
Segmentation fault (core dumped)


If the plugin is copied directly and not a symlink, then there is no segfault:


rm /usr/lib/bfd-plugins/liblto_plugin.so.0.0.0 
cp /usr/libexec/gcc/x86_64-redhat-linux/10/liblto_plugin.so.0.0.0 /usr/lib/bfd-plugins/
ar crs foo.a foo.o bar.o
Comment 1 Tom Stellard 2020-04-25 01:33:49 UTC
It also seems like the LLVMgold.so plugin does not have the same problem.  This similar sequence works with this plugin:

echo "int foo(){}" | clang -flto -O2 -c -x c -o foo.o -
echo "int bar(){}" | clang -flto -O2 -c -x c -o bar.o -
ln -s /usr/lib64/LLVMgold.so /usr/lib/bfd-plugins/
ar crs foo.a foo.o bar.o
Comment 2 H.J. Lu 2020-04-25 15:40:29 UTC
Please try binutils 2.34 branch.
Comment 3 Nick Clifton 2020-04-27 11:45:59 UTC
Hi Tom,

  I am sorry but I cannot reproduce this.  It seems very strange that a
  symlink should be causing a segmentation fault when a copy does not.

  The "ar" program that you are running - is this the binutils ar binary
  or is it an alias/symlink for the gcc-ar script ?

  If you have the symlink in place and you run:

    ar crs --plugin /usr/lib/bfd-plugins/liblto_plugin.so.0.0.0 foo.a foo.o bar.o

  Does that work ?

  Does the problem persist if you use the current mainline development
  sources for the binutils rather than the 2.34 release ?

Cheers
  Nick
Comment 4 Tom Stellard 2020-04-27 14:29:23 UTC
(In reply to Nick Clifton from comment #3)
> Hi Tom,
> 
>   I am sorry but I cannot reproduce this.  It seems very strange that a
>   symlink should be causing a segmentation fault when a copy does not.
> 

I am able to reproduce this running in the fedora:rawhide container image, so you may want to give that a try.

>   The "ar" program that you are running - is this the binutils ar binary
>   or is it an alias/symlink for the gcc-ar script ?
> 

ar is not a symlink or alias as far as I can tell.

>   If you have the symlink in place and you run:
> 
>     ar crs --plugin /usr/lib/bfd-plugins/liblto_plugin.so.0.0.0 foo.a foo.o
> bar.o
> 
>   Does that work ?
> 

Yes, this works.

>   Does the problem persist if you use the current mainline development
>   sources for the binutils rather than the 2.34 release ?
> 

I will try the development sources.  I'm currently testing with gcc-10.0.1-0.12.fc33 and binutils-2.34-3.fc33.

> Cheers
>   Nick
Comment 5 Andreas Schwab 2020-04-27 15:23:07 UTC
This might be a fedora specific bug, so try filing a bug there first.
Comment 6 Tom Stellard 2020-04-27 20:51:58 UTC
(In reply to Andreas Schwab from comment #5)
> This might be a fedora specific bug, so try filing a bug there first.

It looks like this is caused by a Fedora specific patch, so I've filed a bug in the Fedora bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1828587
Comment 7 Nick Clifton 2020-04-28 15:11:21 UTC
Fedora specific.