Commit 86ac6281 authored by Matthias Braun's avatar Matthias Braun
Browse files

Introduce external_private visibility

parent d8d48197
......@@ -85,6 +85,11 @@ typedef enum {
* which are considered 'uninitialized' in this case).
*/
ir_visibility_external,
/**
* The entity is visible across compilation units, but not accross modules.
* This is equivalent to __attribute__((visibility("hidden"))) in gcc.
*/
ir_visibility_external_private,
/**
* The entity is local to the compilation unit.
* A local entity is not visible in other compilation units.
......
......@@ -470,6 +470,31 @@ static void emit_weak(const ir_entity *entity)
emit_symbol_directive(directive, entity);
}
static const char *get_visibility_directive(const ir_entity *entity,
bool *output_global)
{
switch (get_entity_visibility(entity)) {
case ir_visibility_external: return NULL;
case ir_visibility_external_private: {
switch (be_gas_object_file_format) {
case OBJECT_FILE_FORMAT_MACH_O:
*output_global = false;
return ".private_extern";
case OBJECT_FILE_FORMAT_ELF:
return ".hidden";
case OBJECT_FILE_FORMAT_COFF:
panic("ir_visibility_external_private not supported for COFF");
}
panic("invalid object file format");
}
case ir_visibility_local:
case ir_visibility_private:
*output_global = false;
return NULL;
}
panic("invalid visibility");
}
static void emit_visibility(const ir_entity *entity, bool implicit_globl)
{
ir_linkage const linkage = get_entity_linkage(entity);
......@@ -478,15 +503,13 @@ static void emit_visibility(const ir_entity *entity, bool implicit_globl)
emit_weak(entity);
if (entity_has_definition(entity)) {
switch (get_entity_visibility(entity)) {
case ir_visibility_external:
if (!implicit_globl)
emit_symbol_directive(".globl", entity);
break;
case ir_visibility_local:
case ir_visibility_private:
break;
}
bool output_global = !implicit_globl;
const char *const directive
= get_visibility_directive(entity, &output_global);
if (output_global)
emit_symbol_directive(".globl", entity);
if (directive != NULL)
emit_symbol_directive(directive, entity);
}
if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O
......
......@@ -209,9 +209,10 @@ static void symtbl_init(void)
INSERT(tt_loop, "loop", true);
INSERT(tt_loop, "noloop", false);
INSERT(tt_visibility, "local", ir_visibility_local);
INSERT(tt_visibility, "external", ir_visibility_external);
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, "local", ir_visibility_local);
INSERT(tt_visibility, "private", ir_visibility_private);
INSERT(tt_throws, "throw", true);
INSERT(tt_throws, "nothrow", false);
......@@ -299,9 +300,10 @@ static const char *get_segment_name(ir_segment_t segment)
static const char *get_visibility_name(ir_visibility visibility)
{
switch (visibility) {
case ir_visibility_local: return "local";
case ir_visibility_external: return "external";
case ir_visibility_private: return "private";
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";
}
panic("invalid visibility");
}
......
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