[cfe-users] Telling clang a data object is "near"
oporat at yahoo.com
Sun Jun 23 09:40:27 PDT 2013
I'm using clang for OS X development. The data model used for x86_64 makes a distinction between near and far data...
static int x;
is assumed to be reachable within 2GB rip-relative addressing and generates code accordingly.
extern int x;
is not assumed to be so reachable. It generates slightly longer code that may need to use the GOT. The linker (either static or dynamic) has the option of optimizing and replacing a mov instruction from GOT with a lea instruction if it finds that the data element is accessible with a 2GB rip-relative address. However, even with a mov->lea replacement, a longer instruction sequence is usually needed (such as 2 instructions where one would suffice if the data is known to be near.)
Is there a way to tell clang to assume that a piece of data is near, such as
extern __attribute((assume_near))__ int x;
and generate code accordingly (i.e. not via GOT access).
Thanks in Advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-users