|
From: Florian K. <br...@ac...> - 2008-05-16 13:39:27
|
On Thursday 15 May 2008 2:20:50 pm Bart Van Assche wrote: > On Wed, May 14, 2008 at 10:41 PM, Florian Krohm <br...@ac...> wrote: > > But, the more I think of it the more I get convinced that these > > OFFSETs need to be computed by the target compiler. > > I agree. But I can't imagine any way to get offsetof() values out of a > cross-compiler in a portable way (i.e. without relying on nm or > libbfd). Correct. > There is an alternative however: add the header file > libvex_guest_offsets.h to VEX and let the cross-compiler verify > consistency of the header file and the computed offsetof() values. > I have implemented this as follows on the CROSS_COMPILATION branch: > * Added the file VEX/pub/libvex_guest_offsets_in.h > * Added the file VEX/auxprogs/verifyoffsets.c, which verify the > offsets via the static_assert() macro. > * Changed VEX/Makefile as follows: > pub/libvex_guest_offsets.h: > - $(CC) -Wall -g -o auxprogs/genoffsets auxprogs/genoffsets.c > - ./auxprogs/genoffsets > pub/libvex_guest_offsets.h > + $(CC) -Wall -g -c auxprogs/verifyoffsets.c \ > + && cp pub/libvex_guest_offsets_in.h pub/libvex_guest_offsets.h > > What is your opinion about this ? > I'm not too crazy about libvex_guest_offsets.h, now that it is no longer generated. The reason is that I think that, conceptually, the definition of the guest state offsets for a particular architecture should be placed next to the definition on the guest state itself. As for verifying the offsets, it would be helpful if the checking code could be defined in proximity to the offset definitions. If it's in a different file, there is a chance that things get out of sync when a new offset definition is being added. You'd have to remember to add the code snippet that verifies the offset. I know, I wouldn't. It is true that static_assert would save some cycles during development as the failed assertion would cause the build to fail. On the other hand, the error message for a failed static_assert is a bit cryptic as compared to vassert. I'll work on a patch but probably won't get to it until sometime this weekend. Florian |