summaryrefslogtreecommitdiffhomepage
path: root/ir/be/begnuas.c
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-09-07 02:52:06 +0200
committerMatthias Braun <matze@braunis.de>2015-09-07 03:50:11 +0200
commit029646c146a2fbba7d287ae85efb9d71005b92c2 (patch)
tree56b9399cfc10d62ab732d1106d78e7644243034c /ir/be/begnuas.c
parent76b87ca10a115a89d5e3a0569c96b91d940bf9d1 (diff)
begnuas: use designated initializers for section names
Diffstat (limited to 'ir/be/begnuas.c')
-rw-r--r--ir/be/begnuas.c62
1 files changed, 30 insertions, 32 deletions
diff --git a/ir/be/begnuas.c b/ir/be/begnuas.c
index affb42e..fde3af8 100644
--- a/ir/be/begnuas.c
+++ b/ir/be/begnuas.c
@@ -102,21 +102,18 @@ static void emit_section_sparc(be_gas_section_t section,
be_gas_section_t base = section & GAS_SECTION_TYPE_MASK;
be_gas_section_t flags = section & ~GAS_SECTION_TYPE_MASK;
static const char *const basename[GAS_SECTION_LAST+1] = {
- "text",
- "data",
- "rodata",
- "bss",
- "ctors",
- "dtors",
- "jcr",
- NULL, /* cstring */
- NULL, /* pic trampolines */
- NULL, /* pic symbols */
- "debug_info",
- "debug_abbrev",
- "debug_line",
- "debug_pubnames",
- "debug_frame",
+ [GAS_SECTION_TEXT] = "text",
+ [GAS_SECTION_DATA] = "data",
+ [GAS_SECTION_RODATA] = "rodata",
+ [GAS_SECTION_BSS] = "bss",
+ [GAS_SECTION_CONSTRUCTORS] = "ctors",
+ [GAS_SECTION_DESTRUCTORS] = "dtors",
+ [GAS_SECTION_JCR] = "jcr",
+ [GAS_SECTION_DEBUG_INFO] = "debug_info",
+ [GAS_SECTION_DEBUG_ABBREV] = "debug_abbrev",
+ [GAS_SECTION_DEBUG_LINE] = "debug_line",
+ [GAS_SECTION_DEBUG_PUBNAMES] = "debug_pubnames",
+ [GAS_SECTION_DEBUG_FRAME] = "debug_frame",
};
if (current_section == section && !(section & GAS_SECTION_FLAG_COMDAT))
@@ -129,7 +126,9 @@ static void emit_section_sparc(be_gas_section_t section,
if (flags & GAS_SECTION_FLAG_TLS)
be_emit_char('t');
assert(base < (be_gas_section_t)ARRAY_SIZE(basename));
- be_emit_string(basename[base]);
+ char const *const name = basename[base];
+ assert(name != NULL);
+ be_emit_string(name);
if (flags & GAS_SECTION_FLAG_COMDAT) {
be_emit_char('.');
@@ -170,21 +169,18 @@ static void emit_section(be_gas_section_t section, const ir_entity *entity)
const char *type;
const char *flags;
} sectioninfos[GAS_SECTION_LAST+1] = {
- { "text", "progbits", "ax" },
- { "data", "progbits", "aw" },
- { "rodata", "progbits", "a" },
- { "bss", "nobits", "aw" },
- { "ctors", "progbits", "aw" },
- { "dtors", "progbits", "aw" },
- { "jcr", "progbits", "aw" },
- { NULL, NULL, NULL }, /* cstring */
- { NULL, NULL, NULL }, /* pic trampolines */
- { NULL, NULL, NULL }, /* pic symbols */
- { "debug_info", "progbits", "" },
- { "debug_abbrev", "progbits", "" },
- { "debug_line", "progbits", "" },
- { "debug_pubnames", "progbits", "" },
- { "debug_frame", "progbits", "" },
+ [GAS_SECTION_TEXT] = { "text", "progbits", "ax" },
+ [GAS_SECTION_DATA] = { "data", "progbits", "aw" },
+ [GAS_SECTION_RODATA] = { "rodata", "progbits", "a" },
+ [GAS_SECTION_BSS] = { "bss", "nobits", "aw" },
+ [GAS_SECTION_CONSTRUCTORS] = { "ctors", "progbits", "aw" },
+ [GAS_SECTION_DESTRUCTORS] = { "dtors", "progbits", "aw" },
+ [GAS_SECTION_JCR] = { "jcr", "progbits", "aw" },
+ [GAS_SECTION_DEBUG_INFO] = { "debug_info", "progbits", "" },
+ [GAS_SECTION_DEBUG_ABBREV] = { "debug_abbrev", "progbits", "" },
+ [GAS_SECTION_DEBUG_LINE] = { "debug_line", "progbits", "" },
+ [GAS_SECTION_DEBUG_PUBNAMES] = { "debug_pubnames", "progbits", "" },
+ [GAS_SECTION_DEBUG_FRAME] = { "debug_frame", "progbits", "" },
};
if (be_gas_object_file_format == OBJECT_FILE_FORMAT_MACH_O) {
@@ -228,7 +224,9 @@ static void emit_section(be_gas_section_t section, const ir_entity *entity)
/* section name */
if (flags & GAS_SECTION_FLAG_TLS)
be_emit_char('t');
- be_emit_string(sectioninfos[base].name);
+ char const *const name = sectioninfos[base].name;
+ assert(name != NULL);
+ be_emit_string(name);
if (flags & GAS_SECTION_FLAG_COMDAT) {
be_emit_char('.');
be_gas_emit_entity(entity);