Before this patch, we have to calculate the offset for the current range list entry. This patch helps make the "Offset" field optional.
You should also have a test case either in this test or D81217 that shows what happens when you use an offset that is either higher than where you are already, or lower.
I don't think this wants to be an assert - it should be an error, right? If you specify a lower offset than the current position (e.g. 0 for the second set), you want an error since you can't place it there.
Yes, I think it should be an error as well. Currently, DWARFYAML doesn't support error handling. If we change one void EmitXXXSection() to Error EmitXXXSection(), we should change them all. Can I do it in a follow-up patch?
Can ZeroFillBytes cope with a size of zero? If so, this can be simplified to simply:
if (DebugRanges.Offset) ZeroFillBytes(OS, *DebugRanges.Offset - CurrOffset);