summaryrefslogtreecommitdiff
path: root/tools/lto
diff options
context:
space:
mode:
authorNick Kledzik <kledzik@apple.com>2009-06-01 23:41:09 +0000
committerNick Kledzik <kledzik@apple.com>2009-06-01 23:41:09 +0000
commit4bdf73025a56bd2affad27f6eae93c7f8d2a06d4 (patch)
tree3afac9050b82eee5d07892c2b9f579ac093f821e /tools/lto
parent4150d83abe90a5da4ddf86433b7bf4329acfa57c (diff)
downloadllvm-4bdf73025a56bd2affad27f6eae93c7f8d2a06d4.tar.gz
llvm-4bdf73025a56bd2affad27f6eae93c7f8d2a06d4.tar.bz2
llvm-4bdf73025a56bd2affad27f6eae93c7f8d2a06d4.tar.xz
update comments about .objc_ symbols being generated
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72708 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/LTOModule.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index c769af1e2e..939d0eacd1 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -270,8 +270,26 @@ void LTOModule::addDefinedDataSymbol(GlobalValue* v, Mangler& mangler)
// add to list of defined symbols
addDefinedSymbol(v, mangler, false);
- // special case i386/ppc ObjC data structures in magic sections
- if ( v->hasSection() ) {
+ // Special case i386/ppc ObjC data structures in magic sections:
+ // The issue is that the old ObjC object format did some strange
+ // contortions to avoid real linker symbols. For instance, the
+ // ObjC class data structure is allocated statically in the executable
+ // that defines that class. That data structures contains a pointer to
+ // its superclass. But instead of just initializing that part of the
+ // struct to the address of its superclass, and letting the static and
+ // dynamic linkers do the rest, the runtime works by having that field
+ // instead point to a C-string that is the name of the superclass.
+ // At runtime the objc initialization updates that pointer and sets
+ // it to point to the actual super class. As far as the linker
+ // knows it is just a pointer to a string. But then someone wanted the
+ // linker to issue errors at build time if the superclass was not found.
+ // So they figured out a way in mach-o object format to use an absolute
+ // symbols (.objc_class_name_Foo = 0) and a floating reference
+ // (.reference .objc_class_name_Bar) to cause the linker into erroring when
+ // a class was missing.
+ // The following synthesizes the implicit .objc_* symbols for the linker
+ // from the ObjC data structures generated by the front end.
+ if ( v->hasSection() /* && isTargetDarwin */ ) {
// special case if this data blob is an ObjC class definition
if ( v->getSection().compare(0, 15, "__OBJC,__class,") == 0 ) {
if (GlobalVariable* gv = dyn_cast<GlobalVariable>(v)) {