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: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Wed, 24 Jun 2015 04:10:49 -0700
- 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> <558A8E44 dot 6000800 at arm dot com>
On Wed, Jun 24, 2015 at 4:02 AM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> 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.
ldconfig is full of special cases on filenames.
>
> 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).
Can you write a GDB python script with less than 4 bytes?
> i think either the 'strstr (file_name, ".so") != NULL'
This is more restrictive than checking -gdb.py. That is it may
break existing DSOes.
> check at the begining of the function should be more
> strict or just silently ignore any file with invalid
> header.
I assume the error was done on purpose. I don't want to
remove it.
--
H.J.