[llvm] Reland "[ObjectYAML][ELF] Take alignment into account when generating notes" (PR #118434)

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 12:43:14 PST 2024


igorkudrin wrote:

> I'm wondering what we should do for ELF32 instances, where the alignment is 8. In the spirit of yaml2obj's permissiveness, I think we should allow it, in which case we should have a test for it.

I don't see anything wrong with `yanl2obj` generating 8-byte aligned notes for ELF32, so I've added the test.

> More generally, yaml2obj tries to be permissive in what it allows. In other words, it should try to write the object described regardless of the ABI rules on what is permitted. What's preventing us aligning each note to e.g. 2 or 3?

Aligning notes to anything other than 4 or 8 makes no sense, because parsers would not be able to read them correctly. If a test writer needs a nonsense notes section, they can always use `Content:` instead of `Notes:`. Some existing tests even do this, for example, `tools/llvm-objcopy/ELF/only-keep-debug.test` and `tools/llvm-readobj/ELF/note-alignment-invalid.test`.

https://github.com/llvm/llvm-project/pull/118434


More information about the llvm-commits mailing list