aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.h
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-06-25 09:40:45 +0000
committerAlan Modra <amodra@gmail.com>2002-06-25 09:40:45 +0000
commitd4c88bbbc997676cbf6ab62282438ea7df2b4dd7 (patch)
treeab4a8e6f5415e6c214c5be2283530e87ef8dc957 /bfd/elflink.h
parentb0ac09d2fbf4259f7fb5f71f2e3ff23c1cc1d22c (diff)
downloadgdb-d4c88bbbc997676cbf6ab62282438ea7df2b4dd7.zip
gdb-d4c88bbbc997676cbf6ab62282438ea7df2b4dd7.tar.gz
gdb-d4c88bbbc997676cbf6ab62282438ea7df2b4dd7.tar.bz2
* elf64-ppc.c (ppc_add_stub): Replace strcpy/strncpy with memcpy.
* elf32-hppa.c (hppa_add_stub): Likewise. * elflink.c (_bfd_elf_link_record_dynamic_symbol): Likewise. * elflink.h (elf_add_default_symbol): Fix comment typo. (elf_add_default_symbol): Replace strcpy and strncpy with memcpy. (elf_link_add_object_symbols): Likewise. (elf_link_assign_sym_version): Likewise. * hash.c (bfd_hash_lookup): Likewise. * linker.c (_bfd_generic_link_add_one_symbol): Likewise. * section.c (bfd_get_unique_section_name): Likewise. * syms.c (_bfd_stab_section_find_nearest_line): Likewise. * elf.c (_bfd_elf_make_section_from_phdr): Likewise. (assign_section_numbers): Likewise. (_bfd_elfcore_make_pseudosection): Likewise. (elfcore_grok_lwpstatus): Likewise. (elfcore_grok_win32pstatus): Likewise. (elfcore_write_note): Constify input params. Use PTR instead of void *. Include terminating NUL in namesz. Correct padding. Support NULL "name" param. Use memcpy instead of strcpy. (elfcore_write_prpsinfo): Constify input params. (elfcore_write_prstatus): Likewise. Use PTR instead of void *. (elfcore_write_lwpstatus): Likewise. (elfcore_write_pstatus): Likewise. (elfcore_write_prfpreg): Likewise. (elfcore_write_prxfpreg): Likewise. * elf-bfd.h (elfcore_write_note): Update declaration. (elfcore_write_prpsinfo): Likewise. (elfcore_write_prstatus): Likewise. (elfcore_write_pstatus): Likewise. (elfcore_write_prfpreg): Likewise. (elfcore_write_prxfpreg): Likewise. (elfcore_write_lwpstatus): Likewise.
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r--bfd/elflink.h50
1 files changed, 28 insertions, 22 deletions
diff --git a/bfd/elflink.h b/bfd/elflink.h
index d78e31f..293e20a 100644
--- a/bfd/elflink.h
+++ b/bfd/elflink.h
@@ -960,6 +960,7 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value,
boolean collect;
boolean dynamic;
char *p;
+ size_t len, shortlen;
/* If this symbol has a version, and it is the default version, we
create an indirect symbol from the default name to the fully
@@ -972,7 +973,7 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value,
if (override)
{
/* We are overridden by an old defition. We need to check if we
- need to crreate the indirect symbol from the default name. */
+ need to create the indirect symbol from the default name. */
hi = elf_link_hash_lookup (elf_hash_table (info), name, true,
false, false);
BFD_ASSERT (hi != NULL);
@@ -991,12 +992,12 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value,
collect = bed->collect;
dynamic = (abfd->flags & DYNAMIC) != 0;
- shortname = bfd_hash_allocate (&info->hash->table,
- (size_t) (p - name + 1));
+ shortlen = p - name;
+ shortname = bfd_hash_allocate (&info->hash->table, shortlen + 1);
if (shortname == NULL)
return false;
- strncpy (shortname, name, (size_t) (p - name));
- shortname [p - name] = '\0';
+ memcpy (shortname, name, shortlen);
+ shortname[shortlen] = '\0';
/* We are going to create a new symbol. Merge it with any existing
symbol with this name. For the purposes of the merge, act as
@@ -1101,11 +1102,12 @@ elf_add_default_symbol (abfd, info, h, name, sym, sec, value,
/* We also need to define an indirection from the nondefault version
of the symbol. */
- shortname = bfd_hash_allocate (&info->hash->table, strlen (name));
+ len = strlen (name);
+ shortname = bfd_hash_allocate (&info->hash->table, len);
if (shortname == NULL)
return false;
- strncpy (shortname, name, (size_t) (p - name));
- strcpy (shortname + (p - name), p + 1);
+ memcpy (shortname, name, shortlen);
+ memcpy (shortname + shortlen, p + 1, len - shortlen);
/* Once again, merge with any existing symbol. */
type_change_ok = false;
@@ -1493,10 +1495,11 @@ elf_link_add_object_symbols (abfd, info)
fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (n == NULL || fnm == NULL)
goto error_return;
- anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1);
+ amt = strlen (fnm) + 1;
+ anm = bfd_alloc (abfd, amt);
if (anm == NULL)
goto error_return;
- strcpy (anm, fnm);
+ memcpy (anm, fnm, (size_t) amt);
n->name = anm;
n->by = abfd;
n->next = NULL;
@@ -1524,10 +1527,11 @@ elf_link_add_object_symbols (abfd, info)
fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (n == NULL || fnm == NULL)
goto error_return;
- anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1);
+ amt = strlen (fnm) + 1;
+ anm = bfd_alloc (abfd, amt);
if (anm == NULL)
goto error_return;
- strcpy (anm, fnm);
+ memcpy (anm, fnm, (size_t) amt);
n->name = anm;
n->by = abfd;
n->next = NULL;
@@ -1551,10 +1555,11 @@ elf_link_add_object_symbols (abfd, info)
fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv);
if (n == NULL || fnm == NULL)
goto error_return;
- anm = bfd_alloc (abfd, (bfd_size_type) strlen (fnm) + 1);
+ amt = strlen (fnm) + 1;
+ anm = bfd_alloc (abfd, amt);
if (anm == NULL)
goto error_return;
- strcpy (anm, fnm);
+ memcpy (anm, fnm, (size_t) amt);
n->name = anm;
n->by = abfd;
n->next = NULL;
@@ -1798,8 +1803,7 @@ elf_link_add_object_symbols (abfd, info)
|| (vernum > 1 && ! bfd_is_abs_section (sec)))
{
const char *verstr;
- unsigned int namelen;
- bfd_size_type newlen;
+ size_t namelen, verlen, newlen;
char *newname, *p;
if (sym.st_shndx != SHN_UNDEF)
@@ -1856,14 +1860,16 @@ elf_link_add_object_symbols (abfd, info)
}
namelen = strlen (name);
- newlen = namelen + strlen (verstr) + 2;
- if ((iver.vs_vers & VERSYM_HIDDEN) == 0)
+ verlen = strlen (verstr);
+ newlen = namelen + verlen + 2;
+ if ((iver.vs_vers & VERSYM_HIDDEN) == 0
+ && sym.st_shndx != SHN_UNDEF)
++newlen;
- newname = (char *) bfd_alloc (abfd, newlen);
+ newname = (char *) bfd_alloc (abfd, (bfd_size_type) newlen);
if (newname == NULL)
goto error_return;
- strcpy (newname, name);
+ memcpy (newname, name, namelen);
p = newname + namelen;
*p++ = ELF_VER_CHR;
/* If this is a defined non-hidden version symbol,
@@ -1872,7 +1878,7 @@ elf_link_add_object_symbols (abfd, info)
if ((iver.vs_vers & VERSYM_HIDDEN) == 0
&& sym.st_shndx != SHN_UNDEF)
*p++ = ELF_VER_CHR;
- strcpy (p, verstr);
+ memcpy (p, verstr, verlen + 1);
name = newname;
}
@@ -4339,7 +4345,7 @@ elf_link_assign_sym_version (h, data)
alc = bfd_malloc ((bfd_size_type) len);
if (alc == NULL)
return false;
- strncpy (alc, h->root.root.string, len - 1);
+ memcpy (alc, h->root.root.string, len - 1);
alc[len - 1] = '\0';
if (alc[len - 2] == ELF_VER_CHR)
alc[len - 2] = '\0';