mirror of
https://sourceware.org/git/glibc.git
synced 2025-10-27 12:15:39 +03:00
elf: Report when found libraries are rejected [BZ #25669]
When debugging library loading issues with `LD_DEBUG`, it can be
frustrating to see logs for files in a directory are searched, but the
target library is skipped over without any indication of why. Add
reporting to all paths which reject a library as `ENOENT`.
Originally created for minimum-OS version detection, but that has since
been removed in b46d250656 (Remove kernel version check, 2022-02-21).
The remaining codepaths are still useful.
Signed-off-by: Ben Boeckel <ben.boeckel@kitware.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
committed by
Adhemerval Zanella
parent
1b8eb82845
commit
eda354cfd8
@@ -1633,6 +1633,8 @@ open_verify (const char *name, int fd,
|
|||||||
32-bit and 64-bit binaries can be run this might
|
32-bit and 64-bit binaries can be run this might
|
||||||
happen. */
|
happen. */
|
||||||
*found_other_class = true;
|
*found_other_class = true;
|
||||||
|
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
|
||||||
|
_dl_debug_printf (" (incompatible ELF class)\n");
|
||||||
__close_nocancel (fd);
|
__close_nocancel (fd);
|
||||||
__set_errno (ENOENT);
|
__set_errno (ENOENT);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1671,6 +1673,8 @@ open_verify (const char *name, int fd,
|
|||||||
}
|
}
|
||||||
if (! __glibc_likely (elf_machine_matches_host (ehdr)))
|
if (! __glibc_likely (elf_machine_matches_host (ehdr)))
|
||||||
{
|
{
|
||||||
|
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
|
||||||
|
_dl_debug_printf (" (incompatible ELF machine)\n");
|
||||||
__close_nocancel (fd);
|
__close_nocancel (fd);
|
||||||
__set_errno (ENOENT);
|
__set_errno (ENOENT);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1706,12 +1710,19 @@ open_verify (const char *name, int fd,
|
|||||||
(phdr, ehdr->e_phnum, fbp->buf, fbp->len,
|
(phdr, ehdr->e_phnum, fbp->buf, fbp->len,
|
||||||
loader, fd)))
|
loader, fd)))
|
||||||
{
|
{
|
||||||
|
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
|
||||||
|
_dl_debug_printf (" (incompatible ELF headers with the host)\n");
|
||||||
__close_nocancel (fd);
|
__close_nocancel (fd);
|
||||||
__set_errno (ENOENT);
|
__set_errno (ENOENT);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
|
||||||
|
_dl_debug_printf (" (no such file)\n");
|
||||||
|
}
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
@@ -1822,6 +1833,11 @@ open_path (const char *name, size_t namelen, int mode,
|
|||||||
/* The shared object cannot be tested for being SUID
|
/* The shared object cannot be tested for being SUID
|
||||||
or this bit is not set. In this case we must not
|
or this bit is not set. In this case we must not
|
||||||
use this object. */
|
use this object. */
|
||||||
|
if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_LIBS))
|
||||||
|
_dl_debug_printf (" refusing to load file=%s, the shared "
|
||||||
|
"object cannot be tested for being "
|
||||||
|
"SUID or the bit is not set\n",
|
||||||
|
buf);
|
||||||
__close_nocancel (fd);
|
__close_nocancel (fd);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
/* We simply ignore the file, signal this by setting
|
/* We simply ignore the file, signal this by setting
|
||||||
|
|||||||
Reference in New Issue
Block a user