int tr_verify(void) { bool fine = true; type_walk(check_tore, NULL, &fine); for (ir_segment_t s = IR_SEGMENT_FIRST; s <= IR_SEGMENT_LAST; ++s) { ir_type const *const segment = get_segment_type(s); for (size_t e = 0; e < get_compound_n_members(segment); ++e) { ir_entity const *const entity = get_compound_member(segment, e); ident *const ld_ident = get_entity_ld_ident(entity); if (ld_ident == NULL && get_entity_visibility(entity) != ir_visibility_private) { report_error("public segment member %+F has no name", entity); fine = false; continue; } if (segment->flags & tf_info) fine &= verify_info_member(segment, entity); } } ir_type const *const thread_locals = get_segment_type(IR_SEGMENT_THREAD_LOCAL); for (size_t i = 0, n = get_compound_n_members(thread_locals); i < n; ++i) { const ir_entity *entity = get_compound_member(thread_locals, i); /* this is odd and should not be allowed I think */ if (is_method_entity(entity)) { report_error("method %+F in thread local segment", entity); fine = false; } if (get_entity_linkage(entity) & IR_LINKAGE_CONSTANT) { report_error("entity %+F in thread local segment is constant", entity); fine = false; } } return fine; }
static void add_pointer_in_jcr_segment(ir_entity *entity) { if (!create_jcr_segment) return; ir_type *segment = get_segment_type(IR_SEGMENT_JCR); ident *id = id_unique("jcr_ptr"); ir_entity *ptr = new_entity(segment, id, type_reference); ir_graph *irg = get_const_code_irg(); ir_node *val = new_r_Address(irg, entity); set_entity_ld_ident(ptr, new_id_from_chars("", 0)); set_entity_visibility(ptr, ir_visibility_private); set_entity_linkage(ptr, IR_LINKAGE_CONSTANT|IR_LINKAGE_HIDDEN_USER); set_entity_alignment(ptr, 1); ir_initializer_t *const init = create_initializer_const(val); set_entity_initializer(ptr, init); }
int tr_verify(void) { bool fine = true; ir_type *constructors; ir_type *destructors; ir_type *thread_locals; type_walk(check_tore, NULL, &fine); for (ir_segment_t s = IR_SEGMENT_FIRST; s <= IR_SEGMENT_LAST; ++s) { const ir_type *type = get_segment_type(s); for (size_t e = 0; e < get_compound_n_members(type); ++e) { ir_entity *entity = get_compound_member(type, e); if (get_entity_ld_ident(entity) == NULL && get_entity_visibility(entity) != ir_visibility_private) { report_error("public segment member %+F has no name", entity); fine = false; } } } constructors = get_segment_type(IR_SEGMENT_CONSTRUCTORS); for (size_t i = 0, n = get_compound_n_members(constructors); i < n; ++i) { const ir_entity *entity = get_compound_member(constructors, i); if ((get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER) == 0) { report_error("entity %+F in constructors without LINKAGE_HIDDEN_USER", entity); fine = false; } /* Mach-O doesn't like labels in this section */ if (get_entity_ld_name(entity)[0] != '\0') { report_error("entity %+F in constructors must not have an ld_name", entity); fine = false; } } destructors = get_segment_type(IR_SEGMENT_DESTRUCTORS); for (size_t i = 0, n = get_compound_n_members(destructors); i < n; ++i) { const ir_entity *entity = get_compound_member(destructors, i); if ((get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER) == 0) { report_error("entity %+F in destructors without LINKAGE_HIDDEN_USER", entity); fine = false; } /* Mach-O doesn't like labels in this section */ if (get_entity_ld_name(entity)[0] != '\0') { report_error("entity %+F in destructors must not have an ld_name", entity); fine = false; } } thread_locals = get_segment_type(IR_SEGMENT_THREAD_LOCAL); for (size_t i = 0, n = get_compound_n_members(thread_locals); i < n; ++i) { const ir_entity *entity = get_compound_member(thread_locals, i); /* this is odd and should not be allowed I think */ if (is_method_entity(entity)) { report_error("method %+F in thread local segment"); fine = false; } if (get_entity_linkage(entity) & IR_LINKAGE_CONSTANT) { report_error("entity %+F in thread local segment is constant"); fine = false; } } return fine; }