An input ET_EXEC will cause
% as /dev/null -o a.o
% ld.bfd a.o -o a; ld.bfd a
ld.bfd: Using an executable file (a) as input to a link is deprecated - support is likely to be removed in the future
Shall we report a similar error for ET_DYN DF_1_PIE input?
If a DT_NEEDED entry is a PIE, glibc since 2.30 will report something like:
./b: error while loading shared libraries: b: cannot dynamically load position-independent executable
The master branch has been updated by Alan Modra <email@example.com>:
Author: Alan Modra <firstname.lastname@example.org>
Date: Fri Jun 11 14:06:47 2021 +0930
PR27952, Disallow ET_DYN DF_1_PIE linker input
This patch adds a new elf_tdata flag, is_pie, set during the linker's
open_input_bfds processing. The flag is then used to reject attempts
to link a PIE as if it were a shared library.
* elf-bfd.h (struct elf_obj_tdata): Add is_pie.
* elflink.c (elf_link_add_object_symbols): Set is_pie.
* ldelf.c (ldelf_after_open): Error on input PIEs too.