This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Don't issue errors on GDB Python files
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 24 Jun 2015 12:02:28 +0100
- Subject: Re: [PATCH] Don't issue errors on GDB Python files
- Authentication-results: sourceware.org; auth=none
- References: <20150624103058 dot GA3719 at intel dot com>
On 24/06/15 11:30, H.J. Lu wrote:
> @@ -155,11 +162,14 @@ process_file (const char *real_file_name, const char *file_name,
> /* 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)
> - error (0, 0, _("%s is not an ELF file - it has the wrong magic bytes at the start.\n"),
> - file_name);
> + if (!is_gdb_python_file (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)
> + error (0, 0, _("%s is not an ELF file - it has the wrong magic bytes at the start.\n"),
> + file_name);
> + }
> ret = 1;
> }
special-casing -gdb.py is ugly.
and these heuristics are fragile
(eg if the python script happened to be smaller than
an elf header then you would get a "too small" warning).
i think either the 'strstr (file_name, ".so") != NULL'
check at the begining of the function should be more
strict or just silently ignore any file with invalid
header.