Dear All,

We are trying to embed a raw vector of chars into .s file using the following code:

        tree index_type = build_index_type(size_int(moduleBitcode.size()));
        tree const_char_type = build_qualified_type(
            unsigned_char_type_node, TYPE_QUAL_CONST);
        tree string_type = build_array_type(const_char_type, index_type);
        string_type = build_variant_type_copy(string_type);
tree string_val = build_string(moduleBitcode.size(), moduleBitcode.data());
        TREE_TYPE(string_val) = string_type;

        tree var = create_tmp_var_raw(string_type, NULL);
        char* tmpname = tmpnam(NULL) + strlen(P_tmpdir);
        if (*tmpname == '/') tmpname++;
        DECL_NAME (var) = get_identifier (tmpname);
        DECL_SECTION_NAME (var) = build_string (11, ".kernelgen");
        TREE_PUBLIC (var) = 1;
        TREE_STATIC (var) = 1;
        TREE_READONLY (var) = 1;
        DECL_INITIAL (var) = string_val;
        varpool_finalize_decl (var);

The problem is that build_string always null-terminates our data array, which is unexpected. I tried to clone build_string and modify it in such way that it does not add '\0' in the end. But even in this case the output object size is moduleBitcode.size() + 1. Why? How to change this code to write the data exactly as it is - without null-terminator?

Many thanks,
- Dima.

Reply via email to