Question

Assume the x86 64 and linux platform.

If you look into the ELF header, the offset are all 64bit.

So it's easy to create an object file larger than 4G with relocatoin R_X86_64_64. This means a static .o file and executable can be as large as 64bit can represent.

However, for shared library, like gcc , we only have R_X86_64_PLT32 relocation. This means that it's impossible to create a shared library large than 4GB, right?

So if I want to build a huge program, one of the .o file is huge enough (>4GB) , the only choice is static linking?

Any comment is welcome.

Thanks, limi

Was it helpful?

Solution

The x86-64 ABI used by Linux defines a "large model" specifically to avoid such size limitations, which includes 64-bit relocation types for the GOT and PLT. (See the table in section 4.4.2, and the instruction sequences in 3.5.5 which show how they are used.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top