[LLVMdev] Building lld with Visual Studio 2012 RC

Michael Spencer bigcheesegs at gmail.com
Sat Jun 16 22:16:35 PDT 2012


On Sat, Jun 16, 2012 at 8:50 PM, Nick Kledzik <kledzik at apple.com> wrote:
> On Jun 16, 2012, at 8:23 PM, Cesar Mello wrote:
>
> While this will make it compile, the code is not valid to begin with.
> It is trying to do a raw memory copy of a non standard-layout type.
> nameoffset is not guaranteed to directly follow cmdsize.
>
>
> Are you saying that in:
>
> struct A {
>     int  f1;   // offset 0
>     int  f2;   // offset 4
> };
>
> struct B : public A {
>     int  f3;   // offset 8 ?
> };
>
> that f3 is not guaranteed to have the same offset it would have had, had it
> been the third field of A (offset 8)?
>
> -Nick

In the case of non-standard-layout types, yes.

"Unless it is a bit-field (9.6), a most derived object shall have a
non-zero size and shall occupy one or more
bytes of storage. Base class subobjects may have zero size. An object
of trivially copyable or standard-layout
type (3.9) shall occupy contiguous bytes of storage."

"A standard-layout class is a class that:
— has no non-static data members of type non-standard-layout class (or
array of such types) or reference,
— has no virtual functions (10.3) and no virtual base classes (10.1),
— has the same access control (Clause 11) for all non-static data members,
— has no non-standard-layout base classes,
— either has no non-static data members in the most derived class and
at most one base class with
non-static data members, or has no base classes with non-static data
members, and
— has no base classes of the same type as the first non-static data member.
108"

"Nonstatic data members of a (non-union) class with the same access
control (Clause 11) are allocated so
that later members have higher addresses within a class object. The
order of allocation of non-static data
members with different access control is unspecified (11).
Implementation alignment requirements might
cause two adjacent members not to be allocated immediately after each
other; so might requirements for
space for managing virtual functions (10.3) and virtual base classes (10.1)."

load_command has two virtual functions and dylinker_command has
non-static data members with different access specifiers.

- Michael Spencer




More information about the llvm-dev mailing list