Hmm, I think maybe this should be a yaml2obj error rather than just writing some arbitrary value. If a symbol references a non-existent section by name, it's just dodgy YAML. (OTOH, it would be perfectly reasonable to allow specification by index and for an invalid index to be allowed without error).
Add the SectionIndex field for symbol.
1: a symbol can reference a section by SectionName or SectionIndex.
2: a symbol can reference a section by both SectionName and SectionIndex.
3: if both Section and SectionIndex are specified, but the two values refer to different sections, an error will be reported.
4: an invalid SectionIndex is allowed.
5: if a symbol references a non-existent section by SectionName, an error will be reported.
Some small points, but otherwise looks pretty good to me.
Perhaps "does not exist" instead of "is invalid"? Up to you though.
You should specify the name and index in the error message, as otherwise a user won't be able to see which symbol is causing the problem.
Aside: this error message from llvm-readobj should ideally be updated to include the symbol name or index, so that a user can see which symbol is the problem. Fix in a different patch though.