diff --git a/src/action.rs b/src/action.rs index 94e70700..89a71d5d 100644 --- a/src/action.rs +++ b/src/action.rs @@ -307,4 +307,37 @@ mod tests { assert_eq!(basic, new); } + + #[test] + fn test_elf_dwz_with_inlines() { + let tmp_dir = Builder::new().prefix("dwz").tempdir().unwrap(); + let full = PathBuf::from("./test_data/linux/basic.dwz"); + let tmp_out = tmp_dir.path().join("output.sym"); + + let action = Action::Dump(Config { + output: tmp_out.clone().into(), + symbol_server: None, + debug_id: None, + code_id: None, + arch: common::get_compile_time_arch(), + num_jobs: 1, + mapping_var: None, + mapping_src: None, + mapping_dest: None, + mapping_file: None, + check_cfi: false, + emit_inlines: true, + }); + + action.action(&[full.to_str().unwrap()]).unwrap(); + + let data = read(tmp_out).unwrap(); + let new: Vec<_> = data.split(|c| *c == b'\n').skip(1).collect(); + + let basic = PathBuf::from("./test_data/linux/basic.dwz.inlines.sym"); + let data = read(basic).unwrap(); + let basic: Vec<_> = data.split(|c| *c == b'\n').skip(1).collect(); + + assert_eq!(basic, new); + } } diff --git a/src/object_info.rs b/src/object_info.rs index bb066385..85735367 100644 --- a/src/object_info.rs +++ b/src/object_info.rs @@ -59,6 +59,11 @@ impl Display for ObjectInfo { } for (n, function_name) in self.inline_origins.iter().enumerate() { + let function_name = if function_name.is_empty() { + "" + } else { + function_name + }; writeln!(f, "INLINE_ORIGIN {} {}", n, function_name)?; } diff --git a/test_data/linux/basic.dwz b/test_data/linux/basic.dwz new file mode 100755 index 00000000..6c003b13 Binary files /dev/null and b/test_data/linux/basic.dwz differ diff --git a/test_data/linux/basic.dwz.inlines.sym b/test_data/linux/basic.dwz.inlines.sym new file mode 100644 index 00000000..15bbac38 --- /dev/null +++ b/test_data/linux/basic.dwz.inlines.sym @@ -0,0 +1,86 @@ +MODULE Linux x86_64 20AD60B0B4C68177552708AA192E77390 basic.dwz +INFO CODE_ID B060AD20C6B47781552708AA192E7739FAC7C84A +FILE 0 /basic.cpp +INLINE_ORIGIN 0 +PUBLIC 1000 0 _init +PUBLIC 1020 0 <.plt ELF section in basic.dwz> +PUBLIC 1030 0 <.plt.got ELF section in basic.dwz> +PUBLIC 1040 0 _start +PUBLIC 1070 0 deregister_tm_clones +PUBLIC 10a0 0 register_tm_clones +PUBLIC 10e0 0 __do_global_dtors_aux +PUBLIC 1120 0 frame_dummy +FUNC 1125 26 0 inline_1(int) +1125 7 2 0 +112c 9 3 0 +1135 11 4 0 +1146 3 5 0 +1149 2 6 0 +FUNC 114b 2c 0 inline_2(int) +INLINE 0 10 0 0 1158 1d +114b d 9 0 +1158 9 3 0 +1161 11 4 0 +1172 3 5 0 +1175 2 11 0 +FUNC 1177 33 0 inline_3(int) +INLINE 0 15 0 0 118a 1e +INLINE 1 10 0 0 118a 1d +1177 13 14 0 +118a 9 3 0 +1193 11 4 0 +11a4 3 5 0 +11a7 1 10 0 +11a8 2 16 0 +FUNC 11aa 3a 0 inline_4(int) +INLINE 0 20 0 0 11c3 1f +INLINE 1 15 0 0 11c3 1e +INLINE 2 10 0 0 11c3 1d +11aa 19 19 0 +11c3 9 3 0 +11cc 11 4 0 +11dd 3 5 0 +11e0 1 10 0 +11e1 1 15 0 +11e2 2 21 0 +FUNC 11e4 d9 0 foo(int) +INLINE 0 26 0 0 120e 20 +INLINE 1 20 0 0 120e 1f 1265 1f +INLINE 2 15 0 0 120e 1e 1265 1e +INLINE 3 10 0 0 120e 1d 1265 1d +INLINE 0 29 0 0 1265 20 1292 1e +INLINE 1 10 0 0 1292 1d +11e4 7 24 0 +11eb 9 25 0 +11f4 1a 26 0 +120e 9 3 0 +1217 11 4 0 +1228 3 5 0 +122b 1 10 0 +122c 1 15 0 +122d 1 20 0 +122e 3 26 0 +1231 d 27 0 +123e c 28 0 +124a 1b 29 0 +1265 9 3 0 +126e 11 4 0 +127f 3 5 0 +1282 1 10 0 +1283 1 15 0 +1284 1 20 0 +1285 d 29 0 +1292 9 3 0 +129b 11 4 0 +12ac 3 5 0 +12af 1 10 0 +12b0 3 29 0 +12b3 8 31 0 +12bb 2 32 0 +FUNC 12bd 1c 0 main +12bd f 35 0 +12cc b 36 0 +12d7 2 37 0 +PUBLIC 12e0 0 __libc_csu_init +PUBLIC 1340 0 __libc_csu_fini +PUBLIC 1344 0 _fini