[PATCH] D54946: [yaml2obj] [COFF] Subtract the image base for section virtual addresses

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 10:56:11 PST 2018


zturner added a comment.

In D54946#1310078 <https://reviews.llvm.org/D54946#1310078>, @zturner wrote:

> Maybe I'm misunderstanding something.  In `COFFYAML.cpp` we have this code:
>
>   IO.mapOptional("VirtualAddress", Sec.Header.VirtualAddress, 0U);
>   
>
> So, we write out the virtual address exactly as it is in the binary header file.  So why, when going the other direction, do we subtract the image base?  I don't have a strong preference on whether we store the VA or the RVA (I have a mild preference for storing the value exactly as it is in the object file), but whatever we do, yaml2obj and obj2yaml at least need to agree with other, right?


Also, in `coff2yaml.cpp` we have this code which initializes the above field:

  const object::coff_section *COFFSection = Obj.getCOFFSection(ObjSection);
  COFFYAML::Section NewYAMLSection;
  ...
  NewYAMLSection.Header.VirtualAddress = ObjSection.getAddress();

So, the value we print in the yaml is indeed the exact value from the object file.  If we change one but not the other, then it will regress the ability of object files to round-trip through yaml.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54946





More information about the llvm-commits mailing list