[PATCH] Core file build-ids

Keith Seitz keiths@redhat.com
Wed Jun 5 19:19:00 GMT 2019


On 6/5/19 11:57 AM, Sergio Durigan Junior wrote:
> On Wednesday, June 05 2019, Keith Seitz wrote:
>> diff --git a/bfd/elf.c b/bfd/elf.c
>> index b463f1df8b..1d86a0a4d6 100644
>> --- a/bfd/elf.c
>> +++ b/bfd/elf.c
>> @@ -3019,7 +3024,11 @@ bfd_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int hdr_index)
>>        return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "null");
>>  
>>      case PT_LOAD:
>> -      return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "load");
>> +      if (! _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "load"))
>> +	return FALSE;
>> +      if (bfd_get_format (abfd) == bfd_core && abfd->build_id == NULL)
>> +	_bfd_elf_core_find_build_id (abfd, hdr->p_offset);
>> +      return TRUE;
>>  
>>      case PT_DYNAMIC:
>>        return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "dynamic");
>> @@ -11667,34 +11676,42 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
>>  
>>  	case bfd_core:
>>  	  {
>> +	    if (in.namesz == sizeof "GNU" && strcmp (in.namedata, "GNU") == 0)
>> +	      {
>> +		if (! elfobj_grok_gnu_note (abfd, &in))
>> +		  return FALSE;
>> +	      }
>> +	    else
>> +	      {
> 
> You could rewrite this to get rid of the "else" part, which would make
> the patch smaller:
> 

Actually, I think I can make this even simpler. Not sure why I didn't do
this originally, but I'm blaming the weather.

@@ -11681,7 +11690,8 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
              GROKER_ELEMENT ("NetBSD-CORE", elfcore_grok_netbsd_note),
              GROKER_ELEMENT ( "OpenBSD", elfcore_grok_openbsd_note),
              GROKER_ELEMENT ("QNX", elfcore_grok_nto_note),
-             GROKER_ELEMENT ("SPU/", elfcore_grok_spu_note)
+             GROKER_ELEMENT ("SPU/", elfcore_grok_spu_note),
+             GROKER_ELEMENT ("GNU", elfobj_grok_gnu_note)
            };
 #undef GROKER_ELEMENT
            int i;

Thank you for taking a peek,
Keith



More information about the Binutils mailing list