[PATCH] Don't issue errors on GDB Python files
H.J. Lu
hjl.tools@gmail.com
Wed Jun 24 14:34:00 GMT 2015
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.
More information about the Libc-alpha
mailing list