[llvm-commits] [llvm] r92933 - /llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp

Eric Christopher echristo at apple.com
Thu Jan 7 12:56:55 PST 2010


On Jan 7, 2010, at 11:52 AM, Evan Cheng wrote:

> Is this because the linker can't change values in read-only segments?

Basically it's very poor performance to have relocations in read-only segments and somewhat unsafe.  In Mach-O we simply don't allow relocations in the text segment by default.

> Could you illustrate with an example? Test case(s) for this and / or 92934?

I tried to work up a simple testcase for this but wasn't able to - it's coming out of JavaScriptCore's pcre library and indirect branches.  Basically we've got code like this coming out:

.text

someFunc:
...
leaq LCIP##(%rip), %rax
...



__TEXT,__const
LCIP##:
  .quad someOtherAddr

which, of course, requires a relocation.  The code that decided that the constant pool entry needed to be in the text section didn't think about read only code with a relocation.

Also, the code should have been written like this in the first place:

.text

someFunc:
...
leaq someOtherAddr(%rip), %rax

but it was best to fix both problems separately.

Though some version of JSC might make a good addition to the nightly test machinery at some point since it uses a lot of features.

-eric



More information about the llvm-commits mailing list