Re: Size of C/C++ data type from GNU GCC/g++ compiled ELF 64-bit LSB executable, AMD x86-64 vs. ELF 32-bit LSB executable, Intel 80386

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Brian, Daniel, and Andrew,

You demystify the deferentiated implementations of ABIs over 64-bit AMD
Opteron vs. 32-bit P4/P5 architectures; and the corresponding
interpretations of "sizeof" from the GNU/GCC compiler.  

I understand them mostly now. I will write a parser in Perl to sift out from
C/C++ code the ambiguous "typedef", which result in different sizes in
64-bit vs. 32-bit ELF binaries. I will unify the usage of the C/C++ data
types and modifiers from the following lists, which have the same sizes for
both 64-bit and 32-bit. 

size of int 	4
size of float 	4
size of double 	8
size of char 	1
size of bool 	1
size of char 	1
size of unsigned char 	1
size of signed char 	1
size of unsigned int 	4
size of signed int 	4
size of short int 	2
size of unsigned short int 	2
size of signed short int 	2

Daniel's class template way is practical; I will refer it in future
projects.  

Tom   



Andrew Haley-5 wrote:
> 
> tom peng writes:
> 
>  > Thanks for correcting my typo on "signed long int 4 8".
>  > 
>  > The problem I have here is about simulating a hardware model in C/C++.
> The
>  > hardware model development was based on 32-bit CPU originally. We had
>  > presumed "signed long int" as 32-bit/4 byte length -- as specified in
> C/C++
>  > code "typedef signed long int int32".
>  > 
>  > It is apparent that this "int32" in 64-bit ELF executable is of length
> 8
>  > bytes, not what we expect. It "might" cause the hw simulation
> inconsistency
>  > when running in 64 vs. 32 ELF format.
>  > 
>  > I hope to get a generic picture about the size difference of C/C++ data
> type
>  > and their modifiers in 32/64 ELF format compiled by GCC.
>  > 
>  > Are those 32-bit / 64-bit difference stipulated in C/C++ standard or
> ruled
>  > by the GNU/GCC compiler?
> 
> Neither of those.  They are defined by the ABI, at
> http://refspecs.freestandards.org/elf/x86_64-abi-0.95.pdf Page 12.
> 
> GCC, as the system compiler, must conform to this specification.  It
> isn't something that we compiler writers get to decide for ourseleves.
> 
> Andrew.
> 
> 

-- 
View this message in context: http://www.nabble.com/Size-of-C-C%2B%2B-data-type-from-GNU-GCC-g%2B%2B-compiled-ELF-64-bit-LSB-executable%2C-AMD-x86-64-vs.-ELF-32-bit-LSB-executable%2C-Intel-80386-tf3942845.html#a11193485
Sent from the gcc - Help mailing list archive at Nabble.com.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux