@@ -42,6 +42,7 @@
/* System dependend headers */
#include <byteswap.h>
#include <endian.h>
+#include <libgen.h>
#if HAVE_DECL_MMAP
#include <sys/mman.h>
#endif
@@ -98,7 +98,7 @@ dwarf_getsrc_file (Dwarf *dbg, const char *fname, int lineno, int column,
/* Match the name with the name the user provided. */
const char *fname2 = line->files->info[lastfile].name;
if (is_basename)
- lastmatch = strcmp (basename (fname2), fname) == 0;
+ lastmatch = strcmp (basename ((char *)fname2), fname) == 0;
else
lastmatch = strcmp (fname2, fname) == 0;
}
@@ -103,7 +103,7 @@ dwfl_module_getsrc_file (Dwfl_Module *mod,
{
/* Match the name with the name the user provided. */
lastfile = file;
- lastmatch = !strcmp (is_basename ? basename (file) : file,
+ lastmatch = !strcmp (is_basename ? basename ((char *)file) : file,
fname);
}
}
@@ -736,7 +736,7 @@ dwfl_segment_report_module (Dwfl *dwfl, int ndx, const char *name,
bias += fixup;
if (module->name[0] != '\0')
{
- name = basename (module->name);
+ name = basename ((char *)module->name);
name_is_final = true;
}
break;
@@ -164,7 +164,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name,
{
bool cancheck = debuglink_crc != (GElf_Word) 0;
- const char *file_basename = file_name == NULL ? NULL : basename (file_name);
+ const char *file_basename = file_name == NULL ? NULL : basename ((char *)file_name);
char *localname = NULL;
/* We invent a debuglink .debug name if NULL, but then want to try the
@@ -278,7 +278,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name,
else
{
subdir = NULL;
- file = basename (debuglink_file);
+ file = basename ((char *)debuglink_file);
}
try_file_basename = debuglink_null;
break;
@@ -306,7 +306,7 @@ find_debuginfo_in_path (Dwfl_Module *mod, const char *file_name,
if (mod->dw != NULL && (p[0] == '\0' || p[0] == '/'))
{
fd = try_open (&main_stat, dir, ".dwz",
- basename (file), &fname);
+ basename ((char *)file), &fname);
if (fd < 0)
{
if (errno != ENOENT && errno != ENOTDIR)
@@ -469,7 +469,7 @@ report_r_debug (uint_fast8_t elfclass, uint_fast8_t elfdata,
if (r_debug_info_module == NULL)
{
// XXX hook for sysroot
- mod = __libdwfl_report_elf (dwfl, basename (name),
+ mod = __libdwfl_report_elf (dwfl, basename ((char *)name),
name, fd, elf, base,
true, true);
if (mod != NULL)
@@ -381,7 +381,7 @@ print_dwarf_function (Dwfl_Module *mod, Dwarf_Addr addr)
if (file == NULL)
file = "???";
else if (only_basenames)
- file = basename (file);
+ file = basename ((char *)file);
else if (use_comp_dir && file[0] != '/')
{
const char *const *dirs;
@@ -564,7 +564,7 @@ print_src (const char *src, int lineno, int linecol, Dwarf_Die *cu)
const char *comp_dir_sep = "";
if (only_basenames)
- src = basename (src);
+ src = basename ((char *)src);
else if (use_comp_dir && src[0] != '/')
{
Dwarf_Attribute attr;
@@ -1417,7 +1417,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr,
int lineno;
(void) dwarf_lineno (line, &lineno);
const char *file = dwarf_linesrc (line, NULL, NULL);
- file = (file != NULL) ? basename (file) : "???";
+ file = (file != NULL) ? basename ((char *)file) : "???";
int n;
n = obstack_printf (&whereob, "%s:%d%c", file,
lineno, '\0');
@@ -1448,7 +1448,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr,
{
/* We found the line. */
int n = obstack_printf (&whereob, "%s:%" PRIu64 "%c",
- basename ((*found)->file),
+ basename ((char *)(*found)->file),
(*found)->lineno,
'\0');
sym_mem[nentries_used].where = obstack_finish (&whereob);
@@ -152,7 +152,7 @@ module_callback (Dwfl_Module *mod, void **userdata __attribute__((unused)),
int width = get_addr_width (mod);
printf ("0x%0*" PRIx64 "-0x%0*" PRIx64 " %s\n",
- width, start, width, end, basename (name));
+ width, start, width, end, basename ((char *)name));
const unsigned char *id;
GElf_Addr id_vaddr;
@@ -1800,7 +1800,7 @@ handle_elf (int fd, Elf *elf, const char *prefix, const char *fname,
elf_errmsg (-1));
}
- char *debug_basename = basename (debug_fname_embed ?: debug_fname);
+ char *debug_basename = basename ((char *)(debug_fname_embed ?: debug_fname));
off_t crc_offset = strlen (debug_basename) + 1;
/* Align to 4 byte boundary */
crc_offset = ((crc_offset - 1) & ~3) + 4;