Make ctfconvert work correctly on clang-compiled object files. Clang

puts the full original source filename in the STT_FILE entry of the ELF
symbol table, while gcc saves only the basename.

Since the DWARF DW_AT_name attribute contains the full source filename,
both for clang and gcc, ctfconvert takes just the basename of it, for
matching with the STT_FILE entry.  So when attempting to match with such
an entry, use its basename, if necessary.

Reported by:	avg
MFC after:	1 week
This commit is contained in:
Dimitry Andric 2013-03-07 22:16:35 +00:00
parent d023c5ae25
commit 8b0d8e9f2f
1 changed files with 3 additions and 0 deletions

View File

@ -363,6 +363,7 @@ sort_iidescs(Elf *elf, const char *file, tdata_t *td, int fuzzymatch,
for (i = 0; i < nent; i++) {
GElf_Sym sym;
char *bname;
iidesc_t **tolist;
GElf_Sym ssym;
iidesc_match_t smatch;
@ -377,6 +378,8 @@ sort_iidescs(Elf *elf, const char *file, tdata_t *td, int fuzzymatch,
switch (GELF_ST_TYPE(sym.st_info)) {
case STT_FILE:
bname = strrchr(match.iim_name, '/');
bname = bname == NULL ? match.iim_name : bname + 1;
match.iim_file = match.iim_name;
continue;
case STT_OBJECT: