I have a binary object that was generated on a 64-bit SGI machine using the MIPSpro compiler. I am trying to read this binary on a x86_64 64-bit machine with RHEL 6.7. The structure of the object is similar to
class A {
public:
A(){
a_ = 1;
}
A(int a){
a_ = a;
}
virtual ~A();
protected:
int a_;
};
class B : public A {
public:
B(double b, int a){
b_ = b;
a_ = a;
}
virtual ~B();
private:
double b_;
};
A::~A(){}
B::~B(){}
After reading the binary file, byte swapping (due to the nature), I found that it was bcorrect, but aincorrect, which indicates data inconsistency with my current assembly.
I have two questions. First, how does the MIPS Pro compiler align its fields and how does it differ from the way gcc. I am interested in the case of inherited classes. Secondly, is there an option in gccor C ++ that can cause the alignment to be the same as the MIPS method?
1:
MIPS ABI n64. ++, MIPS. x86_64.
2:
sizeof virtual .
MIPS x86_64
size of class A: 4
size of class B: 16
virtual SGI MIPS
size of class A: 8
size of class B: 16
x86-64 Linux:
size of class A: 16
size of class B: 24
, ( ?). , ?