diff options
66 files changed, 618 insertions, 546 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8222b435598..fa9e137e084 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,71 @@ +2006-09-16 Nick Clifton <nickc@redhat.com> + Pedro Alves <pedro_alves@portugalmail.pt> + + * 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. + * archive.c: Make use of the new macros. + * archive64.c: Likewise. + * bfd.c: Likewise. + * coff-ppc.c: Likewise. + * coff-stgo32.c: Likewise. + * coffcode.h: Likewise. + * cofflink.c: Likewise. + * cpu-i960.c: Likewise. + * dwarf2.c: Likewise. + * ecoff.c: Likewise. + * elf-m10300.c: Likewise. + * elf.c: Likewise. + * elf32-arm.c: Likewise. + * elf32-bfin.c: Likewise. + * elf32-cris.c: Likewise. + * elf32-hppa.c: Likewise. + * elf32-i370.c: Likewise. + * elf32-i386.c: Likewise. + * elf32-iq2000.c: Likewise. + * elf32-m32r.c: Likewise. + * elf32-m68hc11.c: Likewise. + * elf32-m68hc12.c: Likewise. + * elf32-m68k.c: Likewise. + * elf32-mcore.c: Likewise. + * elf32-ppc.c: Likewise. + * elf32-s390.c: Likewise. + * elf32-sh-symbian.c: Likewise. + * elf32-sh.c: Likewise. + * elf32-sh64.c: Likewise. + * elf32-v850.c: Likewise. + * elf32-vax.c: Likewise. + * elf32-xtensa.c: Likewise. + * elf64-alpha.c: Likewise. + * elf64-hppa.c: Likewise. + * elf64-mmix.c: Likewise. + * elf64-ppc.c: Likewise. + * elf64-s390.c: Likewise. + * elf64-sh64.c: Likewise. + * elf64-x86-64.c: Likewise. + * elflink.c: Likewise. + * elfxx-ia64.c: Likewise. + * elfxx-mips.c: Likewise. + * elfxx-sparc.c: Likewise. + * hpux-core.c: Likewise. + * i386linux.c: Likewise. + * ieee.c: Likewise. + * libpei.h: Likewise. + * linker.c: Likewise. + * m68klinux.c: Likewise. + * mmo.c: Likewise. + * nlmcode.h: Likewise. + * osf-core.c: Likewise. + * pef.c: Likewise. + * som.c: Likewise. + * sparclinux.c: Likewise. + * vms-hdr.c: Likewise. + 2006-09-14 Alan Modra <amodra@bigpond.net.au> PR 3182 diff --git a/bfd/archive.c b/bfd/archive.c index 24bb048138b..947506d0002 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -912,12 +912,12 @@ bfd_slurp_armap (bfd *abfd) if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0) return FALSE; - if (!strncmp (nextname, "__.SYMDEF ", 16) - || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* old Linux archives */ + if (CONST_STRNEQ (nextname, "__.SYMDEF ") + || CONST_STRNEQ (nextname, "__.SYMDEF/ ")) /* Old Linux archives. */ return do_slurp_bsd_armap (abfd); - else if (!strncmp (nextname, "/ ", 16)) + else if (CONST_STRNEQ (nextname, "/ ")) return do_slurp_coff_armap (abfd); - else if (!strncmp (nextname, "/SYM64/ ", 16)) + else if (CONST_STRNEQ (nextname, "/SYM64/ ")) { /* 64bit ELF (Irix 6) archive. */ #ifdef BFD64 @@ -963,11 +963,11 @@ bfd_slurp_bsd_armap_f2 (bfd *abfd) if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0) return FALSE; - if (!strncmp (nextname, "__.SYMDEF ", 16) - || !strncmp (nextname, "__.SYMDEF/ ", 16)) /* Old Linux archives. */ + if (CONST_STRNEQ (nextname, "__.SYMDEF ") + || CONST_STRNEQ (nextname, "__.SYMDEF/ ")) /* Old Linux archives. */ return do_slurp_bsd_armap (abfd); - if (strncmp (nextname, "/ ", 16)) + if (! CONST_STRNEQ (nextname, "/ ")) { bfd_has_map (abfd) = FALSE; return TRUE; @@ -1063,8 +1063,8 @@ _bfd_slurp_extended_name_table (bfd *abfd) if (bfd_seek (abfd, (file_ptr) -16, SEEK_CUR) != 0) return FALSE; - if (strncmp (nextname, "ARFILENAMES/ ", 16) != 0 && - strncmp (nextname, "// ", 16) != 0) + if (! CONST_STRNEQ (nextname, "ARFILENAMES/ ") + && ! CONST_STRNEQ (nextname, "// ")) { bfd_ardata (abfd)->extended_names = NULL; bfd_ardata (abfd)->extended_names_size = 0; diff --git a/bfd/archive64.c b/bfd/archive64.c index 3b28f853c21..4fc8b851939 100644 --- a/bfd/archive64.c +++ b/bfd/archive64.c @@ -1,25 +1,25 @@ /* MIPS-specific support for 64-bit ELF - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. Ian Lance Taylor, Cygnus Support Linker support added by Mark Mitchell, CodeSourcery, LLC. <mark@codesourcery.com> -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file supports the 64-bit (MIPS) ELF archives. */ @@ -65,10 +65,10 @@ bfd_elf64_archive_slurp_armap (bfd *abfd) return FALSE; /* Archives with traditional armaps are still permitted. */ - if (strncmp (nextname, "/ ", 16) == 0) + if (CONST_STRNEQ (nextname, "/ ")) return bfd_slurp_armap (abfd); - if (strncmp (nextname, "/SYM64/ ", 16) != 0) + if (! CONST_STRNEQ (nextname, "/SYM64/ ")) { bfd_has_map (abfd) = FALSE; return TRUE; diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 6ceb0dbdac3..c11880e9537 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -43,6 +43,25 @@ extern "C" { #endif #endif +/* This is a utility macro to handle the situation where the code + wants to place a constant string into the code, followed by a + comma and then the length of the string. Doing this by hand + is error prone, so using this macro is safer. The macro will + also safely handle the case where a NULL is passed as the arg. */ +#define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0) +/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro + to create the arguments to another macro, since the preprocessor + will mis-count the number of arguments to the outer macro (by not + evaluating STRING_COMMA_LEN and so missing the comma). This is a + problem for example when trying to use STRING_COMMA_LEN to build + the arguments to the strncmp() macro. Hence this alternative + definition of strncmp is provided here. + + Note - these macros do NOT work if STR2 is not a constant string. */ +#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0) +#define CONST_STRNCPY(STR1,STR2) strncpy ((STR1), (STR2), sizeof (STR2) - 1) + + /* The word size used by BFD on the host. This may be 64 with a 32 bit target if the host is 64 bit, or if other 64 bit targets have been selected with --enable-targets, or if --enable-64-bit-bfd. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index b75c8e2510c..841cc465509 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -50,6 +50,25 @@ extern "C" { #endif #endif +/* This is a utility macro to handle the situation where the code + wants to place a constant string into the code, followed by a + comma and then the length of the string. Doing this by hand + is error prone, so using this macro is safer. The macro will + also safely handle the case where a NULL is passed as the arg. */ +#define STRING_COMMA_LEN(STR) (STR), ((STR) ? sizeof (STR) - 1 : 0) +/* Unfortunately it is not possible to use the STRING_COMMA_LEN macro + to create the arguments to another macro, since the preprocessor + will mis-count the number of arguments to the outer macro (by not + evaluating STRING_COMMA_LEN and so missing the comma). This is a + problem for example when trying to use STRING_COMMA_LEN to build + the arguments to the strncmp() macro. Hence this alternative + definition of strncmp is provided here. + + Note - these macros do NOT work if STR2 is not a constant string. */ +#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0) +#define CONST_STRNCPY(STR1,STR2) strncpy ((STR1), (STR2), sizeof (STR2) - 1) + + /* The word size used by BFD on the host. This may be 64 with a 32 bit target if the host is 64 bit, or if other 64 bit targets have been selected with --enable-targets, or if --enable-64-bit-bfd. */ diff --git a/bfd/bfd.c b/bfd/bfd.c index 13fbf93628a..7f59adb1302 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -881,7 +881,7 @@ bfd_get_sign_extend_vma (bfd *abfd) no place to store this information in the COFF back end. Should enough other COFF targets add support for DWARF2, a place will have to be found. Until then, this hack will do. */ - if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0 + if (CONST_STRNEQ (name, "coff-go32") || strcmp (name, "pe-i386") == 0 || strcmp (name, "pei-i386") == 0 || strcmp (name, "pe-arm-wince-little") == 0 diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c index b4427936933..0ef37852345 100644 --- a/bfd/coff-ppc.c +++ b/bfd/coff-ppc.c @@ -1332,7 +1332,7 @@ coff_ppc_relocate_section (output_bfd, info, input_bfd, input_section, DUMP_RELOC2 (howto->name, rel); - if (strncmp(".idata$2",input_section->name,8) == 0 && first_thunk_address == 0) + if (CONST_STRNEQ (input_section->name, ".idata$2") && first_thunk_address == 0) { /* Set magic values. */ int idata5offset; diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c index 3c5fdbb6e80..61f18f0c1f3 100644 --- a/bfd/coff-stgo32.c +++ b/bfd/coff-stgo32.c @@ -1,5 +1,5 @@ /* BFD back-end for Intel 386 COFF files (DJGPP variant with a stub). - Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc. Written by Robert Hoehne. This file is part of BFD, the Binary File Descriptor library. @@ -354,7 +354,7 @@ create_go32_stub (abfd) close (f); goto stub_end; } - if (memcmp (magic, "go32stub", 8) != 0) + if (! CONST_STRNEQ (magic, "go32stub")) { close (f); goto stub_end; diff --git a/bfd/coffcode.h b/bfd/coffcode.h index fa0a206a5ef..0c7f897453b 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -427,7 +427,7 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) styp_flags = STYP_LIT; #endif /* _LIT */ } - else if (!strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1)) + else if (CONST_STRNEQ (sec_name, DOT_DEBUG)) { /* Handle the XCOFF debug section and DWARF2 debug sections. */ if (!sec_name[6]) @@ -435,12 +435,12 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) else styp_flags = STYP_DEBUG_INFO; } - else if (!strncmp (sec_name, ".stab", 5)) + else if (CONST_STRNEQ (sec_name, ".stab")) { styp_flags = STYP_DEBUG_INFO; } #ifdef COFF_LONG_SECTION_NAMES - else if (!strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1)) + else if (CONST_STRNEQ (sec_name, GNU_LINKONCE_WI)) { styp_flags = STYP_DEBUG_INFO; } @@ -529,8 +529,8 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) but there are more IMAGE_SCN_* flags. */ /* FIXME: There is no gas syntax to specify the debug section flag. */ - if (strncmp (sec_name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0 - || strncmp (sec_name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0) + if (CONST_STRNEQ (sec_name, DOT_DEBUG) + || CONST_STRNEQ (sec_name, GNU_LINKONCE_WI)) sec_flags = SEC_DEBUGGING; /* skip LOAD */ @@ -674,14 +674,14 @@ styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED, #endif sec_flags |= SEC_ALLOC; } - else if (strncmp (name, DOT_DEBUG, sizeof (DOT_DEBUG) - 1) == 0 + else if (CONST_STRNEQ (name, DOT_DEBUG) #ifdef _COMMENT || strcmp (name, _COMMENT) == 0 #endif #ifdef COFF_LONG_SECTION_NAMES - || strncmp (name, GNU_LINKONCE_WI, sizeof (GNU_LINKONCE_WI) - 1) == 0 + || CONST_STRNEQ (name, GNU_LINKONCE_WI) #endif - || strncmp (name, ".stab", 5) == 0) + || CONST_STRNEQ (name, ".stab")) { #ifdef COFF_PAGE_SIZE sec_flags |= SEC_DEBUGGING; @@ -715,7 +715,7 @@ styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED, The symbols will be defined as weak, so that multiple definitions are permitted. The GNU linker extension is to actually discard all but one of the sections. */ - if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0) + if (CONST_STRNEQ (name, ".gnu.linkonce")) sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; #endif @@ -1071,7 +1071,7 @@ styp_to_sec_flags (bfd *abfd, /* The MS PE spec sets the DISCARDABLE flag on .reloc sections but we do not want them to be labelled as debug section, since then strip would remove them. */ - if (strncmp (name, ".reloc", sizeof ".reloc" - 1) != 0) + if (! CONST_STRNEQ (name, ".reloc")) sec_flags |= SEC_DEBUGGING; break; case IMAGE_SCN_MEM_SHARED: @@ -1126,7 +1126,7 @@ styp_to_sec_flags (bfd *abfd, The symbols will be defined as weak, so that multiple definitions are permitted. The GNU linker extension is to actually discard all but one of the sections. */ - if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0) + if (CONST_STRNEQ (name, ".gnu.linkonce")) sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; #endif diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 40f5a700929..6e15a025931 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -232,7 +232,7 @@ coff_link_check_ar_symbols (bfd *abfd, /* Auto import. */ if (!h && info->pei386_auto_import - && !strncmp (name,"__imp_", 6)) + && CONST_STRNEQ (name, "__imp_")) h = bfd_link_hash_lookup (info->hash, name + 6, FALSE, FALSE, TRUE); /* We are only interested in symbols that are currently @@ -439,7 +439,7 @@ coff_link_add_symbols (bfd *abfd, || classification == COFF_SYMBOL_PE_SECTION) && coff_section_data (abfd, section) != NULL && coff_section_data (abfd, section)->comdat != NULL - && strncmp (name, "??_", 3) == 0 + && CONST_STRNEQ (name, "??_") && strcmp (name, coff_section_data (abfd, section)->comdat->name) == 0) { if (*sym_hash == NULL) @@ -583,7 +583,7 @@ coff_link_add_symbols (bfd *abfd, asection *stab; for (stab = abfd->sections; stab; stab = stab->next) - if (strncmp (".stab", stab->name, 5) == 0 + if (CONST_STRNEQ (".stab", stab->name) && (!stab->name[5] || (stab->name[5] == '.' && ISDIGIT (stab->name[6])))) { @@ -1232,7 +1232,7 @@ process_embedded_commands (bfd *output_bfd, s++; continue; } - if (strncmp (s, "-attr", 5) == 0) + if (CONST_STRNEQ (s, "-attr")) { char *name; char *attribs; @@ -1272,11 +1272,11 @@ process_embedded_commands (bfd *output_bfd, asec->flags |= SEC_READONLY; } } - else if (strncmp (s,"-heap", 5) == 0) - s = dores_com (s+5, output_bfd, 1); + else if (CONST_STRNEQ (s, "-heap")) + s = dores_com (s + 5, output_bfd, 1); - else if (strncmp (s,"-stack", 6) == 0) - s = dores_com (s+6, output_bfd, 0); + else if (CONST_STRNEQ (s, "-stack")) + s = dores_com (s + 6, output_bfd, 0); else s++; diff --git a/bfd/cpu-i960.c b/bfd/cpu-i960.c index 7a9be7ca640..e7ccd46894d 100644 --- a/bfd/cpu-i960.c +++ b/bfd/cpu-i960.c @@ -1,23 +1,23 @@ /* BFD library support routines for the i960 architecture. - Copyright 1990, 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002 + Copyright 1990, 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc. Hacked by Steve Chamberlain of Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bfd.h" #include "sysdep.h" @@ -57,7 +57,7 @@ scan_960_mach (ap, string) } /* In some bfds the cpu-id is written as "80960KA", "80960KB", "80960CA" or "80960MC". */ - else if (strncmp ("80960", string, 5) == 0) + else if (CONST_STRNEQ (string, "80960")) { string += 5; diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index b55f2faec47..b0571143590 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -2181,7 +2181,7 @@ find_debug_info (bfd *abfd, asection *after_sec) if (strcmp (msec->name, DWARF2_DEBUG_INFO) == 0) return msec; - if (strncmp (msec->name, GNU_LINKONCE_INFO, strlen (GNU_LINKONCE_INFO)) == 0) + if (CONST_STRNEQ (msec->name, GNU_LINKONCE_INFO)) return msec; msec = msec->next; diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 386227b1ccf..eef59dc0f14 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -2861,7 +2861,7 @@ _bfd_ecoff_slurp_armap (bfd *abfd) bfd_slurp_armap, but that seems inappropriate since no other target uses this format. Instead, we check directly for a COFF armap. */ - if (strneq (nextname, "/ ", 16)) + if (CONST_STRNEQ (nextname, "/ ")) return bfd_slurp_armap (abfd); /* See if the first element is an armap. */ diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index a8f4836e709..351d01c7318 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -2,21 +2,21 @@ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bfd.h" #include "sysdep.h" @@ -886,7 +886,7 @@ mn10300_elf_check_relocs (abfd, info, sec, relocs) if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -1036,7 +1036,7 @@ mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); @@ -4310,7 +4310,7 @@ _bfd_mn10300_elf_size_dynamic_sections (output_bfd, info) /* Remember whether there is a PLT. */ plt = s->size != 0; } - else if (strncmp (name, ".rela", 5) == 0) + else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -4343,7 +4343,7 @@ _bfd_mn10300_elf_size_dynamic_sections (output_bfd, info) s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0 + else if (! CONST_STRNEQ (name, ".got") && strcmp (name, ".dynbss") != 0) /* It's not one of our sections, so don't allocate space. */ continue; diff --git a/bfd/elf.c b/bfd/elf.c index ce8f4bccb5f..83bfcef8430 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -816,22 +816,22 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, int len; } debug_sections [] = { - { "debug", 5 }, /* 'd' */ + { STRING_COMMA_LEN ("debug") }, /* 'd' */ { NULL, 0 }, /* 'e' */ { NULL, 0 }, /* 'f' */ - { "gnu.linkonce.wi.", 16 }, /* 'g' */ + { STRING_COMMA_LEN ("gnu.linkonce.wi.") }, /* 'g' */ { NULL, 0 }, /* 'h' */ { NULL, 0 }, /* 'i' */ { NULL, 0 }, /* 'j' */ { NULL, 0 }, /* 'k' */ - { "line", 4 }, /* 'l' */ + { STRING_COMMA_LEN ("line") }, /* 'l' */ { NULL, 0 }, /* 'm' */ { NULL, 0 }, /* 'n' */ { NULL, 0 }, /* 'o' */ { NULL, 0 }, /* 'p' */ { NULL, 0 }, /* 'q' */ { NULL, 0 }, /* 'r' */ - { "stab", 4 } /* 's' */ + { STRING_COMMA_LEN ("stab") } /* 's' */ }; if (name [0] == '.') @@ -852,7 +852,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd, The symbols will be defined as weak, so that multiple definitions are permitted. The GNU linker extension is to actually discard all but one of the sections. */ - if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0 + if (CONST_STRNEQ (name, ".gnu.linkonce") && elf_next_in_group (newsect) == NULL) flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; @@ -2281,109 +2281,109 @@ bfd_section_from_elf_index (bfd *abfd, unsigned int index) static const struct bfd_elf_special_section special_sections_b[] = { - { ".bss", 4, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".bss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_c[] = { - { ".comment", 8, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".comment"), 0, SHT_PROGBITS, 0 }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_d[] = { - { ".data", 5, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".data1", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".debug", 6, 0, SHT_PROGBITS, 0 }, - { ".debug_line", 11, 0, SHT_PROGBITS, 0 }, - { ".debug_info", 11, 0, SHT_PROGBITS, 0 }, - { ".debug_abbrev", 13, 0, SHT_PROGBITS, 0 }, - { ".debug_aranges", 14, 0, SHT_PROGBITS, 0 }, - { ".dynamic", 8, 0, SHT_DYNAMIC, SHF_ALLOC }, - { ".dynstr", 7, 0, SHT_STRTAB, SHF_ALLOC }, - { ".dynsym", 7, 0, SHT_DYNSYM, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".data"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".data1"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".debug"), 0, SHT_PROGBITS, 0 }, + { STRING_COMMA_LEN (".debug_line"), 0, SHT_PROGBITS, 0 }, + { STRING_COMMA_LEN (".debug_info"), 0, SHT_PROGBITS, 0 }, + { STRING_COMMA_LEN (".debug_abbrev"), 0, SHT_PROGBITS, 0 }, + { STRING_COMMA_LEN (".debug_aranges"), 0, SHT_PROGBITS, 0 }, + { STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC, SHF_ALLOC }, + { STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB, SHF_ALLOC }, + { STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_f[] = { - { ".fini", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { ".fini_array", 11, 0, SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_g[] = { - { ".gnu.linkonce.b",15, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { ".got", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".gnu.version", 12, 0, SHT_GNU_versym, 0 }, - { ".gnu.version_d", 14, 0, SHT_GNU_verdef, 0 }, - { ".gnu.version_r", 14, 0, SHT_GNU_verneed, 0 }, - { ".gnu.liblist", 12, 0, SHT_GNU_LIBLIST, SHF_ALLOC }, - { ".gnu.conflict", 13, 0, SHT_RELA, SHF_ALLOC }, - { ".gnu.hash", 9, 0, SHT_GNU_HASH, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".gnu.version"), 0, SHT_GNU_versym, 0 }, + { STRING_COMMA_LEN (".gnu.version_d"), 0, SHT_GNU_verdef, 0 }, + { STRING_COMMA_LEN (".gnu.version_r"), 0, SHT_GNU_verneed, 0 }, + { STRING_COMMA_LEN (".gnu.liblist"), 0, SHT_GNU_LIBLIST, SHF_ALLOC }, + { STRING_COMMA_LEN (".gnu.conflict"), 0, SHT_RELA, SHF_ALLOC }, + { STRING_COMMA_LEN (".gnu.hash"), 0, SHT_GNU_HASH, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_h[] = { - { ".hash", 5, 0, SHT_HASH, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".hash"), 0, SHT_HASH, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_i[] = { - { ".init", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { ".init_array", 11, 0, SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE }, - { ".interp", 7, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".interp"), 0, SHT_PROGBITS, 0 }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_l[] = { - { ".line", 5, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".line"), 0, SHT_PROGBITS, 0 }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_n[] = { - { ".note.GNU-stack",15, 0, SHT_PROGBITS, 0 }, - { ".note", 5, -1, SHT_NOTE, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".note.GNU-stack"), 0, SHT_PROGBITS, 0 }, + { STRING_COMMA_LEN (".note"), -1, SHT_NOTE, 0 }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_p[] = { - { ".preinit_array", 14, 0, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE }, - { ".plt", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_r[] = { - { ".rodata", 7, -2, SHT_PROGBITS, SHF_ALLOC }, - { ".rodata1", 8, 0, SHT_PROGBITS, SHF_ALLOC }, - { ".rela", 5, -1, SHT_RELA, 0 }, - { ".rel", 4, -1, SHT_REL, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".rodata"), -2, SHT_PROGBITS, SHF_ALLOC }, + { STRING_COMMA_LEN (".rodata1"), 0, SHT_PROGBITS, SHF_ALLOC }, + { STRING_COMMA_LEN (".rela"), -1, SHT_RELA, 0 }, + { STRING_COMMA_LEN (".rel"), -1, SHT_REL, 0 }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_s[] = { - { ".shstrtab", 9, 0, SHT_STRTAB, 0 }, - { ".strtab", 7, 0, SHT_STRTAB, 0 }, - { ".symtab", 7, 0, SHT_SYMTAB, 0 }, - { ".stabstr", 5, 3, SHT_STRTAB, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".shstrtab"), 0, SHT_STRTAB, 0 }, + { STRING_COMMA_LEN (".strtab"), 0, SHT_STRTAB, 0 }, + { STRING_COMMA_LEN (".symtab"), 0, SHT_SYMTAB, 0 }, + { STRING_COMMA_LEN (".stabstr"), 3, SHT_STRTAB, 0 }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section special_sections_t[] = { - { ".text", 5, -2, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { ".tbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS }, - { ".tdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".text"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".tbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS }, + { STRING_COMMA_LEN (".tdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_TLS }, + { NULL, 0, 0, 0, 0 } }; static const struct bfd_elf_special_section *special_sections[] = @@ -3238,7 +3238,7 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info) string section. We look for a section with the same name but without the trailing ``str'', and set its sh_link field to point to this section. */ - if (strncmp (sec->name, ".stab", sizeof ".stab" - 1) == 0 + if (CONST_STRNEQ (sec->name, ".stab") && strcmp (sec->name + strlen (sec->name) - 3, "str") == 0) { size_t len; @@ -3646,7 +3646,7 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info) for (s = abfd->sections; s != NULL; s = s->next) { if ((s->flags & SEC_LOAD) != 0 - && strncmp (s->name, ".note", 5) == 0) + && CONST_STRNEQ (s->name, ".note")) { /* We need a PT_NOTE segment. */ ++segs; @@ -4028,7 +4028,7 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) for (s = abfd->sections; s != NULL; s = s->next) { if ((s->flags & SEC_LOAD) != 0 - && strncmp (s->name, ".note", 5) == 0) + && CONST_STRNEQ (s->name, ".note")) { amt = sizeof (struct elf_segment_map); m = bfd_zalloc (abfd, amt); @@ -8291,12 +8291,12 @@ elfcore_read_notes (bfd *abfd, file_ptr offset, bfd_size_type size) in.descdata = in.namedata + BFD_ALIGN (in.namesz, 4); in.descpos = offset + (in.descdata - buf); - if (strncmp (in.namedata, "NetBSD-CORE", 11) == 0) + if (CONST_STRNEQ (in.namedata, "NetBSD-CORE")) { if (! elfcore_grok_netbsd_note (abfd, &in)) goto error; } - else if (strncmp (in.namedata, "QNX", 3) == 0) + else if (CONST_STRNEQ (in.namedata, "QNX")) { if (! elfcore_grok_nto_note (abfd, &in)) goto error; @@ -8675,10 +8675,8 @@ bfd_elf_match_symbols_in_sections (asection *sec1, asection *sec2) /* If both are .gnu.linkonce sections, they have to have the same section name. */ - if (strncmp (sec1->name, ".gnu.linkonce", - sizeof ".gnu.linkonce" - 1) == 0 - && strncmp (sec2->name, ".gnu.linkonce", - sizeof ".gnu.linkonce" - 1) == 0) + if (CONST_STRNEQ (sec1->name, ".gnu.linkonce") + && CONST_STRNEQ (sec2->name, ".gnu.linkonce")) return strcmp (sec1->name + sizeof ".gnu.linkonce", sec2->name + sizeof ".gnu.linkonce") == 0; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 8db3c8cb2fd..f46b6ae58bc 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2221,9 +2221,9 @@ reloc_section_p (struct elf32_arm_link_hash_table *htab, const char *name, asection *s) { if (htab->use_rel) - return strncmp (name, ".rel", 4) == 0 && strcmp (s->name, name + 4) == 0; + return CONST_STRNEQ (name, ".rel") && strcmp (s->name, name + 4) == 0; else - return strncmp (name, ".rela", 5) == 0 && strcmp (s->name, name + 5) == 0; + return CONST_STRNEQ (name, ".rela") && strcmp (s->name, name + 5) == 0; } /* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up @@ -7938,7 +7938,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, /* Remember whether there is a PLT. */ plt = s->size != 0; } - else if (strncmp (name, ".rel", 4) == 0) + else if (CONST_STRNEQ (name, ".rel")) { if (s->size != 0) { @@ -7952,7 +7952,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0 + else if (! CONST_STRNEQ (name, ".got") && strcmp (name, ".dynbss") != 0) { /* It's not one of our sections, so don't allocate space. */ @@ -8680,12 +8680,8 @@ elf32_arm_final_write_processing (bfd *abfd, bfd_boolean linker ATTRIBUTE_UNUSED static bfd_boolean is_arm_elf_unwind_section_name (bfd * abfd ATTRIBUTE_UNUSED, const char * name) { - size_t len1, len2; - - len1 = sizeof (ELF_STRING_ARM_unwind) - 1; - len2 = sizeof (ELF_STRING_ARM_unwind_once) - 1; - return (strncmp (name, ELF_STRING_ARM_unwind, len1) == 0 - || strncmp (name, ELF_STRING_ARM_unwind_once, len2) == 0); + return (CONST_STRNEQ (name, ELF_STRING_ARM_unwind) + || CONST_STRNEQ (name, ELF_STRING_ARM_unwind_once)); } @@ -9656,18 +9652,18 @@ elf32_arm_symbian_special_sections[] = the loadable read-only segment. The post-linker may wish to refer to these sections, but they are not part of the final program image. */ - { ".dynamic", 8, 0, SHT_DYNAMIC, 0 }, - { ".dynstr", 7, 0, SHT_STRTAB, 0 }, - { ".dynsym", 7, 0, SHT_DYNSYM, 0 }, - { ".got", 4, 0, SHT_PROGBITS, 0 }, - { ".hash", 5, 0, SHT_HASH, 0 }, + { STRING_COMMA_LEN (".dynamic"), 0, SHT_DYNAMIC, 0 }, + { STRING_COMMA_LEN (".dynstr"), 0, SHT_STRTAB, 0 }, + { STRING_COMMA_LEN (".dynsym"), 0, SHT_DYNSYM, 0 }, + { STRING_COMMA_LEN (".got"), 0, SHT_PROGBITS, 0 }, + { STRING_COMMA_LEN (".hash"), 0, SHT_HASH, 0 }, /* These sections do not need to be writable as the SymbianOS postlinker will arrange things so that no dynamic relocation is required. */ - { ".init_array", 11, 0, SHT_INIT_ARRAY, SHF_ALLOC }, - { ".fini_array", 11, 0, SHT_FINI_ARRAY, SHF_ALLOC }, - { ".preinit_array", 14, 0, SHT_PREINIT_ARRAY, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".init_array"), 0, SHT_INIT_ARRAY, SHF_ALLOC }, + { STRING_COMMA_LEN (".fini_array"), 0, SHT_FINI_ARRAY, SHF_ALLOC }, + { STRING_COMMA_LEN (".preinit_array"), 0, SHT_PREINIT_ARRAY, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; static void diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index 54900d05c75..6ceaeb0e089 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -5292,7 +5292,7 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, strip = FALSE; - if (strncmp (name, ".rela", 5) == 0) + if (CONST_STRNEQ (name, ".rela")) { if (s->size == 0) { @@ -5316,7 +5316,7 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0) + else if (! CONST_STRNEQ (name, ".got")) { /* It's not one of our sections, so don't allocate space. */ continue; diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 4019e34e26b..121b85d814d 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -1388,7 +1388,7 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); @@ -2799,7 +2799,7 @@ cris_elf_check_relocs (abfd, info, sec, relocs) if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -2962,7 +2962,7 @@ elf_cris_size_dynamic_sections (output_bfd, info) /* Remember whether there is a PLT. */ plt = s->size != 0; } - else if (strncmp (name, ".rela", 5) == 0) + else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -2976,7 +2976,7 @@ elf_cris_size_dynamic_sections (output_bfd, info) s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0 + else if (! CONST_STRNEQ (name, ".got") && strcmp (name, ".dynbss") != 0) { /* It's not one of our sections, so don't allocate space. */ diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 10a1183ea05..07a448c6f40 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -2442,7 +2442,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, else if (sec == htab->sgot || sec == htab->sdynbss) ; - else if (strncmp (bfd_get_section_name (dynobj, sec), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, sec), ".rela")) { if (sec->size != 0) { diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 6a013f8165f..3c7c37239aa 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -655,7 +655,7 @@ i370_elf_size_dynamic_sections (bfd *output_bfd, /* Remember whether there is a PLT. */ plt = s->size != 0; } - else if (strncmp (name, ".rela", 5) == 0) + else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -867,7 +867,7 @@ i370_elf_check_relocs (bfd *abfd, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); sreloc = bfd_get_section_by_name (dynobj, name); @@ -1236,7 +1236,7 @@ i370_elf_relocate_section (bfd *output_bfd, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 7fb142289ac..88f4de78ede 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1177,7 +1177,7 @@ elf_i386_check_relocs (bfd *abfd, if (name == NULL) return FALSE; - if (strncmp (name, ".rel", 4) != 0 + if (! CONST_STRNEQ (name, ".rel") || strcmp (bfd_get_section_name (abfd, sec), name + 4) != 0) { @@ -2029,7 +2029,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (htab->elf.hplt != NULL) strip_section = FALSE; } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rel", 4) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rel")) { if (s->size != 0 && s != htab->srelplt && s != htab->srelplt2) relocs = TRUE; diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c index 146dcaaecaf..f51ca07af22 100644 --- a/bfd/elf32-iq2000.c +++ b/bfd/elf32-iq2000.c @@ -1,5 +1,5 @@ /* IQ2000-specific support for 32-bit ELF. - Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -452,9 +452,9 @@ iq2000_elf_check_relocs (bfd *abfd, case R_IQ2000_32: /* For debug section, change to special harvard-aware relocations. */ - if (memcmp (sec->name, ".debug", 6) == 0 - || memcmp (sec->name, ".stab", 5) == 0 - || memcmp (sec->name, ".eh_frame", 9) == 0) + if (CONST_STRNEQ (sec->name, ".debug") + || CONST_STRNEQ (sec->name, ".stab") + || CONST_STRNEQ (sec->name, ".eh_frame")) { ((Elf_Internal_Rela *) rel)->r_info = ELF32_R_INFO (ELF32_R_SYM (rel->r_info), R_IQ2000_32_DEBUG); diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 6c42c2f5b60..7f4acac1c02 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -2309,7 +2309,7 @@ m32r_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { if (s->size != 0 && s != htab->srelplt) relocs = TRUE; @@ -2933,7 +2933,7 @@ m32r_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); @@ -3990,7 +3990,7 @@ m32r_elf_check_relocs (bfd *abfd, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -4082,9 +4082,9 @@ m32r_elf_check_relocs (bfd *abfd, static const struct bfd_elf_special_section m32r_elf_special_sections[] = { - { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, 0, 0, 0 } }; static bfd_boolean diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c index d61590ff486..68e55893d63 100644 --- a/bfd/elf32-m68hc11.c +++ b/bfd/elf32-m68hc11.c @@ -1,5 +1,5 @@ /* Motorola 68HC11-specific support for 32-bit ELF - Copyright 1999, 2000, 2001, 2002, 2003, 2004 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. Contributed by Stephane Carrez (stcarrez@nerim.fr) (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com)) @@ -1259,11 +1259,11 @@ m68hc11_elf_relax_delete_bytes (bfd *abfd, asection *sec, vectors. */ static const struct bfd_elf_special_section elf32_m68hc11_special_sections[] = { - { ".eeprom", 7, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".page0", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".softregs", 9, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { ".vectors", 8, 0, SHT_PROGBITS, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".eeprom"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".page0"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".softregs"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".vectors"), 0, SHT_PROGBITS, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; #define ELF_ARCH bfd_arch_m68hc11 diff --git a/bfd/elf32-m68hc12.c b/bfd/elf32-m68hc12.c index b52f3fff853..b98615708f2 100644 --- a/bfd/elf32-m68hc12.c +++ b/bfd/elf32-m68hc12.c @@ -1,5 +1,5 @@ /* Motorola 68HC12-specific support for 32-bit ELF - Copyright 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright 1999, 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. Contributed by Stephane Carrez (stcarrez@nerim.fr) (Heavily copied from the D10V port by Martin Hunt (hunt@cygnus.com)) @@ -537,11 +537,11 @@ m68hc12_elf_set_mach_from_flags (bfd *abfd) vectors. */ static const struct bfd_elf_special_section elf32_m68hc12_special_sections[] = { - { ".eeprom", 7, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".page0", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".softregs", 9, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { ".vectors", 8, 0, SHT_PROGBITS, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".eeprom"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".page0"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".softregs"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".vectors"), 0, SHT_PROGBITS, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; #define ELF_ARCH bfd_arch_m68hc12 diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index e8bb275f6fa..0cab8d93c7c 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -864,7 +864,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -1402,7 +1402,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info) /* Remember whether there is a PLT. */ plt = s->size != 0; } - else if (strncmp (name, ".rela", 5) == 0) + else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -1413,7 +1413,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info) s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0 + else if (! CONST_STRNEQ (name, ".got") && strcmp (name, ".dynbss") != 0) { /* It's not one of our sections, so don't allocate space. */ diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index ed0123d553b..e978cdc0051 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -1,5 +1,5 @@ /* Motorola MCore specific support for 32-bit ELF - Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -637,9 +637,9 @@ mcore_elf_check_relocs (bfd * abfd, static const struct bfd_elf_special_section mcore_elf_special_sections[]= { - { ".ctors", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".dtors", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".ctors"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".dtors"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, 0, 0, 0 } }; #define TARGET_BIG_SYM bfd_elf32_mcore_big_vec diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 6e80a1e29c2..98dc93fcdde 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1896,21 +1896,21 @@ ppc_elf_additional_program_headers (bfd *abfd, static const struct bfd_elf_special_section ppc_elf_special_sections[] = { - { ".plt", 4, 0, SHT_NOBITS, SHF_ALLOC + SHF_EXECINSTR }, - { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { ".sbss2", 6, -2, SHT_PROGBITS, SHF_ALLOC }, - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".sdata2", 7, -2, SHT_PROGBITS, SHF_ALLOC }, - { ".tags", 5, 0, SHT_ORDERED, SHF_ALLOC }, - { ".PPC.EMB.apuinfo", 16, 0, SHT_NOTE, 0 }, - { ".PPC.EMB.sbss0", 14, 0, SHT_PROGBITS, SHF_ALLOC }, - { ".PPC.EMB.sdata0", 15, 0, SHT_PROGBITS, SHF_ALLOC }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".plt"), 0, SHT_NOBITS, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".sbss2"), -2, SHT_PROGBITS, SHF_ALLOC }, + { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".sdata2"), -2, SHT_PROGBITS, SHF_ALLOC }, + { STRING_COMMA_LEN (".tags"), 0, SHT_ORDERED, SHF_ALLOC }, + { STRING_COMMA_LEN (".PPC.EMB.apuinfo"), 0, SHT_NOTE, 0 }, + { STRING_COMMA_LEN (".PPC.EMB.sbss0"), 0, SHT_PROGBITS, SHF_ALLOC }, + { STRING_COMMA_LEN (".PPC.EMB.sdata0"), 0, SHT_PROGBITS, SHF_ALLOC }, + { NULL, 0, 0, 0, 0 } }; /* This is what we want for new plt/got. */ static struct bfd_elf_special_section ppc_alt_plt = - { ".plt", 4, 0, SHT_PROGBITS, SHF_ALLOC }; + { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC }; static const struct bfd_elf_special_section * ppc_elf_get_sec_type_attr (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) @@ -3436,7 +3436,7 @@ ppc_elf_check_relocs (bfd *abfd, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -4864,7 +4864,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, { /* Strip these too. */ } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { if (s->size != 0) { @@ -6242,7 +6242,7 @@ ppc_elf_relocate_section (bfd *output_bfd, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); @@ -6445,9 +6445,9 @@ ppc_elf_relocate_section (bfd *output_bfd, BFD_ASSERT (sec != NULL); name = bfd_get_section_name (abfd, sec->output_section); - if (! ((strncmp (name, ".sdata", 6) == 0 + if (! ((CONST_STRNEQ (name, ".sdata") && (name[6] == 0 || name[6] == '.')) - || (strncmp (name, ".sbss", 5) == 0 + || (CONST_STRNEQ (name, ".sbss") && (name[5] == 0 || name[5] == '.')))) { (*_bfd_error_handler) @@ -6473,8 +6473,8 @@ ppc_elf_relocate_section (bfd *output_bfd, BFD_ASSERT (sec != NULL); name = bfd_get_section_name (abfd, sec->output_section); - if (! (strncmp (name, ".sdata2", 7) == 0 - || strncmp (name, ".sbss2", 6) == 0)) + if (! (CONST_STRNEQ (name, ".sdata2") + || CONST_STRNEQ (name, ".sbss2"))) { (*_bfd_error_handler) (_("%B: the target (%s) of a %s relocation is " @@ -6505,9 +6505,9 @@ ppc_elf_relocate_section (bfd *output_bfd, BFD_ASSERT (sec != NULL); name = bfd_get_section_name (abfd, sec->output_section); - if (((strncmp (name, ".sdata", 6) == 0 + if (((CONST_STRNEQ (name, ".sdata") && (name[6] == 0 || name[6] == '.')) - || (strncmp (name, ".sbss", 5) == 0 + || (CONST_STRNEQ (name, ".sbss") && (name[5] == 0 || name[5] == '.')))) { reg = 13; @@ -6517,8 +6517,8 @@ ppc_elf_relocate_section (bfd *output_bfd, + sh->root.u.def.section->output_section->vma); } - else if (strncmp (name, ".sdata2", 7) == 0 - || strncmp (name, ".sbss2", 6) == 0) + else if (CONST_STRNEQ (name, ".sdata2") + || CONST_STRNEQ (name, ".sbss2")) { reg = 2; sh = htab->sdata[1].sym; diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index e2934cff573..7b3c2d3ade6 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1273,7 +1273,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) if (name == NULL) return FALSE; - if (strncmp (name, ".rela", 5) != 0 + if (! CONST_STRNEQ (name, ".rela") || strcmp (bfd_get_section_name (abfd, sec), name + 5) != 0) { @@ -2126,7 +2126,7 @@ elf_s390_size_dynamic_sections (output_bfd, info) /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { if (s->size != 0) relocs = TRUE; diff --git a/bfd/elf32-sh-symbian.c b/bfd/elf32-sh-symbian.c index 9ca0564c36c..7ea9207009f 100644 --- a/bfd/elf32-sh-symbian.c +++ b/bfd/elf32-sh-symbian.c @@ -1,5 +1,5 @@ /* Renesas / SuperH specific support for Symbian 32-bit ELF files - Copyright 2004, 2005 + Copyright 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Red Hat @@ -225,7 +225,7 @@ sh_symbian_process_embedded_commands (struct bfd_link_info *info, bfd * abfd, break; case 'I': - if (strncmp (s, DIRECTIVE_IMPORT, strlen (DIRECTIVE_IMPORT))) + if (! CONST_STRNEQ (s, DIRECTIVE_IMPORT)) result = FALSE; else { @@ -261,9 +261,9 @@ sh_symbian_process_embedded_commands (struct bfd_link_info *info, bfd * abfd, name_end_char = * new_name_end; * new_name_end = 0; - /* Check to see if 'AS '... is present. If se we have an IMPORT AS - directive, otherwise we have an IMPORT directive. */ - if (strncmp (s, DIRECTIVE_AS, strlen (DIRECTIVE_AS))) + /* Check to see if 'AS '... is present. If so we have an + IMPORT AS directive, otherwise we have an IMPORT directive. */ + if (! CONST_STRNEQ (s, DIRECTIVE_AS)) { /* Skip the new-line at the end of the name. */ if (SYMBIAN_DEBUG && name_end_char != '\n') @@ -327,7 +327,7 @@ sh_symbian_process_embedded_commands (struct bfd_link_info *info, bfd * abfd, break; case 'E': - if (strncmp (s, DIRECTIVE_EXPORT, strlen (DIRECTIVE_EXPORT))) + if (! CONST_STRNEQ (s, DIRECTIVE_EXPORT)) result = FALSE; else { diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index a4109016017..19ee8b636e5 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -3042,7 +3042,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { if (s->size != 0 && s != htab->srelplt && s != htab->srelplt2) relocs = TRUE; @@ -3585,7 +3585,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); @@ -4311,7 +4311,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); @@ -5200,7 +5200,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c index 55aa25b7de9..03d5e3e9df1 100644 --- a/bfd/elf32-sh64.c +++ b/bfd/elf32-sh64.c @@ -759,8 +759,8 @@ sh64_elf_merge_symbol_attribute (struct elf_link_hash_entry *h, static const struct bfd_elf_special_section sh64_elf_special_sections[] = { - { ".cranges", 8, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".cranges"), 0, SHT_PROGBITS, 0 }, + { NULL, 0, 0, 0, 0 } }; #undef TARGET_BIG_SYM diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index e3f1240bf58..1b288e41380 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -3028,33 +3028,32 @@ v850_elf_relax_section (bfd *abfd, static const struct bfd_elf_special_section v850_elf_special_sections[] = { - { ".call_table_data", 16, 0, SHT_PROGBITS, (SHF_ALLOC - + SHF_WRITE) }, - { ".call_table_text", 16, 0, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE - + SHF_EXECINSTR) }, - { ".rosdata", 8, -2, SHT_PROGBITS, (SHF_ALLOC - + SHF_V850_GPREL) }, - { ".rozdata", 8, -2, SHT_PROGBITS, (SHF_ALLOC - + SHF_V850_R0REL) }, - { ".sbss", 5, -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_GPREL) }, - { ".scommon", 8, -2, SHT_V850_SCOMMON, (SHF_ALLOC + SHF_WRITE - + SHF_V850_GPREL) }, - { ".sdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_GPREL) }, - { ".tbss", 5, -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_EPREL) }, - { ".tcommon", 8, -2, SHT_V850_TCOMMON, (SHF_ALLOC + SHF_WRITE - + SHF_V850_R0REL) }, - { ".tdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_EPREL) }, - { ".zbss", 5, -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_R0REL) }, - { ".zcommon", 8, -2, SHT_V850_ZCOMMON, (SHF_ALLOC + SHF_WRITE - + SHF_V850_R0REL) }, - { ".zdata", 6, -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE - + SHF_V850_R0REL) }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".call_table_data"), 0, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE) }, + { STRING_COMMA_LEN (".call_table_text"), 0, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + + SHF_EXECINSTR) }, + { STRING_COMMA_LEN (".rosdata"), -2, SHT_PROGBITS, (SHF_ALLOC + + SHF_V850_GPREL) }, + { STRING_COMMA_LEN (".rozdata"), -2, SHT_PROGBITS, (SHF_ALLOC + + SHF_V850_R0REL) }, + { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_GPREL) }, + { STRING_COMMA_LEN (".scommon"), -2, SHT_V850_SCOMMON, (SHF_ALLOC + SHF_WRITE + + SHF_V850_GPREL) }, + { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_GPREL) }, + { STRING_COMMA_LEN (".tbss"), -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_EPREL) }, + { STRING_COMMA_LEN (".tcommon"), -2, SHT_V850_TCOMMON, (SHF_ALLOC + SHF_WRITE + + SHF_V850_R0REL) }, + { STRING_COMMA_LEN (".tdata"), -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_EPREL) }, + { STRING_COMMA_LEN (".zbss"), -2, SHT_NOBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_R0REL) }, + { STRING_COMMA_LEN (".zcommon"), -2, SHT_V850_ZCOMMON, (SHF_ALLOC + SHF_WRITE + + SHF_V850_R0REL) }, + { STRING_COMMA_LEN (".zdata"), -2, SHT_PROGBITS, (SHF_ALLOC + SHF_WRITE + + SHF_V850_R0REL) }, + { NULL, 0, 0, 0, 0 } }; #define TARGET_LITTLE_SYM bfd_elf32_v850_vec diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index bf481e459e7..62735a69f43 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -738,7 +738,7 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -1194,7 +1194,7 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) /* Remember whether there is a PLT. */ plt = s->size != 0; } - else if (strncmp (name, ".rela", 5) == 0) + else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -1226,7 +1226,7 @@ elf_vax_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0 + else if (! CONST_STRNEQ (name, ".got") && strcmp (name, ".dynbss") != 0) { /* It's not one of our sections, so don't allocate space. */ @@ -1646,7 +1646,7 @@ elf_vax_relocate_section (bfd *output_bfd, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 88365ddd32a..12af7c30e7e 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -1409,7 +1409,7 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, of the dynobj section names depend upon the input files. */ name = bfd_get_section_name (dynobj, s); - if (strncmp (name, ".rela", 5) == 0) + if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -1423,8 +1423,8 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, s->reloc_count = 0; } } - else if (strncmp (name, ".plt.", 5) != 0 - && strncmp (name, ".got.plt.", 9) != 0 + else if (! CONST_STRNEQ (name, ".plt.") + && ! CONST_STRNEQ (name, ".got.plt.") && strcmp (name, ".got") != 0 && strcmp (name, ".plt") != 0 && strcmp (name, ".got.plt") != 0 @@ -8854,10 +8854,8 @@ relax_property_section (bfd *abfd, } is_full_prop_section = - ((strncmp (sec->name, XTENSA_PROP_SEC_NAME, - sizeof (XTENSA_PROP_SEC_NAME) - 1) == 0) - || (strncmp (sec->name, ".gnu.linkonce.prop.", - sizeof ".gnu.linkonce.prop." - 1) == 0)); + ( CONST_STRNEQ (sec->name, XTENSA_PROP_SEC_NAME) + || CONST_STRNEQ (sec->name, ".gnu.linkonce.prop.")); if (internal_relocs) { @@ -9518,23 +9516,19 @@ pcrel_reloc_fits (xtensa_opcode opc, static int linkonce_len = sizeof (".gnu.linkonce.") - 1; -static int insn_sec_len = sizeof (XTENSA_INSN_SEC_NAME) - 1; -static int lit_sec_len = sizeof (XTENSA_LIT_SEC_NAME) - 1; -static int prop_sec_len = sizeof (XTENSA_PROP_SEC_NAME) - 1; - static bfd_boolean xtensa_is_property_section (asection *sec) { - if (strncmp (XTENSA_INSN_SEC_NAME, sec->name, insn_sec_len) == 0 - || strncmp (XTENSA_LIT_SEC_NAME, sec->name, lit_sec_len) == 0 - || strncmp (XTENSA_PROP_SEC_NAME, sec->name, prop_sec_len) == 0) + if (CONST_STRNEQ (sec->name, XTENSA_INSN_SEC_NAME) + || CONST_STRNEQ (sec->name, XTENSA_LIT_SEC_NAME) + || CONST_STRNEQ (sec->name, XTENSA_PROP_SEC_NAME)) return TRUE; if (strncmp (".gnu.linkonce.", sec->name, linkonce_len) == 0 - && (strncmp (&sec->name[linkonce_len], "x.", 2) == 0 - || strncmp (&sec->name[linkonce_len], "p.", 2) == 0 - || strncmp (&sec->name[linkonce_len], "prop.", 5) == 0)) + && (CONST_STRNEQ (&sec->name[linkonce_len], "x.") + || CONST_STRNEQ (&sec->name[linkonce_len], "p.") + || CONST_STRNEQ (&sec->name[linkonce_len], "prop."))) return TRUE; return FALSE; @@ -9544,7 +9538,7 @@ xtensa_is_property_section (asection *sec) static bfd_boolean xtensa_is_littable_section (asection *sec) { - if (strncmp (XTENSA_LIT_SEC_NAME, sec->name, lit_sec_len) == 0) + if (CONST_STRNEQ (sec->name, XTENSA_LIT_SEC_NAME)) return TRUE; if (strncmp (".gnu.linkonce.", sec->name, linkonce_len) == 0 @@ -9646,7 +9640,7 @@ xtensa_get_property_section (asection *sec, const char *base_name) suffix = sec->name + linkonce_len; /* For backward compatibility, replace "t." instead of inserting the new linkonce_kind (but not for "prop" sections). */ - if (strncmp (suffix, "t.", 2) == 0 && linkonce_kind[1] == '.') + if (CONST_STRNEQ (suffix, "t.") && linkonce_kind[1] == '.') suffix += 2; strcat (prop_sec_name + linkonce_len, suffix); } @@ -9680,10 +9674,8 @@ xtensa_get_property_section (asection *sec, const char *base_name) flagword xtensa_get_property_predef_flags (asection *sec) { - if (strncmp (sec->name, XTENSA_INSN_SEC_NAME, - sizeof (XTENSA_INSN_SEC_NAME) - 1) == 0 - || strncmp (sec->name, ".gnu.linkonce.x.", - sizeof ".gnu.linkonce.x." - 1) == 0) + if (CONST_STRNEQ (sec->name, XTENSA_INSN_SEC_NAME) + || CONST_STRNEQ (sec->name, ".gnu.linkonce.x.")) return (XTENSA_PROP_INSN | XTENSA_PROP_INSN_NO_TRANSFORM | XTENSA_PROP_INSN_NO_REORDER); @@ -9717,7 +9709,7 @@ xtensa_callback_required_dependence (bfd *abfd, /* ".plt*" sections have no explicit relocations but they contain L32R instructions that reference the corresponding ".got.plt*" sections. */ if ((sec->flags & SEC_LINKER_CREATED) != 0 - && strncmp (sec->name, ".plt", 4) == 0) + && CONST_STRNEQ (sec->name, ".plt")) { asection *sgotplt; @@ -9794,10 +9786,10 @@ xtensa_callback_required_dependence (bfd *abfd, module loader so that the literals are not placed after the text. */ static const struct bfd_elf_special_section elf_xtensa_special_sections[] = { - { ".fini.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { ".init.literal", 13, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { ".literal", 8, 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".fini.literal"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".init.literal"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { STRING_COMMA_LEN (".literal"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR }, + { NULL, 0, 0, 0, 0 } }; #ifndef ELF_ARCH diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 0823f5c3eca..f37a3174d31 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -1901,7 +1901,7 @@ elf64_alpha_check_relocs (bfd *abfd, struct bfd_link_info *info, if (rel_sec_name == NULL) return FALSE; - BFD_ASSERT (strncmp (rel_sec_name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (rel_sec_name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), rel_sec_name+5) == 0); } @@ -2761,7 +2761,7 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, of the dynobj section names depend upon the input files. */ name = bfd_get_section_name (dynobj, s); - if (strncmp (name, ".rela", 5) == 0) + if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -2773,7 +2773,7 @@ elf64_alpha_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0 + else if (! CONST_STRNEQ (name, ".got") && strcmp (name, ".plt") != 0 && strcmp (name, ".dynbss") != 0) { @@ -5148,9 +5148,9 @@ elf64_alpha_reloc_type_class (const Elf_Internal_Rela *rela) static const struct bfd_elf_special_section elf64_alpha_special_sections[] = { - { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, + { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_ALPHA_GPREL }, + { NULL, 0, 0, 0, 0 } }; /* ECOFF swapping routines. These are used when dealing with the diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 7fcc94f6b3e..4ff7e6adf50 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -517,12 +517,12 @@ get_reloc_section (abfd, hppa_info, sec) if (srel_name == NULL) return FALSE; - BFD_ASSERT ((strncmp (srel_name, ".rela", 5) == 0 + BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), - srel_name+5) == 0) - || (strncmp (srel_name, ".rel", 4) == 0 + srel_name + 5) == 0) + || (CONST_STRNEQ (srel_name, ".rel") && strcmp (bfd_get_section_name (abfd, sec), - srel_name+4) == 0)); + srel_name + 4) == 0)); dynobj = hppa_info->root.dynobj; if (!dynobj) @@ -1713,13 +1713,13 @@ elf64_hppa_size_dynamic_sections (output_bfd, info) plt = s->size != 0; } else if (strcmp (name, ".opd") == 0 - || strncmp (name, ".dlt", 4) == 0 + || CONST_STRNEQ (name, ".dlt") || strcmp (name, ".stub") == 0 || strcmp (name, ".got") == 0) { /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (name, ".rela", 5) == 0) + else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -2752,14 +2752,14 @@ elf64_hppa_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int index, static const struct bfd_elf_special_section elf64_hppa_special_sections[] = { - { ".fini", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".init", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".plt", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, - { ".dlt", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, - { ".sdata", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, - { ".sbss", 5, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, - { ".tbss", 5, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_HP_TLS }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".fini"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".init"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".plt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, + { STRING_COMMA_LEN (".dlt"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, + { STRING_COMMA_LEN (".sdata"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, + { STRING_COMMA_LEN (".sbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, + { STRING_COMMA_LEN (".tbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_HP_TLS }, + { NULL, 0, 0, 0, 0 } }; /* The hash bucket size is the standard one, namely 4. */ diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index d8dfc56c078..881ba38b034 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -2193,8 +2193,7 @@ mmix_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) (*secp)->flags |= SEC_LINKER_CREATED; } else if ((*namep)[0] == '_' && (*namep)[1] == '_' && (*namep)[2] == '.' - && strncmp (*namep, MMIX_LOC_SECTION_START_SYMBOL_PREFIX, - strlen (MMIX_LOC_SECTION_START_SYMBOL_PREFIX)) == 0) + && CONST_STRNEQ (*namep, MMIX_LOC_SECTION_START_SYMBOL_PREFIX)) { /* See if we have another one. */ struct bfd_link_hash_entry *h = bfd_link_hash_lookup (info->hash, diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 4fd6bf76319..6917623b027 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -2520,13 +2520,13 @@ ppc64_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) static const struct bfd_elf_special_section ppc64_elf_special_sections[]= { - { ".plt", 4, 0, SHT_NOBITS, 0 }, - { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".toc", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".toc1", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, - { ".tocbss", 7, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".plt"), 0, SHT_NOBITS, 0 }, + { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".toc"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".toc1"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE }, + { STRING_COMMA_LEN (".tocbss"), 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE }, + { NULL, 0, 0, 0, 0 } }; struct _ppc64_elf_section_data @@ -4575,7 +4575,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, || h == &htab->tls_get_addr_fd->elf) sec->has_tls_reloc = 1; else if (htab->tls_get_addr == NULL - && !strncmp (h->root.root.string, ".__tls_get_addr", 15) + && CONST_STRNEQ (h->root.root.string, ".__tls_get_addr") && (h->root.root.string[15] == 0 || h->root.root.string[15] == '@')) { @@ -4583,7 +4583,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, sec->has_tls_reloc = 1; } else if (htab->tls_get_addr_fd == NULL - && !strncmp (h->root.root.string, "__tls_get_addr", 14) + && CONST_STRNEQ (h->root.root.string, "__tls_get_addr") && (h->root.root.string[14] == 0 || h->root.root.string[14] == '@')) { @@ -4776,7 +4776,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (name == NULL) return FALSE; - if (strncmp (name, ".rela", 5) != 0 + if (! CONST_STRNEQ (name, ".rela") || strcmp (bfd_get_section_name (abfd, sec), name + 5) != 0) { @@ -7913,7 +7913,7 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { if (s->size != 0) { diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 72d8432f75a..05be62fb26f 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1238,7 +1238,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) if (name == NULL) return FALSE; - if (strncmp (name, ".rela", 5) != 0 + if (! CONST_STRNEQ (name, ".rela") || strcmp (bfd_get_section_name (abfd, sec), name + 5) != 0) { @@ -2098,7 +2098,7 @@ elf_s390_size_dynamic_sections (output_bfd, info) /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { if (s->size != 0 && s != htab->srelplt) relocs = TRUE; diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index 4d6d8d5645f..d972fc68bc3 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -1709,7 +1709,7 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (input_bfd, input_section), name + 5) == 0); @@ -2731,7 +2731,7 @@ sh_elf64_check_relocs (bfd *abfd, struct bfd_link_info *info, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -3591,7 +3591,7 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd, /* Remember whether there is a PLT. */ plt = s->size != 0; } - else if (strncmp (name, ".rela", 5) == 0) + else if (CONST_STRNEQ (name, ".rela")) { if (s->size != 0) { @@ -3624,7 +3624,7 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd, s->reloc_count = 0; } } - else if (strncmp (name, ".got", 4) != 0 + else if (! CONST_STRNEQ (name, ".got") && strcmp (name, ".dynbss") != 0) { /* It's not one of our sections, so don't allocate space. */ @@ -4070,8 +4070,8 @@ sh64_elf64_merge_symbol_attribute (struct elf_link_hash_entry *h, static const struct bfd_elf_special_section sh64_elf64_special_sections[]= { - { ".cranges", 8, 0, SHT_PROGBITS, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".cranges"), 0, SHT_PROGBITS, 0 }, + { NULL, 0, 0, 0, 0 } }; #define TARGET_BIG_SYM bfd_elf64_sh64_vec diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index d84b82ea39c..c2cf6a43f9d 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1025,7 +1025,7 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (name == NULL) return FALSE; - if (strncmp (name, ".rela", 5) != 0 + if (! CONST_STRNEQ (name, ".rela") || strcmp (bfd_get_section_name (abfd, sec), name + 5) != 0) { @@ -1883,7 +1883,7 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0) + else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) { if (s->size != 0 && s != htab->srelplt) relocs = TRUE; @@ -3636,13 +3636,13 @@ elf64_x86_64_hash_symbol (struct elf_link_hash_entry *h) static const struct bfd_elf_special_section elf64_x86_64_special_sections[]= { - { ".gnu.linkonce.lb", 16, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_X86_64_LARGE}, - { ".gnu.linkonce.lr", 16, -2, SHT_PROGBITS, SHF_ALLOC + SHF_X86_64_LARGE}, - { ".gnu.linkonce.lt", 16, -2, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR + SHF_X86_64_LARGE}, - { ".lbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_X86_64_LARGE}, - { ".ldata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_X86_64_LARGE}, - { ".lrodata", 8, -2, SHT_PROGBITS, SHF_ALLOC + SHF_X86_64_LARGE}, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".gnu.linkonce.lb"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_X86_64_LARGE}, + { STRING_COMMA_LEN (".gnu.linkonce.lr"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_X86_64_LARGE}, + { STRING_COMMA_LEN (".gnu.linkonce.lt"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_EXECINSTR + SHF_X86_64_LARGE}, + { STRING_COMMA_LEN (".lbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_X86_64_LARGE}, + { STRING_COMMA_LEN (".ldata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_X86_64_LARGE}, + { STRING_COMMA_LEN (".lrodata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_X86_64_LARGE}, + { NULL, 0, 0, 0, 0 } }; #define TARGET_LITTLE_SYM bfd_elf64_x86_64_vec diff --git a/bfd/elflink.c b/bfd/elflink.c index a1bc864a00d..9b455784948 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -3204,7 +3204,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) const char *name; name = bfd_get_section_name (abfd, s); - if (strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0) + if (CONST_STRNEQ (name, ".gnu.warning.")) { char *msg; bfd_size_type sz; @@ -4552,7 +4552,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) asection *stab; for (stab = abfd->sections; stab; stab = stab->next) - if (strncmp (".stab", stab->name, 5) == 0 + if (CONST_STRNEQ (stab->name, ".stab") && (!stab->name[5] || (stab->name[5] == '.' && ISDIGIT (stab->name[6]))) && (stab->flags & SEC_MERGE) == 0 @@ -9694,7 +9694,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) for (o = sub->sections; o != NULL; o = o->next) if (!o->gc_mark && o->gc_mark_from_eh && (o->flags & SEC_CODE) == 0) { - if (strncmp (o->name, ".gcc_except_table.", 18) == 0) + if (CONST_STRNEQ (o->name, ".gcc_except_table.")) { unsigned long len; char *fn_name; @@ -9704,7 +9704,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) fn_name = bfd_malloc (len + 6); if (fn_name == NULL) return FALSE; - memcpy (fn_name, ".text.", 6); + memcpy (fn_name, STRING_COMMA_LEN (".text.")); memcpy (fn_name + 6, o->name + 18, len); fn_text = bfd_get_section_by_name (sub, fn_name); free (fn_name); @@ -10224,7 +10224,7 @@ _bfd_elf_section_already_linked (bfd *abfd, struct bfd_section * sec) name = bfd_get_section_name (abfd, sec); - if (strncmp (name, ".gnu.linkonce.", sizeof (".gnu.linkonce.") - 1) == 0 + if (CONST_STRNEQ (name, ".gnu.linkonce.") && (p = strchr (name + sizeof (".gnu.linkonce.") - 1, '.')) != NULL) p++; else diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 2af3fb452bd..0b6f26a695c 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -1424,22 +1424,15 @@ elfNN_ia64_relax_ldxmov (contents, off) /* Return TRUE if NAME is an unwind table section name. */ static inline bfd_boolean -is_unwind_section_name (abfd, name) - bfd *abfd; - const char *name; +is_unwind_section_name (bfd *abfd, const char *name) { - size_t len1, len2, len3; - if (elfNN_ia64_hpux_vec (abfd->xvec) && !strcmp (name, ELF_STRING_ia64_unwind_hdr)) return FALSE; - len1 = sizeof (ELF_STRING_ia64_unwind) - 1; - len2 = sizeof (ELF_STRING_ia64_unwind_info) - 1; - len3 = sizeof (ELF_STRING_ia64_unwind_once) - 1; - return ((strncmp (name, ELF_STRING_ia64_unwind, len1) == 0 - && strncmp (name, ELF_STRING_ia64_unwind_info, len2) != 0) - || strncmp (name, ELF_STRING_ia64_unwind_once, len3) == 0); + return ((CONST_STRNEQ (name, ELF_STRING_ia64_unwind) + && ! CONST_STRNEQ (name, ELF_STRING_ia64_unwind_info)) + || CONST_STRNEQ (name, ELF_STRING_ia64_unwind_once)); } /* Handle an IA-64 specific section when reading an object file. This @@ -2621,10 +2614,10 @@ get_reloc_section (abfd, ia64_info, sec, create) if (srel_name == NULL) return NULL; - BFD_ASSERT ((strncmp (srel_name, ".rela", 5) == 0 + BFD_ASSERT ((CONST_STRNEQ (srel_name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), srel_name+5) == 0) - || (strncmp (srel_name, ".rel", 4) == 0 + || (CONST_STRNEQ (srel_name, ".rel") && strcmp (bfd_get_section_name (abfd, sec), srel_name+4) == 0)); @@ -3702,7 +3695,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info) if (strcmp (name, ".got.plt") == 0) strip = FALSE; - else if (strncmp (name, ".rel", 4) == 0) + else if (CONST_STRNEQ (name, ".rel")) { if (!strip) { @@ -5569,9 +5562,9 @@ elfNN_ia64_reloc_type_class (rela) static const struct bfd_elf_special_section elfNN_ia64_special_sections[] = { - { ".sbss", 5, -1, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, - { ".sdata", 6, -1, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".sbss"), -1, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, + { STRING_COMMA_LEN (".sdata"), -1, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_IA_64_SHORT }, + { NULL, 0, 0, 0, 0 } }; static bfd_boolean @@ -5598,7 +5591,7 @@ elfNN_ia64_object_p (bfd *abfd) if (elf_sec_group (sec) == NULL && ((sec->flags & (SEC_LINK_ONCE | SEC_CODE | SEC_GROUP)) == (SEC_LINK_ONCE | SEC_CODE)) - && strncmp (sec->name, ".gnu.linkonce.t.", 16) == 0) + && CONST_STRNEQ (sec->name, ".gnu.linkonce.t.")) { name = sec->name + 16; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index cdc81a229d5..d0116227c7b 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -4098,8 +4098,8 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, sec = NULL; for (o = input_bfd->sections; o != NULL; o = o->next) { - if (strncmp (bfd_get_section_name (input_bfd, o), - CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0) + if (CONST_STRNEQ (bfd_get_section_name (input_bfd, o), + CALL_FP_STUB)) { sec = h->call_fp_stub; break; @@ -4690,9 +4690,9 @@ mips_elf_stub_section_p (bfd *abfd ATTRIBUTE_UNUSED, asection *section) { const char *name = bfd_get_section_name (abfd, section); - return (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0 - || strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0 - || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0); + return (CONST_STRNEQ (name, FN_STUB) + || CONST_STRNEQ (name, CALL_STUB) + || CONST_STRNEQ (name, CALL_FP_STUB)); } /* Add room for N relocations to the .rel(a).dyn section in ABFD. */ @@ -5407,7 +5407,7 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd, return FALSE; break; case SHT_MIPS_GPTAB: - if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) != 0) + if (! CONST_STRNEQ (name, ".gptab.")) return FALSE; break; case SHT_MIPS_UCODE: @@ -5430,7 +5430,7 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd, return FALSE; break; case SHT_MIPS_CONTENT: - if (strncmp (name, ".MIPS.content", sizeof ".MIPS.content" - 1) != 0) + if (! CONST_STRNEQ (name, ".MIPS.content")) return FALSE; break; case SHT_MIPS_OPTIONS: @@ -5438,7 +5438,7 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd, return FALSE; break; case SHT_MIPS_DWARF: - if (strncmp (name, ".debug_", sizeof ".debug_" - 1) != 0) + if (! CONST_STRNEQ (name, ".debug_")) return FALSE; break; case SHT_MIPS_SYMBOL_LIB: @@ -5446,9 +5446,8 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd, return FALSE; break; case SHT_MIPS_EVENTS: - if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) != 0 - && strncmp (name, ".MIPS.post_rel", - sizeof ".MIPS.post_rel" - 1) != 0) + if (! CONST_STRNEQ (name, ".MIPS.events") + && ! CONST_STRNEQ (name, ".MIPS.post_rel")) return FALSE; break; default: @@ -5568,7 +5567,7 @@ _bfd_mips_elf_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) } else if (strcmp (name, ".conflict") == 0) hdr->sh_type = SHT_MIPS_CONFLICT; - else if (strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0) + else if (CONST_STRNEQ (name, ".gptab.")) { hdr->sh_type = SHT_MIPS_GPTAB; hdr->sh_entsize = sizeof (Elf32_External_gptab); @@ -5625,7 +5624,7 @@ _bfd_mips_elf_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) hdr->sh_type = SHT_MIPS_IFACE; hdr->sh_flags |= SHF_MIPS_NOSTRIP; } - else if (strncmp (name, ".MIPS.content", strlen (".MIPS.content")) == 0) + else if (CONST_STRNEQ (name, ".MIPS.content")) { hdr->sh_type = SHT_MIPS_CONTENT; hdr->sh_flags |= SHF_MIPS_NOSTRIP; @@ -5637,7 +5636,7 @@ _bfd_mips_elf_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) hdr->sh_entsize = 1; hdr->sh_flags |= SHF_MIPS_NOSTRIP; } - else if (strncmp (name, ".debug_", sizeof ".debug_" - 1) == 0) + else if (CONST_STRNEQ (name, ".debug_")) hdr->sh_type = SHT_MIPS_DWARF; else if (strcmp (name, ".MIPS.symlib") == 0) { @@ -5645,9 +5644,8 @@ _bfd_mips_elf_fake_sections (bfd *abfd, Elf_Internal_Shdr *hdr, asection *sec) /* The sh_link and sh_info fields are set in final_write_processing. */ } - else if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0 - || strncmp (name, ".MIPS.post_rel", - sizeof ".MIPS.post_rel" - 1) == 0) + else if (CONST_STRNEQ (name, ".MIPS.events") + || CONST_STRNEQ (name, ".MIPS.post_rel")) { hdr->sh_type = SHT_MIPS_EVENTS; hdr->sh_flags |= SHF_MIPS_NOSTRIP; @@ -6118,7 +6116,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, /* Check for the mips16 stub sections. */ name = bfd_get_section_name (abfd, sec); - if (strncmp (name, FN_STUB, sizeof FN_STUB - 1) == 0) + if (CONST_STRNEQ (name, FN_STUB)) { unsigned long r_symndx; @@ -6143,12 +6141,9 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, /* We can ignore stub sections when looking for relocs. */ if ((o->flags & SEC_RELOC) == 0 || o->reloc_count == 0 - || strncmp (bfd_get_section_name (abfd, o), FN_STUB, - sizeof FN_STUB - 1) == 0 - || strncmp (bfd_get_section_name (abfd, o), CALL_STUB, - sizeof CALL_STUB - 1) == 0 - || strncmp (bfd_get_section_name (abfd, o), CALL_FP_STUB, - sizeof CALL_FP_STUB - 1) == 0) + || CONST_STRNEQ (bfd_get_section_name (abfd, o), FN_STUB) + || CONST_STRNEQ (bfd_get_section_name (abfd, o), CALL_STUB) + || CONST_STRNEQ (bfd_get_section_name (abfd, o), CALL_FP_STUB)) continue; sec_relocs @@ -6224,8 +6219,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, mips_elf_hash_table (info)->mips16_stubs_seen = TRUE; } } - else if (strncmp (name, CALL_STUB, sizeof CALL_STUB - 1) == 0 - || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0) + else if (CONST_STRNEQ (name, CALL_STUB) + || CONST_STRNEQ (name, CALL_FP_STUB)) { unsigned long r_symndx; struct mips_elf_link_hash_entry *h; @@ -6254,7 +6249,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, /* H is the symbol this stub is for. */ - if (strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0) + if (CONST_STRNEQ (name, CALL_FP_STUB)) loc = &h->call_fp_stub; else loc = &h->call_stub; @@ -6639,12 +6634,9 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, References from a stub section do not count. */ if (h != NULL && r_type != R_MIPS16_26 - && strncmp (bfd_get_section_name (abfd, sec), FN_STUB, - sizeof FN_STUB - 1) != 0 - && strncmp (bfd_get_section_name (abfd, sec), CALL_STUB, - sizeof CALL_STUB - 1) != 0 - && strncmp (bfd_get_section_name (abfd, sec), CALL_FP_STUB, - sizeof CALL_FP_STUB - 1) != 0) + && ! CONST_STRNEQ (bfd_get_section_name (abfd, sec), FN_STUB) + && ! CONST_STRNEQ (bfd_get_section_name (abfd, sec), CALL_STUB) + && ! CONST_STRNEQ (bfd_get_section_name (abfd, sec), CALL_FP_STUB)) { struct mips_elf_link_hash_entry *mh; @@ -7292,7 +7284,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, if ((s->flags & SEC_LINKER_CREATED) == 0) continue; - if (strncmp (name, ".rel", 4) == 0) + if (CONST_STRNEQ (name, ".rel")) { if (s->size != 0) { @@ -7344,7 +7336,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, mips_elf_allocate_dynamic_relocations (dynobj, info, count); } } - else if (!htab->is_vxworks && strncmp (name, ".got", 4) == 0) + else if (!htab->is_vxworks && CONST_STRNEQ (name, ".got")) { /* _bfd_mips_elf_always_size_sections() has already done most of the work, but some symbols may have been mapped @@ -7420,16 +7412,16 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, } else if (! info->shared && ! mips_elf_hash_table (info)->use_rld_obj_head - && strncmp (name, ".rld_map", 8) == 0) + && CONST_STRNEQ (name, ".rld_map")) { /* We add a room for __rld_map. It will be filled in by the rtld to contain a pointer to the _r_debug structure. */ s->size += 4; } else if (SGI_COMPAT (output_bfd) - && strncmp (name, ".compact_rel", 12) == 0) + && CONST_STRNEQ (name, ".compact_rel")) s->size += mips_elf_hash_table (info)->compact_rel_size; - else if (strncmp (name, ".init", 5) != 0 + else if (! CONST_STRNEQ (name, ".init") && s != htab->sgotplt && s != htab->splt) { @@ -9089,7 +9081,7 @@ _bfd_mips_elf_final_write_processing (bfd *abfd, BFD_ASSERT ((*hdrpp)->bfd_section != NULL); name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section); BFD_ASSERT (name != NULL - && strncmp (name, ".gptab.", sizeof ".gptab." - 1) == 0); + && CONST_STRNEQ (name, ".gptab.")); sec = bfd_get_section_by_name (abfd, name + sizeof ".gptab" - 1); BFD_ASSERT (sec != NULL); (*hdrpp)->sh_info = elf_section_data (sec)->this_idx; @@ -9099,8 +9091,7 @@ _bfd_mips_elf_final_write_processing (bfd *abfd, BFD_ASSERT ((*hdrpp)->bfd_section != NULL); name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section); BFD_ASSERT (name != NULL - && strncmp (name, ".MIPS.content", - sizeof ".MIPS.content" - 1) == 0); + && CONST_STRNEQ (name, ".MIPS.content")); sec = bfd_get_section_by_name (abfd, name + sizeof ".MIPS.content" - 1); BFD_ASSERT (sec != NULL); @@ -9120,13 +9111,12 @@ _bfd_mips_elf_final_write_processing (bfd *abfd, BFD_ASSERT ((*hdrpp)->bfd_section != NULL); name = bfd_get_section_name (abfd, (*hdrpp)->bfd_section); BFD_ASSERT (name != NULL); - if (strncmp (name, ".MIPS.events", sizeof ".MIPS.events" - 1) == 0) + if (CONST_STRNEQ (name, ".MIPS.events")) sec = bfd_get_section_by_name (abfd, name + sizeof ".MIPS.events" - 1); else { - BFD_ASSERT (strncmp (name, ".MIPS.post_rel", - sizeof ".MIPS.post_rel" - 1) == 0); + BFD_ASSERT (CONST_STRNEQ (name, ".MIPS.post_rel")); sec = bfd_get_section_by_name (abfd, (name + sizeof ".MIPS.post_rel" - 1)); @@ -10435,7 +10425,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) mdebug_sec = o; } - if (strncmp (o->name, ".gptab.", sizeof ".gptab." - 1) == 0) + if (CONST_STRNEQ (o->name, ".gptab.")) { const char *subname; unsigned int c; @@ -11106,13 +11096,13 @@ _bfd_mips_elf_print_private_bfd_data (bfd *abfd, void *ptr) const struct bfd_elf_special_section _bfd_mips_elf_special_sections[] = { - { ".lit4", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, - { ".lit8", 5, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, - { ".mdebug", 7, 0, SHT_MIPS_DEBUG, 0 }, - { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, - { ".sdata", 6, -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, - { ".ucode", 6, 0, SHT_MIPS_UCODE, 0 }, - { NULL, 0, 0, 0, 0 } + { STRING_COMMA_LEN (".lit4"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { STRING_COMMA_LEN (".lit8"), 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { STRING_COMMA_LEN (".mdebug"), 0, SHT_MIPS_DEBUG, 0 }, + { STRING_COMMA_LEN (".sbss"), -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { STRING_COMMA_LEN (".sdata"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_MIPS_GPREL }, + { STRING_COMMA_LEN (".ucode"), 0, SHT_MIPS_UCODE, 0 }, + { NULL, 0, 0, 0, 0 } }; /* Merge non visibility st_other attributes. Ensure that the diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index 6da70a32f86..63eed174aa2 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -1430,7 +1430,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rela", 5) == 0 + BFD_ASSERT (CONST_STRNEQ (name, ".rela") && strcmp (bfd_get_section_name (abfd, sec), name + 5) == 0); @@ -2290,7 +2290,7 @@ _bfd_sparc_elf_size_dynamic_sections (bfd *output_bfd, /* Strip this section if we don't need it; see the comment below. */ } - else if (strncmp (s->name, ".rela", 5) == 0) + else if (CONST_STRNEQ (s->name, ".rela")) { if (s->size != 0) { diff --git a/bfd/hpux-core.c b/bfd/hpux-core.c index b3c070c5e29..e8a5e31b1ec 100644 --- a/bfd/hpux-core.c +++ b/bfd/hpux-core.c @@ -144,7 +144,7 @@ thread_section_p (bfd *abfd ATTRIBUTE_UNUSED, asection *sect, void *obj ATTRIBUTE_UNUSED) { - return (strncmp (sect->name, ".reg/", 5) == 0); + return CONST_STRNEQ (sect->name, ".reg/"); } /* this function builds a bfd target if the file is a corefile. diff --git a/bfd/i386linux.c b/bfd/i386linux.c index 519c40e1766..99d1c06c5be 100644 --- a/bfd/i386linux.c +++ b/bfd/i386linux.c @@ -93,8 +93,7 @@ i386linux_write_object_contents (abfd) #define GOT_REF_PREFIX "__GOT_" #endif -#define IS_GOT_SYM(name) \ - (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0) +#define IS_GOT_SYM(name) (CONST_STRNEQ (name, GOT_REF_PREFIX)) /* See if a symbol name is a reference to the procedure linkage table. */ @@ -102,8 +101,7 @@ i386linux_write_object_contents (abfd) #define PLT_REF_PREFIX "__PLT_" #endif -#define IS_PLT_SYM(name) \ - (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0) +#define IS_PLT_SYM(name) (CONST_STRNEQ (name, PLT_REF_PREFIX)) /* This string is used to generate specialized error messages. */ @@ -441,8 +439,7 @@ linux_tally_symbols (h, data) h = (struct linux_link_hash_entry *) h->root.root.u.i.link; if (h->root.root.type == bfd_link_hash_undefined - && strncmp (h->root.root.root.string, NEEDS_SHRLIB, - sizeof NEEDS_SHRLIB - 1) == 0) + && CONST_STRNEQ (h->root.root.root.string, NEEDS_SHRLIB)) { const char *name; char *p; diff --git a/bfd/ieee.c b/bfd/ieee.c index f8d4e800235..0d60ad1e19c 100644 --- a/bfd/ieee.c +++ b/bfd/ieee.c @@ -1875,8 +1875,8 @@ ieee_object_p (bfd *abfd) family[9] = '\0'; } } - else if ((strncmp (processor, "cpu32", 5) == 0) /* CPU32 and CPU32+ */ - || (strncmp (processor, "CPU32", 5) == 0)) + else if ((CONST_STRNEQ (processor, "cpu32")) /* CPU32 and CPU32+ */ + || (CONST_STRNEQ (processor, "CPU32"))) strcpy (family, "68332"); else { diff --git a/bfd/libpei.h b/bfd/libpei.h index f0f6580fe4b..b01e222ede9 100644 --- a/bfd/libpei.h +++ b/bfd/libpei.h @@ -1,5 +1,5 @@ /* Support for the generic parts of PE/PEI; common header information. - Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005 + Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Solutions. @@ -271,9 +271,9 @@ #endif /* !COFF_WITH_pep */ /* Macro: Returns true if the bfd is a PE executable as opposed to a PE object file. */ -#define bfd_pe_executable_p(abfd) \ - (strncmp ((abfd)->xvec->name, "pei-", 4) == 0 \ - || strncmp ((abfd)->xvec->name, "efi-app-", 8) == 0) +#define bfd_pe_executable_p(abfd) \ + (CONST_STRNEQ ((abfd)->xvec->name, "pei-") \ + || CONST_STRNEQ ((abfd)->xvec->name, "efi-app-")) /* These functions are architecture dependent, and are in peicode.h: coff_swap_reloc_in diff --git a/bfd/linker.c b/bfd/linker.c index 14eeae4df0c..ea14d7645d4 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -562,11 +562,11 @@ bfd_wrapped_link_hash_lookup (bfd *abfd, #undef WRAP -#undef REAL +#undef REAL #define REAL "__real_" if (*l == '_' - && strncmp (l, REAL, sizeof REAL - 1) == 0 + && CONST_STRNEQ (l, REAL) && bfd_hash_lookup (info->wrap_hash, l + sizeof REAL - 1, FALSE, FALSE) != NULL) { @@ -1659,8 +1659,7 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, s = name + 1; while (*s == '_') ++s; - if (s[0] == 'G' - && strncmp (s, CONS_PREFIX, CONS_PREFIX_LEN - 1) == 0) + if (s[0] == 'G' && CONST_STRNEQ (s, CONS_PREFIX)) { char c; diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c index 03f8eaac0f0..f2295d12204 100644 --- a/bfd/m68klinux.c +++ b/bfd/m68klinux.c @@ -94,8 +94,7 @@ m68klinux_write_object_contents (abfd) #define GOT_REF_PREFIX "__GOT_" #endif -#define IS_GOT_SYM(name) \ - (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0) +#define IS_GOT_SYM(name) (CONST_STRNEQ (name, GOT_REF_PREFIX)) /* See if a symbol name is a reference to the procedure linkage table. */ @@ -103,8 +102,7 @@ m68klinux_write_object_contents (abfd) #define PLT_REF_PREFIX "__PLT_" #endif -#define IS_PLT_SYM(name) \ - (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0) +#define IS_PLT_SYM(name) (CONST_STRNEQ (name, PLT_REF_PREFIX)) /* This string is used to generate specialized error messages. */ @@ -445,8 +443,7 @@ linux_tally_symbols (h, data) h = (struct linux_link_hash_entry *) h->root.root.u.i.link; if (h->root.root.type == bfd_link_hash_undefined - && strncmp (h->root.root.root.string, NEEDS_SHRLIB, - sizeof NEEDS_SHRLIB - 1) == 0) + && CONST_STRNEQ (h->root.root.root.string, NEEDS_SHRLIB)) { const char *name; char *p; diff --git a/bfd/mmo.c b/bfd/mmo.c index 9ee539baece..077e3a8b8a0 100644 --- a/bfd/mmo.c +++ b/bfd/mmo.c @@ -2421,10 +2421,10 @@ mmo_internal_write_section (bfd *abfd, asection *sec) bfd_set_error (bfd_error_bad_value); return FALSE; } - else if (strncmp (sec->name, MMIX_OTHER_SPEC_SECTION_PREFIX, - strlen (MMIX_OTHER_SPEC_SECTION_PREFIX)) == 0) + else if (CONST_STRNEQ (sec->name, MMIX_OTHER_SPEC_SECTION_PREFIX)) { int n = atoi (sec->name + strlen (MMIX_OTHER_SPEC_SECTION_PREFIX)); + mmo_write_tetra_raw (abfd, (LOP << 24) | (LOP_SPEC << 16) | n); return (! abfd->tdata.mmo_data->have_error && mmo_write_chunk_list (abfd, mmo_section_data (sec)->head)); diff --git a/bfd/nlmcode.h b/bfd/nlmcode.h index a7d3985c6a7..30e6f47b357 100644 --- a/bfd/nlmcode.h +++ b/bfd/nlmcode.h @@ -174,7 +174,7 @@ nlm_swap_auxiliary_headers_in (bfd *abfd) return FALSE; if (bfd_seek (abfd, position, SEEK_SET) != 0) return FALSE; - if (strncmp (tempstr, "VeRsIoN#", 8) == 0) + if (CONST_STRNEQ (tempstr, "VeRsIoN#")) { Nlm_External_Version_Header thdr; @@ -196,7 +196,7 @@ nlm_swap_auxiliary_headers_in (bfd *abfd) nlm_version_header (abfd)->day = get_word (abfd, (bfd_byte *) thdr.day); } - else if (strncmp (tempstr, "MeSsAgEs", 8) == 0) + else if (CONST_STRNEQ (tempstr, "MeSsAgEs")) { Nlm_External_Extended_Header thdr; @@ -264,7 +264,7 @@ nlm_swap_auxiliary_headers_in (bfd *abfd) nlm_extended_header (abfd)->reserved5 = get_word (abfd, (bfd_byte *) thdr.reserved5); } - else if (strncmp (tempstr, "CoPyRiGhT=", 10) == 0) + else if (CONST_STRNEQ (tempstr, "CoPyRiGhT=")) { amt = sizeof (nlm_copyright_header (abfd)->stamp); if (bfd_bread ((void *) nlm_copyright_header (abfd)->stamp, @@ -280,7 +280,7 @@ nlm_swap_auxiliary_headers_in (bfd *abfd) amt, abfd) != amt) return FALSE; } - else if (strncmp (tempstr, "CuStHeAd", 8) == 0) + else if (CONST_STRNEQ (tempstr, "CuStHeAd")) { Nlm_External_Custom_Header thdr; bfd_size_type hdrLength; @@ -345,7 +345,7 @@ nlm_swap_auxiliary_headers_in (bfd *abfd) /* If we have found a Cygnus header, process it. Otherwise, just save the associated data without trying to interpret it. */ - if (strncmp (dataStamp, "CyGnUsEx", 8) == 0) + if (CONST_STRNEQ (dataStamp, "CyGnUsEx")) { file_ptr pos; bfd_byte *contents; @@ -364,7 +364,7 @@ nlm_swap_auxiliary_headers_in (bfd *abfd) if (bfd_seek (abfd, pos, SEEK_SET) != 0) return FALSE; - memcpy (nlm_cygnus_ext_header (abfd), "CyGnUsEx", 8); + memcpy (nlm_cygnus_ext_header (abfd), STRING_COMMA_LEN ("CyGnUsEx")); nlm_cygnus_ext_header (abfd)->offset = dataOffset; nlm_cygnus_ext_header (abfd)->length = dataLength; @@ -645,7 +645,7 @@ nlm_swap_auxiliary_headers_out (bfd *abfd) { Nlm_External_Version_Header thdr; - memcpy (thdr.stamp, "VeRsIoN#", 8); + memcpy (thdr.stamp, STRING_COMMA_LEN ("VeRsIoN#")); put_word (abfd, (bfd_vma) nlm_version_header (abfd)->majorVersion, (bfd_byte *) thdr.majorVersion); put_word (abfd, (bfd_vma) nlm_version_header (abfd)->minorVersion, @@ -672,7 +672,7 @@ nlm_swap_auxiliary_headers_out (bfd *abfd) { Nlm_External_Copyright_Header thdr; - memcpy (thdr.stamp, "CoPyRiGhT=", 10); + memcpy (thdr.stamp, STRING_COMMA_LEN ("CoPyRiGhT=")); amt = sizeof (thdr.stamp); if (bfd_bwrite ((void *) thdr.stamp, amt, abfd) != amt) return FALSE; @@ -694,7 +694,7 @@ nlm_swap_auxiliary_headers_out (bfd *abfd) { Nlm_External_Extended_Header thdr; - memcpy (thdr.stamp, "MeSsAgEs", 8); + memcpy (thdr.stamp, STRING_COMMA_LEN ("MeSsAgEs")); put_word (abfd, (bfd_vma) nlm_extended_header (abfd)->languageID, (bfd_byte *) thdr.languageID); @@ -797,7 +797,7 @@ nlm_swap_auxiliary_headers_out (bfd *abfd) ds = find_nonzero (nlm_custom_header (abfd)->dataStamp, sizeof (nlm_custom_header (abfd)->dataStamp)); - memcpy (thdr.stamp, "CuStHeAd", 8); + memcpy (thdr.stamp, STRING_COMMA_LEN ("CuStHeAd")); hdrLength = (2 * NLM_TARGET_LONG_SIZE + (ds ? 8 : 0) + nlm_custom_header (abfd)->hdrLength); put_word (abfd, hdrLength, thdr.length); @@ -831,14 +831,14 @@ nlm_swap_auxiliary_headers_out (bfd *abfd) { Nlm_External_Custom_Header thdr; - memcpy (thdr.stamp, "CuStHeAd", 8); + memcpy (thdr.stamp, STRING_COMMA_LEN ("CuStHeAd")); put_word (abfd, (bfd_vma) 2 * NLM_TARGET_LONG_SIZE + 8, (bfd_byte *) thdr.length); put_word (abfd, (bfd_vma) nlm_cygnus_ext_header (abfd)->offset, (bfd_byte *) thdr.dataOffset); put_word (abfd, (bfd_vma) nlm_cygnus_ext_header (abfd)->length, (bfd_byte *) thdr.dataLength); - memcpy (thdr.dataStamp, "CyGnUsEx", 8); + memcpy (thdr.dataStamp, STRING_COMMA_LEN ("CyGnUsEx")); amt = sizeof (thdr); if (bfd_bwrite ((void *) &thdr, amt, abfd) != amt) return FALSE; diff --git a/bfd/osf-core.c b/bfd/osf-core.c index 1d3802bf82f..9bba6e78ddd 100644 --- a/bfd/osf-core.c +++ b/bfd/osf-core.c @@ -94,7 +94,7 @@ osf_core_core_file_p (abfd) if (val != sizeof core_header) return NULL; - if (strncmp (core_header.magic, "Core", 4) != 0) + if (! CONST_STRNEQ (core_header.magic, "Core")) return NULL; core_hdr (abfd) = (struct osf_core_struct *) diff --git a/bfd/pef.c b/bfd/pef.c index 63e557acaa5..23715f44c2d 100644 --- a/bfd/pef.c +++ b/bfd/pef.c @@ -209,7 +209,7 @@ bfd_pef_print_symbol (bfd *abfd, default: bfd_print_symbol_vandf (abfd, (void *) file, symbol); fprintf (file, " %-5s %s", symbol->section->name, symbol->name); - if (strncmp (symbol->name, "__traceback_", strlen ("__traceback_")) == 0) + if (CONST_STRNEQ (symbol->name, "__traceback_")) { unsigned char *buf = alloca (symbol->udata.i); size_t offset = symbol->value + 4; diff --git a/bfd/som.c b/bfd/som.c index ead05f94746..4d00d49a323 100644 --- a/bfd/som.c +++ b/bfd/som.c @@ -4374,12 +4374,12 @@ som_slurp_symbol_table (bfd *abfd) && sym->symbol.name[strlen (sym->symbol.name) - 1] == '$' && !strcmp (sym->symbol.name, sym->symbol.section->name)) sym->symbol.flags |= BSF_SECTION_SYM; - else if (!strncmp (sym->symbol.name, "L$0\002", 4)) + else if (CONST_STRNEQ (sym->symbol.name, "L$0\002")) { sym->symbol.flags |= BSF_SECTION_SYM; sym->symbol.name = sym->symbol.section->name; } - else if (!strncmp (sym->symbol.name, "L$0\001", 4)) + else if (CONST_STRNEQ (sym->symbol.name, "L$0\001")) sym->symbol.flags |= BSF_DEBUGGING; /* Note increment at bottom of loop, since we skip some symbols @@ -5653,7 +5653,7 @@ som_slurp_armap (bfd *abfd) return FALSE; /* For archives without .o files there is no symbol table. */ - if (strncmp (nextname, "/ ", 16)) + if (! CONST_STRNEQ (nextname, "/ ")) { bfd_has_map (abfd) = FALSE; return TRUE; diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c index 6b534e3a4d3..243e85028d0 100644 --- a/bfd/sparclinux.c +++ b/bfd/sparclinux.c @@ -2,22 +2,22 @@ Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, -USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, + USA. */ #define TARGET_PAGE_SIZE 4096 #define ZMAGIC_DISK_BLOCK_SIZE 1024 @@ -94,8 +94,7 @@ sparclinux_write_object_contents (abfd) #define GOT_REF_PREFIX "__GOT_" #endif -#define IS_GOT_SYM(name) \ - (strncmp (name, GOT_REF_PREFIX, sizeof GOT_REF_PREFIX - 1) == 0) +#define IS_GOT_SYM(name) (CONST_STRNEQ (name, GOT_REF_PREFIX)) /* See if a symbol name is a reference to the procedure linkage table. */ @@ -103,8 +102,7 @@ sparclinux_write_object_contents (abfd) #define PLT_REF_PREFIX "__PLT_" #endif -#define IS_PLT_SYM(name) \ - (strncmp (name, PLT_REF_PREFIX, sizeof PLT_REF_PREFIX - 1) == 0) +#define IS_PLT_SYM(name) (CONST_STRNEQ (name, PLT_REF_PREFIX)) /* This string is used to generate specialized error messages. */ @@ -428,9 +426,7 @@ linux_add_one_symbol (info, abfd, name, flags, section, value, string, This function is called via linux_link_hash_traverse. */ static bfd_boolean -linux_tally_symbols (h, data) - struct linux_link_hash_entry *h; - PTR data; +linux_tally_symbols (struct linux_link_hash_entry *h, void * data) { struct bfd_link_info *info = (struct bfd_link_info *) data; struct fixup *f, *f1; @@ -442,8 +438,7 @@ linux_tally_symbols (h, data) h = (struct linux_link_hash_entry *) h->root.root.u.i.link; if (h->root.root.type == bfd_link_hash_undefined - && strncmp (h->root.root.root.string, NEEDS_SHRLIB, - sizeof NEEDS_SHRLIB - 1) == 0) + && CONST_STRNEQ (h->root.root.root.string, NEEDS_SHRLIB)) { const char *name; char *p; diff --git a/bfd/vms-hdr.c b/bfd/vms-hdr.c index 24a0aec1a0c..67c22b300d1 100644 --- a/bfd/vms-hdr.c +++ b/bfd/vms-hdr.c @@ -1,6 +1,6 @@ /* vms-hdr.c -- BFD back-end for VMS/VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. HDR record handling functions @@ -248,7 +248,7 @@ _bfd_vms_write_hdr (bfd *abfd, int objtype) /* LMN. */ _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_LNM); - _bfd_vms_output_dump (abfd, (unsigned char *)"GAS proGIS", 10); + _bfd_vms_output_dump (abfd, (unsigned char *) STRING_COMMA_LEN ("GAS proGIS")); _bfd_vms_output_flush (abfd); /* SRC. */ @@ -260,7 +260,7 @@ _bfd_vms_write_hdr (bfd *abfd, int objtype) if (symbol->flags & BSF_FILE) { - if (strncmp ((char *)symbol->name, "<CASE:", 6) == 0) + if (CONST_STRNEQ ((char *)symbol->name, "<CASE:")) { PRIV (flag_hash_long_names) = symbol->name[6] - '0'; PRIV (flag_show_after_trunc) = symbol->name[7] - '0'; @@ -280,13 +280,13 @@ _bfd_vms_write_hdr (bfd *abfd, int objtype) } if (symnum == abfd->symcount) - _bfd_vms_output_dump (abfd, (unsigned char *)"noname", 6); + _bfd_vms_output_dump (abfd, (unsigned char *) STRING_COMMA_LEN ("noname")); _bfd_vms_output_flush (abfd); /* TTL. */ _bfd_vms_output_begin (abfd, EOBJ_S_C_EMH, EMH_S_C_TTL); - _bfd_vms_output_dump (abfd, (unsigned char *)"TTL", 3); + _bfd_vms_output_dump (abfd, (unsigned char *) STRING_COMMA_LEN ("TTL")); _bfd_vms_output_flush (abfd); /* CPR. */ diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 290b8d47a03..e87e62a760f 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,14 @@ +2006-09-16 Nick Clifton <nickc@redhat.com> + Pedro Alves <pedro_alves@portugalmail.pt> + + * arm-dis.c: Make use of new STRING_COMMA_LEN and CONST_STRNEQ + macros defined in bfd.h. + * cris-dis.c: Likewise. + * h8300-dis.c: Likewise. + * i386-dis.c: Likewise. + * ia64-gen.c: Likewise. + * mips-dis: Likewise. + 2006-09-04 Paul Brook <paul@codesourcery.com> * arm-dis.c (neon_opcode): Fix suffix on VMOVN. diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c index 45e5da7c570..d87e1eb7556 100644 --- a/opcodes/arm-dis.c +++ b/opcodes/arm-dis.c @@ -3653,7 +3653,7 @@ parse_arm_disassembler_option (char *option) if (option == NULL) return; - if (strneq (option, "reg-names-", 10)) + if (CONST_STRNEQ (option, "reg-names-")) { int i; @@ -3670,9 +3670,9 @@ parse_arm_disassembler_option (char *option) /* XXX - should break 'option' at following delimiter. */ fprintf (stderr, _("Unrecognised register name set: %s\n"), option); } - else if (strneq (option, "force-thumb", 11)) + else if (CONST_STRNEQ (option, "force-thumb")) force_thumb = 1; - else if (strneq (option, "no-force-thumb", 14)) + else if (CONST_STRNEQ (option, "no-force-thumb")) force_thumb = 0; else /* XXX - should break 'option' at following delimiter. */ diff --git a/opcodes/cris-dis.c b/opcodes/cris-dis.c index f6c63cb280d..137bed7e6d5 100644 --- a/opcodes/cris-dis.c +++ b/opcodes/cris-dis.c @@ -1,5 +1,5 @@ /* Disassembler code for CRIS. - Copyright 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Axis Communications AB, Lund, Sweden. Written by Hans-Peter Nilsson. @@ -783,7 +783,7 @@ print_with_operands (const struct cris_opcode *opcodep, better way). */ if (opcodep->name[0] == 'j') { - if (strncmp (opcodep->name, "jsr", 3) == 0) + if (CONST_STRNEQ (opcodep->name, "jsr")) /* It's "jsr" or "jsrc". */ info->insn_type = dis_jsr; else @@ -1360,16 +1360,16 @@ print_with_operands (const struct cris_opcode *opcodep, itself or in a "move.d const,rN, sub.d rN,rM"-like sequence. */ if (TRACE_CASE && case_offset_counter == 0) { - if (strncmp (opcodep->name, "sub", 3) == 0) + if (CONST_STRNEQ (opcodep->name, "sub")) case_offset = last_immediate; /* It could also be an "add", if there are negative case-values. */ - else if (strncmp (opcodep->name, "add", 3) == 0) + else if (CONST_STRNEQ (opcodep->name, "add")) /* The first case is the negated operand to the add. */ case_offset = -last_immediate; /* A bound insn will tell us the number of cases. */ - else if (strncmp (opcodep->name, "bound", 5) == 0) + else if (CONST_STRNEQ (opcodep->name, "bound")) no_of_case_offsets = last_immediate + 1; /* A jump or jsr or branch breaks the chain of insns for a diff --git a/opcodes/h8300-dis.c b/opcodes/h8300-dis.c index 769c12e37d4..d8973813a73 100644 --- a/opcodes/h8300-dis.c +++ b/opcodes/h8300-dis.c @@ -1,5 +1,5 @@ /* Disassemble h8300 instructions. - Copyright 1993, 1994, 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright 1993, 1994, 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -638,7 +638,7 @@ bfd_h8_disassemble (bfd_vma addr, disassemble_info *info, int mach) regno[1]); return qi->length; } - if (strncmp (q->name, "mova", 4) == 0) + if (CONST_STRNEQ (q->name, "mova")) { op_type *args = q->args.nib; diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 18ca5decc65..bcf30802297 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -1,6 +1,6 @@ /* Print i386 instructions for GDB, the GNU debugger. Copyright 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -2667,44 +2667,44 @@ print_insn (bfd_vma pc, disassemble_info *info) for (p = info->disassembler_options; p != NULL; ) { - if (strncmp (p, "x86-64", 6) == 0) + if (CONST_STRNEQ (p, "x86-64")) { address_mode = mode_64bit; priv.orig_sizeflag = AFLAG | DFLAG; } - else if (strncmp (p, "i386", 4) == 0) + else if (CONST_STRNEQ (p, "i386")) { address_mode = mode_32bit; priv.orig_sizeflag = AFLAG | DFLAG; } - else if (strncmp (p, "i8086", 5) == 0) + else if (CONST_STRNEQ (p, "i8086")) { address_mode = mode_16bit; priv.orig_sizeflag = 0; } - else if (strncmp (p, "intel", 5) == 0) + else if (CONST_STRNEQ (p, "intel")) { intel_syntax = 1; } - else if (strncmp (p, "att", 3) == 0) + else if (CONST_STRNEQ (p, "att")) { intel_syntax = 0; } - else if (strncmp (p, "addr", 4) == 0) + else if (CONST_STRNEQ (p, "addr")) { if (p[4] == '1' && p[5] == '6') priv.orig_sizeflag &= ~AFLAG; else if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag |= AFLAG; } - else if (strncmp (p, "data", 4) == 0) + else if (CONST_STRNEQ (p, "data")) { if (p[4] == '1' && p[5] == '6') priv.orig_sizeflag &= ~DFLAG; else if (p[4] == '3' && p[5] == '2') priv.orig_sizeflag |= DFLAG; } - else if (strncmp (p, "suffix", 6) == 0) + else if (CONST_STRNEQ (p, "suffix")) priv.orig_sizeflag |= SUFFIX_ALWAYS; p = strchr (p, ','); @@ -5207,9 +5207,9 @@ PNI_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag) && (prefixes & PREFIX_ADDR) && olen >= (4 + 7) && *(p - 1) == ' ' - && strncmp (p - 7, "addr", 4) == 0 - && (strncmp (p - 3, "16", 2) == 0 - || strncmp (p - 3, "32", 2) == 0)) + && CONST_STRNEQ (p - 7, "addr") + && (CONST_STRNEQ (p - 3, "16") + || CONST_STRNEQ (p - 3, "32"))) p -= 7; if (rm) diff --git a/opcodes/ia64-gen.c b/opcodes/ia64-gen.c index 556228319a8..b1d0225262f 100644 --- a/opcodes/ia64-gen.c +++ b/opcodes/ia64-gen.c @@ -467,7 +467,7 @@ fetch_insn_class (const char *full_name, int create) int ind; int is_class = 0; - if (strncmp (full_name, "IC:", 3) == 0) + if (CONST_STRNEQ (full_name, "IC:")) { name = xstrdup (full_name + 3); is_class = 1; @@ -749,7 +749,7 @@ parse_resource_users (ref, usersp, nusersp, notesp) are read. Only create new classes if it's *not* an insn class, or if it's a composite class (which wouldn't necessarily be in the IC table). */ - if (strncmp (name, "IC:", 3) != 0 || xsect != NULL) + if (! CONST_STRNEQ (name, "IC:") || xsect != NULL) create = 1; iclass = fetch_insn_class (name, create); @@ -1034,7 +1034,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, if (ic->comment) { - if (!strncmp (ic->comment, "Format", 6)) + if (CONST_STRNEQ (ic->comment, "Format")) { /* Assume that the first format seen is the most restrictive, and only keep a later one if it looks like it's more restrictive. */ @@ -1050,7 +1050,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, else format = ic->comment; } - else if (!strncmp (ic->comment, "Field", 5)) + else if (CONST_STRNEQ (ic->comment, "Field")) { if (field) warn (_("overlapping field %s->%s\n"), @@ -1064,7 +1064,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, instructions. */ if (ic->nsubs == 0 && ic->nxsubs == 0) { - int is_mov = strncmp (idesc->name, "mov", 3) == 0; + int is_mov = CONST_STRNEQ (idesc->name, "mov"); int plain_mov = strcmp (idesc->name, "mov") == 0; int len = strlen(ic->name); @@ -1123,32 +1123,32 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, if (resolved && format) { - if (strncmp (idesc->name, "dep", 3) == 0 + if (CONST_STRNEQ (idesc->name, "dep") && strstr (format, "I13") != NULL) resolved = idesc->operands[1] == IA64_OPND_IMM8; - else if (strncmp (idesc->name, "chk", 3) == 0 + else if (CONST_STRNEQ (idesc->name, "chk") && strstr (format, "M21") != NULL) resolved = idesc->operands[0] == IA64_OPND_F2; - else if (strncmp (idesc->name, "lfetch", 6) == 0) + else if (CONST_STRNEQ (idesc->name, "lfetch")) resolved = (strstr (format, "M14 M15") != NULL && (idesc->operands[1] == IA64_OPND_R2 || idesc->operands[1] == IA64_OPND_IMM9b)); - else if (strncmp (idesc->name, "br.call", 7) == 0 + else if (CONST_STRNEQ (idesc->name, "br.call") && strstr (format, "B5") != NULL) resolved = idesc->operands[1] == IA64_OPND_B2; - else if (strncmp (idesc->name, "br.call", 7) == 0 + else if (CONST_STRNEQ (idesc->name, "br.call") && strstr (format, "B3") != NULL) resolved = idesc->operands[1] == IA64_OPND_TGT25c; - else if (strncmp (idesc->name, "brp", 3) == 0 + else if (CONST_STRNEQ (idesc->name, "brp") && strstr (format, "B7") != NULL) resolved = idesc->operands[0] == IA64_OPND_B2; else if (strcmp (ic->name, "invala") == 0) resolved = strcmp (idesc->name, ic->name) == 0; - else if (strncmp (idesc->name, "st", 2) == 0 + else if (CONST_STRNEQ (idesc->name, "st") && (strstr (format, "M5") != NULL || strstr (format, "M10") != NULL)) resolved = idesc->flags & IA64_OPCODE_POSTINC; - else if (strncmp (idesc->name, "ld", 2) == 0 + else if (CONST_STRNEQ (idesc->name, "ld") && (strstr (format, "M2 M3") != NULL || strstr (format, "M12") != NULL || strstr (format, "M7 M8") != NULL)) @@ -1161,7 +1161,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, plain brl matches brl.cond. */ if (!resolved && (strcmp (idesc->name, "brl") == 0 - || strncmp (idesc->name, "brl.", 4) == 0) + || CONST_STRNEQ (idesc->name, "brl.")) && strcmp (ic->name, "brl.cond") == 0) { resolved = 1; @@ -1170,7 +1170,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, /* Misc br variations ('.cond' is optional). */ if (!resolved && (strcmp (idesc->name, "br") == 0 - || strncmp (idesc->name, "br.", 3) == 0) + || CONST_STRNEQ (idesc->name, "br.")) && strcmp (ic->name, "br.cond") == 0) { if (format) @@ -1183,7 +1183,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, } /* probe variations. */ - if (!resolved && strncmp (idesc->name, "probe", 5) == 0) + if (!resolved && CONST_STRNEQ (idesc->name, "probe")) { resolved = strcmp (ic->name, "probe") == 0 && !((strstr (idesc->name, "fault") != NULL) @@ -1217,7 +1217,7 @@ in_iclass (struct ia64_opcode *idesc, struct iclass *ic, } /* Some variants of mov and mov.[im]. */ - if (!resolved && strncmp (ic->name, "mov_", 4) == 0) + if (!resolved && CONST_STRNEQ (ic->name, "mov_")) resolved = in_iclass_mov_x (idesc, ic, format, field); } @@ -1476,13 +1476,13 @@ lookup_specifier (const char *name) warn (_("Don't know how to specify # dependency %s\n"), name); } - else if (strncmp (name, "AR[FPSR]", 8) == 0) + else if (CONST_STRNEQ (name, "AR[FPSR]")) return IA64_RS_AR_FPSR; - else if (strncmp (name, "AR[", 3) == 0) + else if (CONST_STRNEQ (name, "AR[")) return IA64_RS_ARX; - else if (strncmp (name, "CR[", 3) == 0) + else if (CONST_STRNEQ (name, "CR[")) return IA64_RS_CRX; - else if (strncmp (name, "PSR.", 4) == 0) + else if (CONST_STRNEQ (name, "PSR.")) return IA64_RS_PSR; else if (strcmp (name, "InService*") == 0) return IA64_RS_INSERVICE; @@ -2448,7 +2448,7 @@ insert_opcode_dependencies (opc, cmp) int j; if (strcmp (opc->name, "cmp.eq.and") == 0 - && strncmp (rs->name, "PR%", 3) == 0 + && CONST_STRNEQ (rs->name, "PR%") && rs->mode == 1) no_class_found = 99; @@ -2459,7 +2459,7 @@ insert_opcode_dependencies (opc, cmp) if (in_iclass (opc, ics[rs->regs[j]], NULL, NULL, &ic_note)) { /* We can ignore ic_note 11 for non PR resources. */ - if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0) + if (ic_note == 11 && ! CONST_STRNEQ (rs->name, "PR")) ic_note = 0; if (ic_note != 0 && rs->regnotes[j] != 0 @@ -2487,7 +2487,7 @@ insert_opcode_dependencies (opc, cmp) if (in_iclass (opc, ics[rs->chks[j]], NULL, NULL, &ic_note)) { /* We can ignore ic_note 11 for non PR resources. */ - if (ic_note == 11 && strncmp (rs->name, "PR", 2) != 0) + if (ic_note == 11 && ! CONST_STRNEQ (rs->name, "PR")) ic_note = 0; if (ic_note != 0 && rs->chknotes[j] != 0 diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c index b0562ea2523..8af043c977a 100644 --- a/opcodes/mips-dis.c +++ b/opcodes/mips-dis.c @@ -575,7 +575,7 @@ parse_mips_dis_option (const char *option, unsigned int len) const struct mips_arch_choice *chosen_arch; /* Try to match options that are simple flags */ - if (strncmp (option, "no-aliases", 10) == 0) + if (CONST_STRNEQ (option, "no-aliases")) { no_aliases = 1; return; |