Correct the files' directory index when downgrading DWARF5 -> 4 (#1989)

* correct the files' directory index when downgrading DWARF5 -> 4
This commit is contained in:
Gabor Greif
2020-07-07 18:20:32 +02:00
committed by GitHub
parent 9900641674
commit 79f054f77f

View File

@@ -121,8 +121,11 @@ where
dirs.push(dir_id); dirs.push(dir_id);
} }
let mut files = Vec::new(); let mut files = Vec::new();
// Since we are outputting DWARF-4, perform base change.
let directory_index_correction = if header.version() >= 5 { 1 } else { 0 };
for file_entry in header.file_names() { for file_entry in header.file_names() {
let dir_id = dirs[file_entry.directory_index() as usize]; let dir_index = file_entry.directory_index() + directory_index_correction;
let dir_id = dirs[dir_index as usize];
let file_id = out_program.add_file( let file_id = out_program.add_file(
clone_attr_string( clone_attr_string(
&file_entry.path_name(), &file_entry.path_name(),