This is the mail archive of the
mailing list for the GCC project.
Re: [RFC] Change PCH "checksum"
* Richard Biener:
>> Since the introduction of GNU Property notes this is (sadly) no longer
>> the correct way to iterate through ELF notes. The padding of names and
>> desc might now depend on the alignment of the PT_NOTE segment.
> Ick, that's of course worse ;) So it's not entirely clear what
> the correct thing to do is - from how I read the mail at the above
> link only iff sh_align of the note section is exactly 8 the above
> ALIGN would use 8 byte alignment and else 4 is correct (independent
> on sh_align). Or can I assume sh_align of the note section is
> "correct" for all existing binaries?
sh_align doesn't come into play if you look at program headers.
A GNU build ID note will not end up in a PT_NOTE segment with 8-byte
alignment, so I think you can skip those early, like this:
+ if (info->dlpi_phdr[i].p_type != PT_NOTE
+ || info->dlpi_phdr[i].p_align != 4)
(Untested, of course.)