* 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. >> https://sourceware.org/ml/binutils/2018-09/msg00359.html > > 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) + continue; (Untested, of course.) Thanks, Florian