diff mbox

[users/roland/osabi-assert] Do not crash on unrecognized GNU .note.ABI-tag values

Message ID CAB=4xhoR0=ZaDot6rEaVhhEAxYeoBjP89AHhxgD52ANKKrDYJg@mail.gmail.com
State New
Headers show

Commit Message

Roland McGrath May 29, 2015, 12:21 a.m. UTC
Diagnosis of unexpected input (in this case, in an executable file)
should not crash as if it were a bug in GDB.  This one is especially
harmless, since the "osabi" has so little effect on anything.

OK for trunk and 7.9 branch?


Thanks,
Roland


gdb/
2015-05-28  Roland McGrath  <mcgrathr@google.com>

	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Use warning
	rather than internal_error for an unrecognized value.

 	}

Comments

Pedro Alves May 29, 2015, 10:07 a.m. UTC | #1
On 05/29/2015 01:21 AM, Roland McGrath wrote:
> Diagnosis of unexpected input (in this case, in an executable file)
> should not crash as if it were a bug in GDB.  

Indeed.

> This one is especially
> harmless, since the "osabi" has so little effect on anything.

It's used to pick the right gdbarch for the inferior.

> 
> OK for trunk and 7.9 branch?

In order to get this into a release branch, the protocol is to file
a PR and then once fixed, list the fix in the release page in the wiki:

  https://sourceware.org/gdb/wiki/GDB_7.9_Release

That helps the release manager build the release notes.

> gdb/
> 2015-05-28  Roland McGrath  <mcgrathr@google.com>
> 
> 	* osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Use warning
> 	rather than internal_error for an unrecognized value.
> 
> diff --git a/gdb/osabi.c b/gdb/osabi.c
> index 9d90c55..abf4bd4 100644
> --- a/gdb/osabi.c
> +++ b/gdb/osabi.c
> @@ -493,10 +493,9 @@ generic_elf_osabi_sniff_abi_tag_sections (bfd
> *abfd, asection *sect, void *obj)
>  	      break;
> 
>  	    default:
> -	      internal_error (__FILE__, __LINE__,
> -			      _("generic_elf_osabi_sniff_abi_tag_sections: "
> -				"unknown OS number %d"),
> -			      abi_tag);
> +              warning ("GNU ABI tag value %u unrecognized.\n", abi_tag);

Wrap string in _().

Indentation looks odd.  tabs vs spaces?  (We use tabs in gdb.)

> +              *osabi = GDB_OSABI_UNKNOWN;

This line is not necessary.  It if were, we'd need to do the
same in the other two paths that don't match anything in
this function too.

OK with those fixed.

> +              break;
>  	    }
>  	  return;
>  	}

Thanks,
Pedro Alves
Doug Evans May 29, 2015, 4:26 p.m. UTC | #2
On Fri, May 29, 2015 at 3:07 AM, Pedro Alves <palves@redhat.com> wrote:
> On 05/29/2015 01:21 AM, Roland McGrath wrote:
>> Diagnosis of unexpected input (in this case, in an executable file)
>> should not crash as if it were a bug in GDB.
>>...
>> +              warning ("GNU ABI tag value %u unrecognized.\n", abi_tag);
>
> Wrap string in _().

No trailing \n too, right?
Pedro Alves May 29, 2015, 4:29 p.m. UTC | #3
On 05/29/2015 05:26 PM, Doug Evans wrote:
> On Fri, May 29, 2015 at 3:07 AM, Pedro Alves <palves@redhat.com> wrote:
>> On 05/29/2015 01:21 AM, Roland McGrath wrote:
>>> Diagnosis of unexpected input (in this case, in an executable file)
>>> should not crash as if it were a bug in GDB.
>>> ...
>>> +              warning ("GNU ABI tag value %u unrecognized.\n", abi_tag);
>>
>> Wrap string in _().
> 
> No trailing \n too, right?

Right.

Thanks,
Pedro Alves
diff mbox

Patch

diff --git a/gdb/osabi.c b/gdb/osabi.c
index 9d90c55..abf4bd4 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -493,10 +493,9 @@  generic_elf_osabi_sniff_abi_tag_sections (bfd
*abfd, asection *sect, void *obj)
 	      break;

 	    default:
-	      internal_error (__FILE__, __LINE__,
-			      _("generic_elf_osabi_sniff_abi_tag_sections: "
-				"unknown OS number %d"),
-			      abi_tag);
+              warning ("GNU ABI tag value %u unrecognized.\n", abi_tag);
+              *osabi = GDB_OSABI_UNKNOWN;
+              break;
 	    }
 	  return;