FS#77365 - [binutils] ldconfig: /usr/lib/libbfd.so is not an ELF file - it has the wrong magic bytes at the sta

Attached to Project: Community Packages
Opened by Andreas Baumann (andreas_baumann) - Friday, 03 February 2023, 07:05 GMT
Last edited by freswa (frederik) - Friday, 03 February 2023, 12:44 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To freswa (frederik)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

with:

shared linking to these files outside binutils
rm -f "$pkgdir"/usr/lib/lib{bfd,opcodes}.so
echo 'INPUT( /usr/lib/libbfd.a -lsframe -liberty -lz -lzstd -ldl )' > "$pkgdir/usr/lib/libbfd.so"
echo 'INPUT( /usr/lib/libopcodes.a -lbfd )' > "$pkgdir/usr/lib/libopcodes.so"

you will get:

ldconfig: /usr/lib/libbfd.so is not an ELF file - it has the wrong magic bytes at the start.

Looking at ldconfig.c I see:

elf_header = (ElfW(Ehdr) *) file_contents;
if (memcmp (elf_header->e_ident, ELFMAG, SELFMAG) != 0)
{
/* The file is neither ELF nor aout. Check if it's a linker
script, like libc.so - otherwise complain. Only search the
beginning of the file. */
size_t len = MIN (statbuf.st_size, 512);
if (memmem (file_contents, len, "GROUP", 5) == NULL
&& memmem (file_contents, len, "GNU ld script", 13) == NULL
&& !is_gdb_python_file (file_name))
error (0, 0, _("%s is not an ELF file - it has the wrong magic bytes at the start.\n"),
file_name);
ret = 1;
}

So probably libbfd.so should have a "GNU ld script" header to make
this ELF detection in ldconfig.c happy:

/* GNU ld script */

https://github.com/archlinux/svntogit-packages/blob/packages/binutils/trunk/PKGBUILD#L113

Funnily /usr/lib/libopcodes.so is not showing this behaviour.
This task depends upon

Closed by  freswa (frederik)
Friday, 03 February 2023, 12:44 GMT
Reason for closing:  Fixed
Additional comments about closing:  Committed revision 468145

Will be in the next release (with glibc 2.37)

Loading...