Index: contrib/elftoolchain/libdwarf/libdwarf_lineno.c =================================================================== --- contrib/elftoolchain/libdwarf/libdwarf_lineno.c +++ contrib/elftoolchain/libdwarf/libdwarf_lineno.c @@ -33,7 +33,7 @@ Dwarf_Error *error, Dwarf_Debug dbg) { Dwarf_LineFile lf; - const char *dirname; + const char *basedir, *incdir; uint8_t *src; int slen; @@ -56,18 +56,33 @@ /* Make full pathname if need. */ if (*lf->lf_fname != '/') { - dirname = compdir; - if (lf->lf_dirndx > 0) - dirname = li->li_incdirs[lf->lf_dirndx - 1]; - if (dirname != NULL) { - slen = strlen(dirname) + strlen(lf->lf_fname) + 2; + basedir = incdir = NULL; + if (lf->lf_dirndx > 0) { + incdir = li->li_incdirs[lf->lf_dirndx - 1]; + if (incdir[0] == '/') + basedir = incdir; + } else { + basedir = compdir; + } + if (basedir != NULL) { + slen = strlen(basedir) + strlen(lf->lf_fname) + 2; if ((lf->lf_fullpath = malloc(slen)) == NULL) { free(lf); DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); return (DW_DLE_MEMORY); } - snprintf(lf->lf_fullpath, slen, "%s/%s", dirname, + snprintf(lf->lf_fullpath, slen, "%s/%s", basedir, lf->lf_fname); + } else if (incdir != NULL) { + slen = strlen(compdir) + strlen(incdir) + + strlen(lf->lf_fname) + 3; + if ((lf->lf_fullpath = malloc(slen)) == NULL) { + free(lf); + DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); + return (DW_DLE_MEMORY); + } + snprintf(lf->lf_fullpath, slen, "%s/%s/%s", compdir, + incdir, lf->lf_fname); } } Index: sys/conf/kern.post.mk =================================================================== --- sys/conf/kern.post.mk +++ sys/conf/kern.post.mk @@ -358,11 +358,6 @@ .endif .endfor -.if defined(_MAP_DEBUG_PREFIX) -# Ensure that DWARF info contains a full path for auto-generated headers. -CFLAGS+= -fdebug-prefix-map=.=${.OBJDIR} -.endif - ${_ILINKS}: @case ${.TARGET} in \ machine) \ Index: sys/conf/kmod.mk =================================================================== --- sys/conf/kmod.mk +++ sys/conf/kmod.mk @@ -302,11 +302,6 @@ .endif .endfor -.if defined(_MAP_DEBUG_PREFIX) -# Ensure that DWARF info contains a full path for auto-generated headers. -CFLAGS+= -fdebug-prefix-map=.=${.OBJDIR} -.endif - .NOPATH: ${_ILINKS} ${_ILINKS}: