Пример #1
0
        /**
         * Creates the data symbol for a TLS variable for Mach-O.
         *
         * Input:
         *      vd  the variable declaration for the symbol
         *      s   the regular symbol for the variable
         *
         * Returns: the newly create symbol
         */
        Symbol *createTLVDataSymbol(VarDeclaration *vd, Symbol *s)
        {
            assert(config.objfmt == OBJ_MACH && I64 && (s->ty() & mTYLINK) == mTYthread);

            OutBuffer buffer;
            buffer.writestring(s->Sident);
            buffer.write("$tlv$init", 9);

            const char *tlvInitName = buffer.extractString();
            Symbol *tlvInit = symbol_name(tlvInitName, SCstatic, type_fake(vd->type->ty));
            tlvInit->Sdt = NULL;
            tlvInit->Salignment = type_alignsize(s->Stype);

            type_setty(&tlvInit->Stype, tlvInit->Stype->Tty | mTYthreadData);
            type_setmangle(&tlvInit->Stype, mangle(vd, tlvInit));

            return tlvInit;
        }
Пример #2
0
        /**
         * Creates the data symbol used to initialize a TLS variable for Mach-O.
         *
         * Params:
         *      vd = the variable declaration for the symbol
         *      s = the back end symbol corresponding to vd
         *
         * Returns: the newly created symbol
         */
        Symbol *createTLVDataSymbol(VarDeclaration *vd, Symbol *s)
        {
            assert(config.objfmt == OBJ_MACH && I64 && (s->ty() & mTYLINK) == mTYthread);

            // Compute identifier for tlv symbol
            OutBuffer buffer;
            buffer.writestring(s->Sident);
            buffer.write("$tlv$init", 9);
            const char *tlvInitName = buffer.peekString();

            // Compute type for tlv symbol
            type *t = type_fake(vd->type->ty);
            type_setty(&t, t->Tty | mTYthreadData);
            type_setmangle(&t, mangle(vd));

            Symbol *tlvInit = symbol_name(tlvInitName, SCstatic, t);
            tlvInit->Sdt = NULL;
            tlvInit->Salignment = type_alignsize(s->Stype);
            if (vd->linkage == LINKcpp)
                tlvInit->Sflags |= SFLpublic;

            return tlvInit;
        }