ldconfig: Ignore all GDB extension files
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
ldconfig already ignores files with the -gdb.py suffix, but GDB also
looks for -gdb.gdb and -gdb.scm files. These aren't as widely used, but
libguile at least comes with a -gdb.scm file.
This patch makes ldconfig ignore all three types of file.
Signed-off-by: Adam Sampson <ats@offog.org>
---
Note: I'm using DCO, and I'm happy for this trivial change to be covered
by the existing FSF copyright notice in the file, or by Copyright The
GNU Toolchain Authors if you prefer.
elf/readlib.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
Comments
* Adam Sampson:
> -/* Check if string corresponds to a GDB Python file. */
> +/* Check if string corresponds to a GDB extension file. */
> static bool
> -is_gdb_python_file (const char *name)
> +is_gdb_extension_file (const char *name)
> {
> size_t len = strlen (name);
> - return len > 7 && strcmp (name + len - 7, "-gdb.py") == 0;
> + if (len > 8 && strcmp (name + len - 8, "-gdb.gdb") == 0)
> + return true;
> + if (len > 7 && strcmp (name + len - 7, "-gdb.py") == 0)
> + return true;
> + if (len > 8 && strcmp (name + len - 8, "-gdb.scm") == 0)
> + return true;
> + return false;
> }
We already have endswithn in elf/ldconfig.c. Maybe it's time to move
this function to its own header file and use it here as well?
Thanks,
Florian
@@ -43,12 +43,18 @@ struct known_names
int flag;
};
-/* Check if string corresponds to a GDB Python file. */
+/* Check if string corresponds to a GDB extension file. */
static bool
-is_gdb_python_file (const char *name)
+is_gdb_extension_file (const char *name)
{
size_t len = strlen (name);
- return len > 7 && strcmp (name + len - 7, "-gdb.py") == 0;
+ if (len > 8 && strcmp (name + len - 8, "-gdb.gdb") == 0)
+ return true;
+ if (len > 7 && strcmp (name + len - 7, "-gdb.py") == 0)
+ return true;
+ if (len > 8 && strcmp (name + len - 8, "-gdb.scm") == 0)
+ return true;
+ return false;
}
/* Returns 0 if everything is ok, != 0 in case of error. */
@@ -145,7 +151,7 @@ process_file (const char *real_file_name, const char *file_name,
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))
+ && !is_gdb_extension_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;