This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: size of an address when compiling with -m64


David Livshin wrote:

double a[DIM][DIM];



movl $a, %eax


The register 'eax' ( 'rax' actualy ) is used later in the code as the base for an address.
Questions:


  1. Why 'movl'  and not 'movq' is used? ( It seems that compilers
     assumes that the size of the address of the symbol 'a' is 32 bits
     only )
In other words, the compiler has assumed that the global data object "a" will be linked in the first 4GB of the address space.

If it turns out not to be, then you will get an error at link time.

I have read (but not really understood) various things about "memory model" restrictions in x86_64 that imply rules. I expect (but I'm not sure) one such rule is that certain globals in the main image are restricted to the first 4GB.
2. How to force the compiler to generate 'movq'?
I know you can use -fPIC when compiling code for .so files to turn off some of the compile time assumptions about link time operations. I assume you're not compiling a .so, so -fPIC is probably drastic (if not flat out incorrect) for your purposes.

Do you really think that 8MB data object needs to be linkable outside the first 4GB?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]