Commit 4602d983 authored by Matthias Braun's avatar Matthias Braun
Browse files

Introduce ir_visibility_external_protected

parent 09954cdb
......@@ -90,6 +90,12 @@ typedef enum {
* This is equivalent to __attribute__((visibility("hidden"))) in gcc.
*/
ir_visibility_external_private,
/**
* The entity is visible across compilation units and modules and cannot be
* overridden by other modules.
* Equivalent to __attribute__((visible("protected"))) in gcc.
*/
ir_visibility_external_protected,
/**
* The entity is local to the compilation unit.
* A local entity is not visible in other compilation units.
......
......@@ -564,6 +564,17 @@ static const char *get_visibility_directive(const ir_entity *entity,
}
panic("invalid object file format");
}
case ir_visibility_external_protected: {
switch (be_gas_object_file_format) {
case OBJECT_FILE_FORMAT_MACH_O:
return NULL;
case OBJECT_FILE_FORMAT_ELF:
return ".protected";
case OBJECT_FILE_FORMAT_COFF:
panic("ir_visibility_external_protected not supported for COFF");
}
panic("invalid object file format");
}
case ir_visibility_local:
case ir_visibility_private:
*output_global = false;
......
......@@ -209,10 +209,11 @@ static void symtbl_init(void)
INSERT(tt_loop, "loop", true);
INSERT(tt_loop, "noloop", false);
INSERT(tt_visibility, "external", ir_visibility_external);
INSERT(tt_visibility, "external_private", ir_visibility_external_private);
INSERT(tt_visibility, "local", ir_visibility_local);
INSERT(tt_visibility, "private", ir_visibility_private);
INSERT(tt_visibility, "external", ir_visibility_external);
INSERT(tt_visibility, "external_private", ir_visibility_external_private);
INSERT(tt_visibility, "external_protected", ir_visibility_external_protected);
INSERT(tt_visibility, "local", ir_visibility_local);
INSERT(tt_visibility, "private", ir_visibility_private);
INSERT(tt_throws, "throw", true);
INSERT(tt_throws, "nothrow", false);
......@@ -300,10 +301,11 @@ static const char *get_segment_name(ir_segment_t segment)
static const char *get_visibility_name(ir_visibility visibility)
{
switch (visibility) {
case ir_visibility_external: return "external";
case ir_visibility_external_private: return "external_private";
case ir_visibility_local: return "local";
case ir_visibility_private: return "private";
case ir_visibility_external: return "external";
case ir_visibility_external_private: return "external_private";
case ir_visibility_external_protected: return "external_protected";
case ir_visibility_local: return "local";
case ir_visibility_private: return "private";
}
panic("invalid visibility");
}
......
......@@ -860,9 +860,10 @@ int entity_is_externally_visible(const ir_entity *entity)
switch (visibility) {
case ir_visibility_local:
case ir_visibility_private:
return get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER;
return (get_entity_linkage(entity) & IR_LINKAGE_HIDDEN_USER) != 0;
case ir_visibility_external:
case ir_visibility_external_private:
case ir_visibility_external_protected:
return true;
}
panic("Invalid visibility for entity %+F", entity);
......
......@@ -175,8 +175,8 @@ struct ir_entity {
ENUMBF(ir_volatility) volatility:1; /**< Volatility of entity content.*/
ENUMBF(ir_align) aligned:1; /**< Alignment of entity content. */
ENUMBF(ir_entity_usage) usage:4; /**< Usage type of entity */
ENUMBF(ir_visibility) visibility:2; /**< Visibility of entity. */
uint16_t alignment; /**< entity alignment in bytes */
ENUMBF(ir_visibility) visibility:3; /**< Visibility of entity. */
ENUMBF(unsigned) alignment:12; /**< entity alignment in bytes */
ir_visited_t visit; /**< visited counter for walks of the type
information. */
dbg_info *dbi; /**< A pointer to information for debug support. */
......
......@@ -199,9 +199,17 @@ static bool check_initializer(const ir_initializer_t *initializer,
static bool is_externally_visible(const ir_entity *entity)
{
ir_visibility visibility = get_entity_visibility(entity);
return visibility == ir_visibility_external
|| visibility == ir_visibility_external_private;
switch (get_entity_visibility(entity)) {
case ir_visibility_external:
case ir_visibility_external_private:
case ir_visibility_external_protected:
return true;
case ir_visibility_private:
case ir_visibility_local:
return false;
}
/* Return true here, the verification will fail elsewhere for this */
return true;
}
static bool check_external_linkage(const ir_entity *entity, ir_linkage linkage,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment