aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2006-09-16 18:12:17 +0000
committerNick Clifton <nickc@redhat.com>2006-09-16 18:12:17 +0000
commit0112cd268b205d8176b8b4d00988a334822956cf (patch)
tree67d11340ff93c7dbc29c8917bc03d9d24555f43d /binutils
parent4fa3602bd53183badf1d259128a5f951f32db8cb (diff)
downloadgdb-0112cd268b205d8176b8b4d00988a334822956cf.zip
gdb-0112cd268b205d8176b8b4d00988a334822956cf.tar.gz
gdb-0112cd268b205d8176b8b4d00988a334822956cf.tar.bz2
* bfd-in.h (STRING_AND_COMMA): New macro. Takes one constant string as its
argument and emits the string followed by a comma and then the length of the string. (CONST_STRNEQ): New macro. Checks to see if a variable string has a constant string as its initial characters. (CONST_STRNCPY): New macro. Copies a constant string to the start of a variable string. * bfd-in2.h: Regenerate. * <remainign files>: Make use of the new macros.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog16
-rw-r--r--binutils/ar.c2
-rw-r--r--binutils/dlltool.c4
-rw-r--r--binutils/emul_aix.c10
-rw-r--r--binutils/nlmconv.c18
-rw-r--r--binutils/objdump.c2
-rw-r--r--binutils/prdbg.c13
-rw-r--r--binutils/readelf.c21
-rw-r--r--binutils/stabs.c14
9 files changed, 57 insertions, 43 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 90c6fe9..23f0a81 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,19 @@
+2006-09-16 Nick Clifton <nickc@redhat.com>
+ Pedro Alves <pedro_alves@portugalmail.pt>
+
+ * ar.c: Make use of new STRING_COMMA_LEN and CONST_STRNEQ
+ macros defined in bfd.h.
+ * dlltool.c: Likewise.
+ * emul_aix.c: Likewise.
+ * nlmconv.c: Likewise.
+ * objdump.c: Likewise.
+ * prdbg.c: Likewise.
+ * stabs.c: Likewise.
+ * readelf.c (const_strneq): New macro.
+ (process_section_headers, slurp_ia64_unwind_table,
+ slurp_hppa_unwind_table, display_debug_section, process_notes,
+ process_archive): Use the new macro.
+
2006-09-14 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/3181
diff --git a/binutils/ar.c b/binutils/ar.c
index 2431448..9675caf 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -430,7 +430,7 @@ main (int argc, char **argv)
usage (0);
if (strcmp (argv[1], "-V") == 0
|| strcmp (argv[1], "-v") == 0
- || strncmp (argv[1], "--v", 3) == 0)
+ || CONST_STRNEQ (argv[1], "--v"))
print_version ("ranlib");
arg_index = 1;
if (strcmp (argv[1], "-t") == 0)
diff --git a/binutils/dlltool.c b/binutils/dlltool.c
index 8cf972e..b09c94e 100644
--- a/binutils/dlltool.c
+++ b/binutils/dlltool.c
@@ -1248,7 +1248,7 @@ scan_drectve_symbols (bfd *abfd)
while (p < e)
{
if (p[0] == '-'
- && strncmp (p, "-export:", 8) == 0)
+ && CONST_STRNEQ (p, "-export:"))
{
char * name;
char * c;
@@ -1266,7 +1266,7 @@ scan_drectve_symbols (bfd *abfd)
char *tag_start = ++p;
while (p < e && *p != ' ' && *p != '-')
p++;
- if (strncmp (tag_start, "data", 4) == 0)
+ if (CONST_STRNEQ (tag_start, "data"))
flags &= ~BSF_FUNCTION;
}
diff --git a/binutils/emul_aix.c b/binutils/emul_aix.c
index 8161a86..97677bc 100644
--- a/binutils/emul_aix.c
+++ b/binutils/emul_aix.c
@@ -1,5 +1,5 @@
/* Binutils emulation layer.
- Copyright 2002, 2003 Free Software Foundation, Inc.
+ Copyright 2002, 2003, 2006 Free Software Foundation, Inc.
Written by Tom Rix, Red Hat Inc.
This file is part of GNU Binutils.
@@ -126,25 +126,25 @@ ar_emul_aix5_replace (bfd **after_bfd, char *file_name, bfd_boolean verbose)
static bfd_boolean
ar_emul_aix_parse_arg (char *arg)
{
- if (strncmp (arg, "-X32_64", 6) == 0)
+ if (CONST_STRNEQ (arg, "-X32_64"))
{
big_archive = TRUE;
X32 = TRUE;
X64 = TRUE;
}
- else if (strncmp (arg, "-X32", 3) == 0)
+ else if (CONST_STRNEQ (arg, "-X32"))
{
big_archive = TRUE;
X32 = TRUE;
X64 = FALSE;
}
- else if (strncmp (arg, "-X64", 3) == 0)
+ else if (CONST_STRNEQ (arg, "-X64"))
{
big_archive = TRUE;
X32 = FALSE;
X64 = TRUE;
}
- else if (strncmp (arg, "-g", 2) == 0)
+ else if (CONST_STRNEQ (arg, "-g"))
{
big_archive = FALSE;
X32 = TRUE;
diff --git a/binutils/nlmconv.c b/binutils/nlmconv.c
index 551e7e5..6159dc9 100644
--- a/binutils/nlmconv.c
+++ b/binutils/nlmconv.c
@@ -1,6 +1,6 @@
/* nlmconv.c -- NLM conversion program
Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -737,7 +737,7 @@ main (int argc, char **argv)
|| ! bfd_set_section_flags (outbfd, help_section,
SEC_HAS_CONTENTS))
bfd_fatal (_("help section"));
- strncpy (nlm_extended_header (outbfd)->stamp, "MeSsAgEs", 8);
+ CONST_STRNCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs");
}
}
if (message_file != NULL)
@@ -759,7 +759,7 @@ main (int argc, char **argv)
|| ! bfd_set_section_flags (outbfd, message_section,
SEC_HAS_CONTENTS))
bfd_fatal (_("message section"));
- strncpy (nlm_extended_header (outbfd)->stamp, "MeSsAgEs", 8);
+ CONST_STRNCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs");
}
}
if (modules != NULL)
@@ -795,7 +795,7 @@ main (int argc, char **argv)
|| ! bfd_set_section_flags (outbfd, rpc_section,
SEC_HAS_CONTENTS))
bfd_fatal (_("rpc section"));
- strncpy (nlm_extended_header (outbfd)->stamp, "MeSsAgEs", 8);
+ CONST_STRNCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs");
}
}
if (sharelib_file != NULL)
@@ -852,20 +852,20 @@ main (int argc, char **argv)
|| ! bfd_set_section_flags (outbfd, shared_section,
SEC_HAS_CONTENTS))
bfd_fatal (_("shared section"));
- strncpy (nlm_extended_header (outbfd)->stamp, "MeSsAgEs", 8);
+ CONST_STRNCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs");
}
}
}
/* Check whether a version was given. */
- if (strncmp (version_hdr->stamp, "VeRsIoN#", 8) != 0)
+ if (!CONST_STRNEQ (version_hdr->stamp, "VeRsIoN#"))
non_fatal (_("warning: No version number given"));
/* At least for now, always create an extended header, because that
is what NLMLINK does. */
- strncpy (nlm_extended_header (outbfd)->stamp, "MeSsAgEs", 8);
+ CONST_STRNCPY (nlm_extended_header (outbfd)->stamp, "MeSsAgEs");
- strncpy (nlm_cygnus_ext_header (outbfd)->stamp, "CyGnUsEx", 8);
+ CONST_STRNCPY (nlm_cygnus_ext_header (outbfd)->stamp, "CyGnUsEx");
/* If the date was not given, force it in. */
if (nlm_version_header (outbfd)->month == 0
@@ -880,7 +880,7 @@ main (int argc, char **argv)
nlm_version_header (outbfd)->month = ptm->tm_mon + 1;
nlm_version_header (outbfd)->day = ptm->tm_mday;
nlm_version_header (outbfd)->year = ptm->tm_year + 1900;
- strncpy (version_hdr->stamp, "VeRsIoN#", 8);
+ CONST_STRNCPY (version_hdr->stamp, "VeRsIoN#");
}
#ifdef NLMCONV_POWERPC
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 824cc33..809457e 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -2015,7 +2015,7 @@ dump_dwarf_section (bfd *abfd, asection *section,
const char *match;
enum dwarf_section_display_enum i;
- if (strncmp (name, ".gnu.linkonce.wi.", 17) == 0)
+ if (CONST_STRNEQ (name, ".gnu.linkonce.wi."))
match = ".debug_info";
else
match = name;
diff --git a/binutils/prdbg.c b/binutils/prdbg.c
index 87a4934..5b89595 100644
--- a/binutils/prdbg.c
+++ b/binutils/prdbg.c
@@ -1,5 +1,5 @@
/* prdbg.c -- Print out generic debugging information.
- Copyright 1995, 1996, 1999, 2002, 2003, 2004
+ Copyright 1995, 1996, 1999, 2002, 2003, 2004, 2006
Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@cygnus.com>.
Tags style generation written by Salvador E. Tropea <set@computer.org>.
@@ -910,11 +910,10 @@ pr_method_type (void *p, bfd_boolean domain, int argcount, bfd_boolean varargs)
domain_type = pop_type (info);
if (domain_type == NULL)
return FALSE;
- if (strncmp (domain_type, "class ", sizeof "class " - 1) == 0
+ if (CONST_STRNEQ (domain_type, "class ")
&& strchr (domain_type + sizeof "class " - 1, ' ') == NULL)
domain_type += sizeof "class " - 1;
- else if (strncmp (domain_type, "union class ",
- sizeof "union class ") == 0
+ else if (CONST_STRNEQ (domain_type, "union class ")
&& (strchr (domain_type + sizeof "union class " - 1, ' ')
== NULL))
domain_type += sizeof "union class " - 1;
@@ -1317,7 +1316,7 @@ pr_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean virtual,
if (t == NULL)
return FALSE;
- if (strncmp (t, "class ", sizeof "class " - 1) == 0)
+ if (CONST_STRNEQ (t, "class "))
t += sizeof "class " - 1;
/* Push it back on to take advantage of the prepend_type and
@@ -2158,7 +2157,7 @@ tg_class_static_member (void *p, const char *name,
if (! full_name)
return FALSE;
memcpy (full_name, info->stack->next->type, len_class);
- memcpy (full_name + len_class, "::", 2);
+ memcpy (full_name + len_class, STRING_COMMA_LEN ("::"));
memcpy (full_name + len_class + 2, name, len_var + 1);
if (! substitute_type (info, full_name))
@@ -2199,7 +2198,7 @@ tg_class_baseclass (void *p, bfd_vma bitpos ATTRIBUTE_UNUSED,
if (t == NULL)
return FALSE;
- if (strncmp (t, "class ", sizeof "class " - 1) == 0)
+ if (CONST_STRNEQ (t, "class "))
t += sizeof "class " - 1;
/* Push it back on to take advantage of the prepend_type and
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 9644256..6d0e66c 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -263,6 +263,7 @@ static void (*byte_put) (unsigned char *, bfd_vma, int);
/* This is just a bit of syntatic sugar. */
#define streq(a,b) (strcmp ((a), (b)) == 0)
#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
+#define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0)
static void *
get_data (void *var, FILE *file, long offset, size_t size, size_t nmemb,
@@ -1135,7 +1136,6 @@ dump_relocations (FILE *file,
case EM_BLACKFIN:
rtype = elf_bfin_reloc_type (type);
break;
-
}
if (rtype == NULL)
@@ -1968,7 +1968,7 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
char const *isa = _("unknown");
char const *mac = _("unknown mac");
char const *additional = NULL;
-
+
switch (e_flags & EF_M68K_ISA_MASK)
{
case EF_M68K_ISA_A_NODIV:
@@ -2049,7 +2049,6 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
case EM_CYGNUS_M32R:
if ((e_flags & EF_M32R_ARCH) == E_M32R_ARCH)
strcat (buf, ", m32r");
-
break;
case EM_MIPS:
@@ -4070,7 +4069,7 @@ process_section_headers (FILE *file)
|| do_debug_lines || do_debug_pubnames || do_debug_aranges
|| do_debug_frames || do_debug_macinfo || do_debug_str
|| do_debug_loc || do_debug_ranges)
- && strneq (name, ".debug_", 7))
+ && const_strneq (name, ".debug_"))
{
name += 7;
@@ -4090,7 +4089,7 @@ process_section_headers (FILE *file)
}
/* linkonce section to be combined with .debug_info at link time. */
else if ((do_debugging || do_debug_info)
- && strneq (name, ".gnu.linkonce.wi.", 17))
+ && const_strneq (name, ".gnu.linkonce.wi."))
request_dump (i, DEBUG_DUMP);
else if (do_debug_frames && streq (name, ".eh_frame"))
request_dump (i, DEBUG_DUMP);
@@ -4926,7 +4925,7 @@ slurp_ia64_unwind_table (FILE *file,
sym = aux->symtab + ELF64_R_SYM (rp->r_info);
}
- if (! strneq (relname, "R_IA64_SEGREL", 13))
+ if (! const_strneq (relname, "R_IA64_SEGREL"))
{
warn (_("Skipping unexpected relocation type %s\n"), relname);
continue;
@@ -5339,7 +5338,7 @@ slurp_hppa_unwind_table (FILE *file,
}
/* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */
- if (strncmp (relname, "R_PARISC_SEGREL", 15) != 0)
+ if (! const_strneq (relname, "R_PARISC_SEGREL"))
{
warn (_("Skipping unexpected relocation type %s\n"), relname);
continue;
@@ -7826,7 +7825,7 @@ display_debug_section (Elf_Internal_Shdr *section, FILE *file)
return 0;
}
- if (strneq (name, ".gnu.linkonce.wi.", 17))
+ if (const_strneq (name, ".gnu.linkonce.wi."))
name = ".debug_info";
/* See if we know how to display the contents of this section. */
@@ -8871,7 +8870,7 @@ process_note (Elf_Internal_Note *pnote)
note type strings. */
nt = get_note_type (pnote->type);
- else if (strneq (pnote->namedata, "NetBSD-CORE", 11))
+ else if (const_strneq (pnote->namedata, "NetBSD-CORE"))
/* NetBSD-specific core file notes. */
nt = get_netbsd_elfcore_note_type (pnote->type);
@@ -9319,7 +9318,7 @@ process_archive (char *file_name, FILE *file)
return 1;
}
- if (memcmp (arhdr.ar_name, "/ ", 16) == 0)
+ if (const_strneq (arhdr.ar_name, "/ "))
{
/* This is the archive symbol table. Skip it.
FIXME: We should have an option to dump it. */
@@ -9341,7 +9340,7 @@ process_archive (char *file_name, FILE *file)
}
}
- if (memcmp (arhdr.ar_name, "// ", 16) == 0)
+ if (const_strneq (arhdr.ar_name, "// "))
{
/* This is the archive string table holding long member
names. */
diff --git a/binutils/stabs.c b/binutils/stabs.c
index 879a3e2..9aca97a 100644
--- a/binutils/stabs.c
+++ b/binutils/stabs.c
@@ -1,5 +1,5 @@
/* stabs.c -- Parse stabs debugging information
- Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@cygnus.com>.
@@ -1696,12 +1696,12 @@ parse_stab_range_type (void *dhandle, struct stab_handle *info, const char *type
#define ULLHIGH "01777777777777777777777;"
if (index_type == DEBUG_TYPE_NULL)
{
- if (strncmp (s2, LLLOW, sizeof LLLOW - 1) == 0
- && strncmp (s3, LLHIGH, sizeof LLHIGH - 1) == 0)
+ if (CONST_STRNEQ (s2, LLLOW)
+ && CONST_STRNEQ (s3, LLHIGH))
return debug_make_int_type (dhandle, 8, FALSE);
if (! ov2
&& n2 == 0
- && strncmp (s3, ULLHIGH, sizeof ULLHIGH - 1) == 0)
+ && CONST_STRNEQ (s3, ULLHIGH))
return debug_make_int_type (dhandle, 8, TRUE);
}
@@ -2832,7 +2832,7 @@ parse_stab_argtypes (void *dhandle, struct stab_handle *info,
&& (ISDIGIT (argtypes[2])
|| argtypes[2] == 'Q'
|| argtypes[2] == 't'))
- || strncmp (argtypes, "__ct", 4) == 0);
+ || CONST_STRNEQ (argtypes, "__ct"));
is_constructor = (is_full_physname_constructor
|| (tagname != NULL
@@ -2840,7 +2840,7 @@ parse_stab_argtypes (void *dhandle, struct stab_handle *info,
is_destructor = ((argtypes[0] == '_'
&& (argtypes[1] == '$' || argtypes[1] == '.')
&& argtypes[2] == '_')
- || strncmp (argtypes, "__dt", 4) == 0);
+ || CONST_STRNEQ (argtypes, "__dt"));
is_v3 = argtypes[0] == '_' && argtypes[1] == 'Z';
if (is_destructor || is_full_physname_constructor || is_v3)
@@ -3841,7 +3841,7 @@ stab_demangle_function_name (struct stab_demangle_info *minfo,
*pp = scan + 2;
if (*pp - name >= 5
- && strncmp (name, "type", 4) == 0
+ && CONST_STRNEQ (name, "type")
&& (name[4] == '$' || name[4] == '.'))
{
const char *tem;