This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Don't issue errors on GDB Python files


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]