[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/24920] New: Executable produces nonsensical error message after
From: |
geir at cray dot com |
Subject: |
[Bug ld/24920] New: Executable produces nonsensical error message after statically linking with trying to link in a dynamic library. |
Date: |
Tue, 20 Aug 2019 16:43:24 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=24920
Bug ID: 24920
Summary: Executable produces nonsensical error message after
statically linking with trying to link in a dynamic
library.
Product: binutils
Version: 2.31
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: geir at cray dot com
Target Milestone: ---
A user that attempts to create a static executable that also links in a dynamic
library will result in an executable that produces a confusing error message.
The error message incorrectly indicates that the executable does not exist.
PLEASE NOTE!: The resolution of the issue should be to not allow the link to
complete without error OR at least produce a better runtime error message.
There is no expectation that statically linking with dynamic libraries should
produce a working executable.
Here is the test case:
$ gcc --version
gcc (GCC) 8.3.0 20190222 (Cray Inc.)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ls -l /lib64/libaio.so.1*
lrwxrwxrwx 1 root root 15 May 25 2018 /lib64/libaio.so.1 -> libaio.so.1.0.1
-rwxr-xr-x 1 root root 5608 May 25 2018 /lib64/libaio.so.1.0.1
$ cat hello.c
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
return 0;
}
$ gcc -c hello.c
$ gcc -static hello.o -Wl,-Bdynamic /lib64/libaio.so.1
$ ./a.out
-bash: ./a.out: No such file or directory
$ ls -l a.out
-rwxr-xr-x 1 geir compiler 12128 Aug 20 11:22 a.out
$ file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked,
interpreter /lib/ld6, for GNU/Linux 3.2.0, with debug_info, not stripped
$
The problem appears to be an issue with 'ld':
$ ld --version
GNU ld (GNU Binutils; SUSE Linux Enterprise 15) 2.31.1.20180828-6.3
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
$ /usr/bin/ld -m elf_x86_64 -static /usr/lib/../lib64/crt1.o
/usr/lib/../lib64/crti.o
/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/crtbeginT.o
-L/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0
-L/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/../../../../lib64
-L/lib/../lib64 -L/usr/lib/../lib64
-L/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/../../.. hello.o
--start-group -lgcc -lgcc_eh -lc --end-group
/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/crtend.o
/usr/lib/../lib64/crtn.o -Bdynamic /lib64/libaio.so.1
$ ./a.out
-bash: ./a.out: No such file or directory
$
If the '-Bdynamic' option is removed, then an appropriate link time error
is provided:
$ /usr/bin/ld -m elf_x86_64 -static /usr/lib/../lib64/crt1.o
/usr/lib/../lib64/crti.o
/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/crtbeginT.o
-L/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0
-L/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/../../../../lib64
-L/lib/../lib64 -L/usr/lib/../lib64
-L/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/../../.. hello.o
--start-group -lgcc -lgcc_eh -lc --end-group
/opt/gcc/8.3.0/snos/lib/gcc/x86_64-suse-linux/8.3.0/crtend.o
/usr/lib/../lib64/crtn.o /lib64/libaio.so.1
/usr/bin/ld: attempted static link of dynamic object `/lib64/libaio.so.1'
$
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/24920] New: Executable produces nonsensical error message after statically linking with trying to link in a dynamic library.,
geir at cray dot com <=