about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-06-24 03:21:29 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-06-24 10:27:39 -0700
commiteea3dc5bf2813b77ee9819d1b9ec893140db1491 (patch)
tree8880a115fc860029f96c48a49e8ccc82b32711ba /elf
parent6f874bd4d4063cacd9edd7f7607fb929f0db218f (diff)
downloadglibc-eea3dc5bf2813b77ee9819d1b9ec893140db1491.tar.gz
glibc-eea3dc5bf2813b77ee9819d1b9ec893140db1491.tar.xz
glibc-eea3dc5bf2813b77ee9819d1b9ec893140db1491.zip
Don't issue errors on GDB Python files
Many packages, including GCC, install Python files for GDB in library
diretory. ldconfig reads them and issue errors since they aren't ELF
files:

ldconfig: /usr/gcc-5.1.1/lib/libstdc++.so.6.0.21-gdb.py is not an ELF file - it has the wrong magic bytes at the start.

ldconfig: /usr/gcc-5.1.1/libx32/libstdc++.so.6.0.21-gdb.py is not an ELF file - it has the wrong magic bytes at the start.

ldconfig: /usr/gcc-5.1.1/lib64/libstdc++.so.6.0.21-gdb.py is not an ELF file - it has the wrong magic bytes at the start.

This patch silences ldconfig on GDB Python files by checking filenames
with -gdb.py suffix.

	[BZ #18585]
	* elf/readlib.c (is_gdb_python_file): New.
	(process_file): Don't issue errors on filenames with -gdb.py
	suffix.
Diffstat (limited to 'elf')
-rw-r--r--elf/readlib.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/elf/readlib.c b/elf/readlib.c
index 5c14a42b9d..7fd5b8afbf 100644
--- a/elf/readlib.c
+++ b/elf/readlib.c
@@ -63,6 +63,13 @@ static struct known_names known_libs[] =
 };
 
 
+/* Check if string corresponds to a GDB Python file.  */
+static bool
+is_gdb_python_file (const char *name)
+{
+  size_t len = strlen (name);
+  return len > 7 && strcmp (name + len - 7, "-gdb.py") == 0;
+}
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
@@ -157,7 +164,8 @@ process_file (const char *real_file_name, const char *file_name,
 	 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)
+	  && 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;