Skip to content

Add DW_AT_comp_dir to elf files. #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions output/outelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static struct hash_table section_by_name;
static struct elf_symbol *fwds;

static char elf_module[FILENAME_MAX];
static char elf_dir[FILENAME_MAX];

extern const struct ofmt of_elf32;
extern const struct ofmt of_elf64;
Expand Down Expand Up @@ -552,8 +553,10 @@ static void elf_init(void)
".shstrtab", ".strtab", ".symtab", ".symtab_shndx", NULL
};
const char * const *p;
const char * cur_path = nasm_realpath(inname);

strlcpy(elf_module, inname, sizeof(elf_module));
strlcpy(elf_dir, nasm_dirname(cur_path), sizeof(elf_dir));
sects = NULL;
nsects = sectlen = 0;
syms = saa_init((int32_t)sizeof(struct elf_symbol));
Expand Down Expand Up @@ -3307,7 +3310,8 @@ static void dwarf_generate(void)
saa_write32(pinforel, (dwarf_linesym << 8) + R_386_32); /* reloc to line */
saa_write32(pinforel, 0);
saa_write32(pinfo,0); /* DW_AT_stmt_list */
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1); /* DW_AT_name */
saa_wbytes(pinfo, elf_dir, strlen(elf_dir)+1); /* DW_AT_comp_dir */
saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1);
saa_write16(pinfo,DW_LANG_Mips_Assembler);
saa_write8(pinfo,2); /* abbrviation number LEB128u */
Expand Down Expand Up @@ -3346,7 +3350,8 @@ static void dwarf_generate(void)
saa_write32(pinforel, (dwarf_linesym << 8) + R_X86_64_32); /* reloc to line */
saa_write32(pinforel, 0);
saa_write32(pinfo,0); /* DW_AT_stmt_list */
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1); /* DW_AT_name */
saa_wbytes(pinfo, elf_dir, strlen(elf_dir)+1); /* DW_AT_comp_dir */
saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1);
saa_write16(pinfo,DW_LANG_Mips_Assembler);
saa_write8(pinfo,2); /* abbrviation number LEB128u */
Expand Down Expand Up @@ -3386,7 +3391,8 @@ static void dwarf_generate(void)
saa_write64(pinforel, (dwarf_linesym << 32) + R_X86_64_32); /* reloc to line */
saa_write64(pinforel, 0);
saa_write32(pinfo,0); /* DW_AT_stmt_list */
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1);
saa_wbytes(pinfo, elf_module, strlen(elf_module)+1); /* DW_AT_name */
saa_wbytes(pinfo, elf_dir, strlen(elf_dir)+1); /* DW_AT_comp_dir */
saa_wbytes(pinfo, nasm_signature(), nasm_signature_len()+1);
saa_write16(pinfo,DW_LANG_Mips_Assembler);
saa_write8(pinfo,2); /* abbrviation number LEB128u */
Expand Down Expand Up @@ -3424,6 +3430,8 @@ static void dwarf_generate(void)
saa_write8(pabbrev,DW_FORM_data4);
saa_write8(pabbrev,DW_AT_name);
saa_write8(pabbrev,DW_FORM_string);
saa_write8(pabbrev,DW_AT_comp_dir);
saa_write8(pabbrev,DW_FORM_string);
saa_write8(pabbrev,DW_AT_producer);
saa_write8(pabbrev,DW_FORM_string);
saa_write8(pabbrev,DW_AT_language);
Expand Down