/* nto-tdep.c - general QNX Neutrino target functionality.
- Copyright (C) 2003-2004, 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2003-2013 Free Software Foundation, Inc.
Contributed by QNX Software Systems Ltd.
char *buf, *arch_path, *nto_root, *endian;
const char *base;
const char *arch;
- int ret;
+ int arch_len, len, ret;
#define PATH_FMT \
"%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
/* In case nto_root is short, add strlen(solib)
so we can reuse arch_path below. */
- arch_path =
- alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
- strlen (solib));
- sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
- buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
- sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
- arch_path);
+ arch_len = (strlen (nto_root) + strlen (arch) + strlen (endian) + 2
+ + strlen (solib));
+ arch_path = alloca (arch_len);
+ xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
+
+ len = strlen (PATH_FMT) + strlen (arch_path) * 5 + 1;
+ buf = alloca (len);
+ xsnprintf (buf, len, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
+ arch_path);
base = lbasename (solib);
- ret = openp (buf, 1, base, o_flags, temp_pathname);
+ ret = openp (buf, OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH, base, o_flags,
+ temp_pathname);
if (ret < 0 && base != solib)
{
- sprintf (arch_path, "/%s", solib);
+ xsnprintf (arch_path, arch_len, "/%s", solib);
ret = open (arch_path, o_flags, 0);
if (temp_pathname)
{
if (ret >= 0)
*temp_pathname = gdb_realpath (arch_path);
else
- **temp_pathname = '\0';
+ *temp_pathname = NULL;
}
}
return ret;
== BFD_ENDIAN_BIG ? "be" : "le";
}
- sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
+ xsnprintf (arch_path, sizeof (arch_path), "%s/%s%s", nto_root, arch, endian);
- sprintf (buf, "set solib-absolute-prefix %s", arch_path);
+ xsnprintf (buf, sizeof (buf), "set solib-absolute-prefix %s", arch_path);
execute_command (buf, 0);
}
/* Neutrino treats the l_addr base address field in link.h as different than
the base address in the System V ABI and so the offset needs to be
calculated and applied to relocations. */
- Elf_Internal_Phdr *phdr = find_load_phdr (sec->bfd);
+ Elf_Internal_Phdr *phdr = find_load_phdr (sec->the_bfd_section->owner);
unsigned vaddr = phdr ? phdr->p_vaddr : 0;
sec->addr = nto_truncate_ptr (sec->addr + lm_addr (so) - vaddr);
int
nto_in_dynsym_resolve_code (CORE_ADDR pc)
{
- if (in_plt_section (pc, NULL))
+ if (in_plt_section (pc))
return 1;
return 0;
}