[PATCH] D75527: [yaml2obj] - Add `ELFYAML::YAMLInt` to fix how we parse a relocation `Addend` key.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 09:00:25 PST 2020


MaskRay added a comment.

In D75527#1904856 <https://reviews.llvm.org/D75527#1904856>, @grimar wrote:

> In D75527#1903438 <https://reviews.llvm.org/D75527#1903438>, @MaskRay wrote:
>
> > It should probably accept the union of int32_t and uint32_t, i.e. [-2147483648, 4294967295]. Examples: R_AARCH64_ABS32, R_AARCH64_PREL32, R_PPC64_ADDR32.
>
>
> I think your suggestion is fine. I'll go this way if there will be no objections.
>
> But what should we print (obj2yaml)? We print int64_t decimal currently.
>  Should we switch to printing a hex form then?


For most relocation types, the addend should be interpreted as a signed integer. We don't want obj2yaml to learn the semantics of relocation types, so letting obj2yaml unconditionally dump an addend as a signed integer should be fine. An addend (of a 32-bit object) greater than or equal to 0x80000000 is usually accepted as input, so yaml2obj should also accept them.

I just think that `-0x1` and `-0x5` don't look so strange (no need to reject), but I'd like to hear a third opinion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75527/new/

https://reviews.llvm.org/D75527





More information about the llvm-commits mailing list