aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-03-18 15:16:54 +0100
committerMartin Liska <mliska@suse.cz>2021-04-01 14:59:04 +0200
commit3f3328b816ee3486ac0621cfd6d808faa2c0a689 (patch)
tree5323d7ff39635e28d62c26a7e13e705ccfafe757 /binutils
parent24d127aa9f26445709dbd53e14e2ab636a449888 (diff)
downloadfsf-binutils-gdb-3f3328b816ee3486ac0621cfd6d808faa2c0a689.zip
fsf-binutils-gdb-3f3328b816ee3486ac0621cfd6d808faa2c0a689.tar.gz
fsf-binutils-gdb-3f3328b816ee3486ac0621cfd6d808faa2c0a689.tar.bz2
Use startswith more for strncmp function calls.
bfd/ChangeLog: * elf-bfd.h (bfd_section_is_ctf): Use startswith function. * elf.c (_bfd_elf_make_section_from_shdr): Likewise. (elf_get_reloc_section): Likewise. * elf32-arc.c (elf_arc_size_dynamic_sections): Likewise. * elf32-m32r.c (m32r_elf_section_flags): Likewise. * elf32-microblaze.c (microblaze_elf_size_dynamic_sections): Likewise. * elf32-nds32.c (nds32_elf_size_dynamic_sections): Likewise. (nds32_elf_relocate_section): Likewise. (nds32_elf_action_discarded): Likewise. (nds32_elf_check_relocs): Likewise. (nds32_elf_section_flags): Likewise. * elf32-or1k.c (or1k_elf_check_relocs): Likewise. * elf32-ppc.c (ppc_elf_section_from_shdr): Likewise. * elf32-rx.c (rx_table_find): Likewise. (rx_table_map): Likewise. * elf32-spu.c (spu_elf_backend_symbol_processing): Likewise. (spu_elf_find_overlays): Likewise. (needs_ovl_stub): Likewise. (allocate_spuear_stubs): Likewise. (build_spuear_stubs): Likewise. (mark_overlay_section): Likewise. (spu_elf_auto_overlay): Likewise. (spu_elf_output_symbol_hook): Likewise. * elf32-tilepro.c (tilepro_elf_size_dynamic_sections): Likewise. * elf32-xtensa.c (xtensa_property_section_name): Likewise. * elf64-ppc.c (ppc64_elf_section_flags): Likewise. (ppc64_elf_relocate_section): Likewise. * elflink.c (resolve_section): Likewise. (UNARY_OP): Likewise. (BINARY_OP_HEAD): Likewise. (elf_link_input_bfd): Likewise. * elfnn-riscv.c (riscv_elf_size_dynamic_sections): Likewise. * elfxx-riscv.c (riscv_parse_subset): Likewise. * elfxx-tilegx.c (tilegx_elf_size_dynamic_sections): Likewise. * opncls.c (get_build_id): Likewise. binutils/ChangeLog: * dllwrap.c: Use startswith function. * objcopy.c (is_dwo_section): Likewise. (handle_remove_section_option): Likewise. (copy_main): Likewise. * objdump.c (is_significant_symbol_name): Likewise.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/dllwrap.c8
-rw-r--r--binutils/objcopy.c20
-rw-r--r--binutils/objdump.c2
4 files changed, 23 insertions, 15 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 125ac81..1ffbdf8 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,13 @@
2021-04-01 Martin Liska <mliska@suse.cz>
+ * dllwrap.c: Use startswith function.
+ * objcopy.c (is_dwo_section): Likewise.
+ (handle_remove_section_option): Likewise.
+ (copy_main): Likewise.
+ * objdump.c (is_significant_symbol_name): Likewise.
+
+2021-04-01 Martin Liska <mliska@suse.cz>
+
* dwarf.c (display_debug_lines_raw): Replace const_strneq with
startswith.
(display_debug_lines_decoded): Likewise.
diff --git a/binutils/dllwrap.c b/binutils/dllwrap.c
index bd65b98..bc7104d 100644
--- a/binutils/dllwrap.c
+++ b/binutils/dllwrap.c
@@ -840,11 +840,11 @@ Creating one, but that may not be what you want"));
else
which_target = UNKNOWN_TARGET;
- if (! strncmp (target, "arm", 3))
+ if (startswith (target, "arm"))
which_cpu = ARM_CPU;
- else if (!strncmp (target, "x86_64", 6)
- || !strncmp (target, "athlon64", 8)
- || !strncmp (target, "amd64", 5))
+ else if (startswith (target, "x86_64")
+ || startswith (target, "athlon64")
+ || startswith (target, "amd64"))
which_cpu = X64_CPU;
else if (target[0] == 'i' && (target[1] >= '3' && target[1] <= '6')
&& target[2] == '8' && target[3] == '6')
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 092bc9e..6622adc 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1285,7 +1285,7 @@ is_dwo_section (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
if (len < 5)
return false;
- return strncmp (name + len - 4, ".dwo", 4) == 0;
+ return startswith (name + len - 4, ".dwo");
}
/* Return TRUE if section SEC is in the update list. */
@@ -4261,7 +4261,7 @@ static void
handle_remove_section_option (const char *section_pattern)
{
find_section_list (section_pattern, true, SECTION_CONTEXT_REMOVE);
- if (strncmp (section_pattern, ".rel", 4) == 0)
+ if (startswith (section_pattern, ".rel"))
{
section_pattern += 4;
if (*section_pattern == 'a')
@@ -5875,15 +5875,15 @@ copy_main (int argc, char *argv[])
/* Convert input EFI target to PEI target. */
if (input_target != NULL
- && strncmp (input_target, "efi-", 4) == 0)
+ && startswith (input_target, "efi-"))
{
char *efi;
efi = xstrdup (output_target + 4);
- if (strncmp (efi, "bsdrv-", 6) == 0
- || strncmp (efi, "rtdrv-", 6) == 0)
+ if (startswith (efi, "bsdrv-")
+ || startswith (efi, "rtdrv-"))
efi += 2;
- else if (strncmp (efi, "app-", 4) != 0)
+ else if (!startswith (efi, "app-"))
fatal (_("unknown input EFI target: %s"), input_target);
input_target = efi;
@@ -5892,23 +5892,23 @@ copy_main (int argc, char *argv[])
/* Convert output EFI target to PEI target. */
if (output_target != NULL
- && strncmp (output_target, "efi-", 4) == 0)
+ && startswith (output_target, "efi-"))
{
char *efi;
efi = xstrdup (output_target + 4);
- if (strncmp (efi, "app-", 4) == 0)
+ if (startswith (efi, "app-"))
{
if (pe_subsystem == -1)
pe_subsystem = IMAGE_SUBSYSTEM_EFI_APPLICATION;
}
- else if (strncmp (efi, "bsdrv-", 6) == 0)
+ else if (startswith (efi, "bsdrv-"))
{
if (pe_subsystem == -1)
pe_subsystem = IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER;
efi += 2;
}
- else if (strncmp (efi, "rtdrv-", 6) == 0)
+ else if (startswith (efi, "rtdrv-"))
{
if (pe_subsystem == -1)
pe_subsystem = IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER;
diff --git a/binutils/objdump.c b/binutils/objdump.c
index bffd744..cbbec81 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -821,7 +821,7 @@ slurp_dynamic_symtab (bfd *abfd)
static bool
is_significant_symbol_name (const char * name)
{
- return strncmp (name, ".plt", 4) == 0 || strcmp (name, ".got") == 0;
+ return startswith (name, ".plt") || startswith (name, ".got");
}
/* Filter out (in place) symbols that are useless for disassembly.