[RFC][PATCH] Add Solaris specific ELF note processing.

Libor Bukata libor.bukata@oracle.com
Fri Jul 30 15:18:40 GMT 2021


Hi Alan,

thank you for looking into it.

On 7/28/21 11:14 AM, Alan Modra wrote:
> On Mon, Jul 19, 2021 at 07:09:47AM +0000, Libor Bukata via Binutils wrote:
>> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
>> index b3f56b8c2ce..2427fcb1414 100644
>> --- a/bfd/elf-bfd.h
>> +++ b/bfd/elf-bfd.h
>> @@ -1377,6 +1377,11 @@ struct elf_backend_data
>>     bool (*elf_backend_grok_freebsd_prstatus)
>>       (bfd *, Elf_Internal_Note *);
>>   
>> +  /* This function, if defined, is called when a "Solaris" NT_LWPSTATUS
>> +     note is found in a core file.  */
>> +  bool (*elf_backend_grok_lwpstatus)
>> +    (bfd *, Elf_Internal_Note *);
>> +
> Why did you add this?  There is no place where it is defined as
> anything other than NULL.
Frankly speaking, I am not the original author of the patch but I 
maintain, update, and refactor it on behalf of Oracle. I got the 
approvals from Oracle to contribute it to binutils project. I removed 
elf_backend_grok_lwpstatus since it is obviously not needed.
>
>>     /* This function, if defined, is called to write a note to a corefile.  */
>>     char *(*elf_backend_write_core_note)
>>       (bfd *abfd, char *buf, int *bufsiz, int note_type, ...);
>> diff --git a/bfd/elf.c b/bfd/elf.c
>> index de5abafabf0..d39b4bd3b88 100644
>> --- a/bfd/elf.c
>> +++ b/bfd/elf.c
>> @@ -9717,7 +9717,10 @@ elfcore_make_note_pseudosection (bfd *abfd,
>>   static bool
>>   elfcore_grok_prfpreg (bfd *abfd, Elf_Internal_Note *note)
>>   {
>> -  return elfcore_make_note_pseudosection (abfd, ".reg2", note);
>> +  asection *sect = bfd_get_section_by_name (abfd, ".reg2");
>> +  if (sect == NULL)
>> +    return elfcore_make_note_pseudosection (abfd, ".reg2", note);
>> +  return true;
>>   }
>>   
>>   /* Linux dumps the Intel SSE regs in a note named "LINUX" with a note
> The above was not described or mentioned in a ChangeLog.  Why do you
> need this?
Maybe it was required with older GDB versions. I removed it and 
retested.  Note that elfcore_make_note_pseudosection returns false only 
in case of errors and the existence of a section is not considered an 
error...
>
> There are also rather a lot of formatting errors in the rest of the
> patch.
>
I hopefully improved the code formatting (lines with at max 79 
characters, aligned function arguments). Let me know if more work is 
needed. Thanks.

Testing:

Solaris: Verified that general and float registers are loaded from core 
files on both x86 and sparc.
Linux: No regressions in binutils unit tests. Loaded a core file 
generated by GDB.

I have some issues with my email client, therefore, I attached the patch 
instead of inlining the text.

I have a favor to ask you, could you please check the following auxv fix 
from binutils side?
https://sourceware.org/pipermail/gdb-patches/2021-July/180967.html

I need an approval of AT_SUN_CAP_HW3 constant addition. Simon Marchi 
approved GDB changes. Many thanks.

Regards,
Libor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-bfd-Add-Solaris-specific-ELF-note-processing.patch
Type: text/x-patch
Size: 11378 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210730/23c56df0/attachment.bin>


More information about the Binutils mailing list