X86-64: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Line 162: Line 162:
| HP UX 11
| HP UX 11
| LP64
| LP64
|}

=== Text Segment Types ===

Another thing that you must keep in mind, that although the address space (and with it all the pointers) are 64 bit wide, the generated code in the text segment is most likely not. That's because by default gcc compiles to the "mov" instruction which has only 32 bit immediate. This means 64 bit programs are limited to 2G, just as 32 bit mode programs.

If you have ever seen an error message like this:
<source lang="bash">
relocation truncated to fit: R_X86_64_32 against symbol
</source>
then your code hit this barrier. For Assembly, you must use the "movabs" instruction instead of "mov", and for gcc you need to select a different text segment model with the "-mcmodel" argument.

{| {{wikitable}}
! Flag
! Text Segment Addressing
|-
| -mcmodel=small
| The program and its symbols must be linked in the lower 2 GB of the address space (this is the default model)
|-
| -mcmodel=large
| This model makes no assumptions about addresses and sizes of sections.
|}
|}