Re: [PATCH 6/7] gdb: select "Cygwin" OS ABI for Cygwin binaries

Simon Marchi
2020-04-02T14:18:00Z

On 2020-04-02 10:08 a.m., Simon Marchi wrote:
> On 2020-04-02 10:03 a.m., Pedro Alves wrote:
>> On 4/2/20 3:01 PM, Simon Marchi wrote:
>>> On 2020-04-02 9:56 a.m., Pedro Alves wrote:
>>>> On 4/1/20 10:53 PM, Simon Marchi via Gdb-patches wrote:
>>>>> However, when BFD maps the file/section data in memory for GDB to read, is that mapping
>>>>> guaranteed to be sufficiently aligned as well?
>>>>
>>>> I think so. If bfd heap allocates, then memory will be aligned to the word size at
>>>> least. If bfd mmaps, then memory will be aligned to page size. And then if the
>>>> data structures are aligned, we should be good.
>>>
>>> Following this message from Tom [1], I'm going to change the code to use
>>> bfd_get_full_section_contents and store the data into a pre-allocated gdb::byte_vector.
>>> Does that change anything?
>>
>> I don't think it does.
>
> Err, just to make a correction: bfd_get_full_section_contents allocates the memory itself
> and returns a pointer, so I won't use gdb::byte_vector. Since BFD does the allocation
> itself, then we can say it's responsible for returning a properly aligned buffer.

Scratch that again. I now realized that bfd_get_section_contents uses a user-provided buffer,
unlike bfd_get_full_section_contents. I am not sure yet what I'm going to use.

Simon