Commit 4392e72f authored by Matthias Braun's avatar Matthias Braun
Browse files

dwarf: fix escaping of special filenames

parent 0f73b43e
......@@ -94,17 +94,18 @@ static char *comp_dir;
static unsigned insert_file(const char *filename)
{
unsigned num;
void *entry = pmap_get(void, env.file_map, filename);
void *entry = pmap_get(void, env.file_map, filename);
if (entry != NULL) {
return PTR_TO_INT(entry);
}
ARR_APP1(const char*, env.file_list, filename);
num = (unsigned)ARR_LEN(env.file_list);
unsigned num = (unsigned)ARR_LEN(env.file_list);
pmap_insert(env.file_map, filename, INT_TO_PTR(num));
/* TODO: quote chars in string */
be_emit_irprintf("\t.file %u \"%s\"\n", num, filename);
be_emit_irprintf("\t.file %u ", num);
be_gas_emit_string_literal(filename);
be_emit_char('\n');
be_emit_write_line();
return num;
}
......
......@@ -772,6 +772,15 @@ static size_t emit_string_initializer(const ir_initializer_t *initializer)
return initializer->compound.n_initializers;
}
void be_gas_emit_string_literal(const char *string)
{
be_emit_char('"');
for (const char *c = string; *c != '\0'; ++c) {
emit_string_char(*c);
}
be_emit_char('"');
}
void be_gas_emit_cstring(const char *string)
{
be_emit_cstring("\t.asciz \"");
......
......@@ -104,6 +104,11 @@ void be_gas_begin_block(const ir_node *block, bool needs_label);
*/
void be_gas_emit_cstring(const char *string);
/**
* emit a string literal. This function takes care of escaping special chars.
*/
void be_gas_emit_string_literal(const char *string);
/**
* Starts emitting a compilation unit. This emits:
* - global assembler snippets
......
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