aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-03-22 12:12:36 +0100
committerMartin Liska <mliska@suse.cz>2021-04-01 06:47:23 +0200
commit639155da66491d4b84ce0fa86549d66dc6c0f4f7 (patch)
treeca020995cd375752e6c892bb420df656d87e80af
parent733f5eea6bde8546a4845416457174c6d716e882 (diff)
downloadgdb-639155da66491d4b84ce0fa86549d66dc6c0f4f7.zip
gdb-639155da66491d4b84ce0fa86549d66dc6c0f4f7.tar.gz
gdb-639155da66491d4b84ce0fa86549d66dc6c0f4f7.tar.bz2
Replace const_strneq with startswith.
binutils/ChangeLog: * dwarf.c (display_debug_lines_raw): Replace const_strneq with startswith. (display_debug_lines_decoded): Likewise. (display_debug_links): Likewise. * elfcomm.c (setup_archive): Likewise. * elfcomm.h (const_strneq): Likewise. * readelf.c (process_section_headers): Likewise. (slurp_ia64_unwind_table): Likewise. (slurp_hppa_unwind_table): Likewise. (decode_arm_unwind): Likewise. (display_debug_section): Likewise. (process_note): Likewise.
-rw-r--r--binutils/dwarf.c8
-rw-r--r--binutils/elfcomm.c7
-rw-r--r--binutils/elfcomm.h1
-rw-r--r--binutils/readelf.c102
4 files changed, 59 insertions, 59 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index a8b6562..293d33e 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -4500,7 +4500,7 @@ display_debug_lines_raw (struct dwarf_section * section,
unsigned char *end_of_sequence;
int i;
- if (const_strneq (section->name, ".debug_line.")
+ if (startswith (section->name, ".debug_line.")
/* Note: the following does not apply to .debug_line.dwo sections.
These are full debug_line sections. */
&& strcmp (section->name, ".debug_line.dwo") != 0)
@@ -4924,7 +4924,7 @@ display_debug_lines_decoded (struct dwarf_section * section,
unsigned char **directory_table = NULL;
dwarf_vma n_directories = 0;
- if (const_strneq (section->name, ".debug_line.")
+ if (startswith (section->name, ".debug_line.")
/* Note: the following does not apply to .debug_line.dwo sections.
These are full debug_line sections. */
&& strcmp (section->name, ".debug_line.dwo") != 0)
@@ -10031,7 +10031,7 @@ display_debug_links (struct dwarf_section * section,
printf (_(" Separate debug info file: %s\n"), filename);
- if (const_strneq (section->name, ".gnu_debuglink"))
+ if (startswith (section->name, ".gnu_debuglink"))
{
unsigned int crc32;
unsigned int crc_offset;
@@ -10055,7 +10055,7 @@ display_debug_links (struct dwarf_section * section,
return 0;
}
}
- else /* const_strneq (section->name, ".gnu_debugaltlink") */
+ else /* startswith (section->name, ".gnu_debugaltlink") */
{
const unsigned char * build_id = section->start + filelen + 1;
bfd_size_type build_id_len = section->size - (filelen + 1);
diff --git a/binutils/elfcomm.c b/binutils/elfcomm.c
index 5cf4c24..c5092c6 100644
--- a/binutils/elfcomm.c
+++ b/binutils/elfcomm.c
@@ -27,6 +27,7 @@
#include "sysdep.h"
#include "libiberty.h"
+#include "bfd.h"
#include "filenames.h"
#include "aout/ar.h"
#include "elfcomm.h"
@@ -611,12 +612,12 @@ setup_archive (struct archive_info *arch, const char *file_name,
}
/* See if this is the archive symbol table. */
- if (const_strneq (arch->arhdr.ar_name, "/ "))
+ if (startswith (arch->arhdr.ar_name, "/ "))
{
if (! process_archive_index_and_symbols (arch, 4, read_symbols))
return 1;
}
- else if (const_strneq (arch->arhdr.ar_name, "/SYM64/ "))
+ else if (startswith (arch->arhdr.ar_name, "/SYM64/ "))
{
arch->uses_64bit_indices = 1;
if (! process_archive_index_and_symbols (arch, 8, read_symbols))
@@ -625,7 +626,7 @@ setup_archive (struct archive_info *arch, const char *file_name,
else if (read_symbols)
printf (_("%s has no archive index\n"), file_name);
- if (const_strneq (arch->arhdr.ar_name, "// "))
+ if (startswith (arch->arhdr.ar_name, "// "))
{
/* This is the archive string table holding long member names. */
char fmag_save = arch->arhdr.ar_fmag[0];
diff --git a/binutils/elfcomm.h b/binutils/elfcomm.h
index 9754ce1..04e909c 100644
--- a/binutils/elfcomm.h
+++ b/binutils/elfcomm.h
@@ -48,7 +48,6 @@ extern void byte_get_64 (const unsigned char *, elf_vma *, elf_vma *);
/* This is just a bit of syntatic sugar. */
#define streq(a,b) (strcmp ((a), (b)) == 0)
#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
-#define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0)
/* Structure to hold information about an archive file. */
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 8ffca05..01fba0b 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -6589,8 +6589,8 @@ process_section_headers (Filedata * filedata)
|| do_debug_str || do_debug_str_offsets || do_debug_loc
|| do_debug_ranges
|| do_debug_addr || do_debug_cu_index || do_debug_links)
- && (const_strneq (name, ".debug_")
- || const_strneq (name, ".zdebug_")))
+ && (startswith (name, ".debug_")
+ || startswith (name, ".zdebug_")))
{
if (name[1] == 'z')
name += sizeof (".zdebug_") - 1;
@@ -6598,35 +6598,35 @@ process_section_headers (Filedata * filedata)
name += sizeof (".debug_") - 1;
if (do_debugging
- || (do_debug_info && const_strneq (name, "info"))
- || (do_debug_info && const_strneq (name, "types"))
- || (do_debug_abbrevs && const_strneq (name, "abbrev"))
+ || (do_debug_info && startswith (name, "info"))
+ || (do_debug_info && startswith (name, "types"))
+ || (do_debug_abbrevs && startswith (name, "abbrev"))
|| (do_debug_lines && strcmp (name, "line") == 0)
- || (do_debug_lines && const_strneq (name, "line."))
- || (do_debug_pubnames && const_strneq (name, "pubnames"))
- || (do_debug_pubtypes && const_strneq (name, "pubtypes"))
- || (do_debug_pubnames && const_strneq (name, "gnu_pubnames"))
- || (do_debug_pubtypes && const_strneq (name, "gnu_pubtypes"))
- || (do_debug_aranges && const_strneq (name, "aranges"))
- || (do_debug_ranges && const_strneq (name, "ranges"))
- || (do_debug_ranges && const_strneq (name, "rnglists"))
- || (do_debug_frames && const_strneq (name, "frame"))
- || (do_debug_macinfo && const_strneq (name, "macinfo"))
- || (do_debug_macinfo && const_strneq (name, "macro"))
- || (do_debug_str && const_strneq (name, "str"))
- || (do_debug_links && const_strneq (name, "sup"))
- || (do_debug_str_offsets && const_strneq (name, "str_offsets"))
- || (do_debug_loc && const_strneq (name, "loc"))
- || (do_debug_loc && const_strneq (name, "loclists"))
- || (do_debug_addr && const_strneq (name, "addr"))
- || (do_debug_cu_index && const_strneq (name, "cu_index"))
- || (do_debug_cu_index && const_strneq (name, "tu_index"))
+ || (do_debug_lines && startswith (name, "line."))
+ || (do_debug_pubnames && startswith (name, "pubnames"))
+ || (do_debug_pubtypes && startswith (name, "pubtypes"))
+ || (do_debug_pubnames && startswith (name, "gnu_pubnames"))
+ || (do_debug_pubtypes && startswith (name, "gnu_pubtypes"))
+ || (do_debug_aranges && startswith (name, "aranges"))
+ || (do_debug_ranges && startswith (name, "ranges"))
+ || (do_debug_ranges && startswith (name, "rnglists"))
+ || (do_debug_frames && startswith (name, "frame"))
+ || (do_debug_macinfo && startswith (name, "macinfo"))
+ || (do_debug_macinfo && startswith (name, "macro"))
+ || (do_debug_str && startswith (name, "str"))
+ || (do_debug_links && startswith (name, "sup"))
+ || (do_debug_str_offsets && startswith (name, "str_offsets"))
+ || (do_debug_loc && startswith (name, "loc"))
+ || (do_debug_loc && startswith (name, "loclists"))
+ || (do_debug_addr && startswith (name, "addr"))
+ || (do_debug_cu_index && startswith (name, "cu_index"))
+ || (do_debug_cu_index && startswith (name, "tu_index"))
)
request_dump_bynumber (&filedata->dump, i, DEBUG_DUMP);
}
/* Linkonce section to be combined with .debug_info at link time. */
else if ((do_debugging || do_debug_info)
- && const_strneq (name, ".gnu.linkonce.wi."))
+ && startswith (name, ".gnu.linkonce.wi."))
request_dump_bynumber (&filedata->dump, i, DEBUG_DUMP);
else if (do_debug_frames && streq (name, ".eh_frame"))
request_dump_bynumber (&filedata->dump, i, DEBUG_DUMP);
@@ -6636,7 +6636,7 @@ process_section_headers (Filedata * filedata)
/* Trace sections for Itanium VMS. */
else if ((do_debugging || do_trace_info || do_trace_abbrevs
|| do_trace_aranges)
- && const_strneq (name, ".trace_"))
+ && startswith (name, ".trace_"))
{
name += sizeof (".trace_") - 1;
@@ -6648,8 +6648,8 @@ process_section_headers (Filedata * filedata)
request_dump_bynumber (&filedata->dump, i, DEBUG_DUMP);
}
else if ((do_debugging || do_debug_links)
- && (const_strneq (name, ".gnu_debuglink")
- || const_strneq (name, ".gnu_debugaltlink")))
+ && (startswith (name, ".gnu_debuglink")
+ || startswith (name, ".gnu_debugaltlink")))
request_dump_bynumber (&filedata->dump, i, DEBUG_DUMP);
}
@@ -8107,7 +8107,7 @@ slurp_ia64_unwind_table (Filedata * filedata,
continue;
}
- if (! const_strneq (relname, "R_IA64_SEGREL"))
+ if (! startswith (relname, "R_IA64_SEGREL"))
{
warn (_("Skipping unexpected relocation type: %s\n"), relname);
continue;
@@ -8574,7 +8574,7 @@ slurp_hppa_unwind_table (Filedata * filedata,
}
/* R_PARISC_SEGREL32 or R_PARISC_SEGREL64. */
- if (! const_strneq (relname, "R_PARISC_SEGREL"))
+ if (! startswith (relname, "R_PARISC_SEGREL"))
{
warn (_("Skipping unexpected relocation type: %s\n"), relname);
continue;
@@ -9476,10 +9476,10 @@ decode_arm_unwind (Filedata * filedata,
encoding, starting with one byte giving the number of
words. */
if (procname != NULL
- && (const_strneq (procname, "__gcc_personality_v0")
- || const_strneq (procname, "__gxx_personality_v0")
- || const_strneq (procname, "__gcj_personality_v0")
- || const_strneq (procname, "__gnu_objc_personality_v0")))
+ && (startswith (procname, "__gcc_personality_v0")
+ || startswith (procname, "__gxx_personality_v0")
+ || startswith (procname, "__gcj_personality_v0")
+ || startswith (procname, "__gnu_objc_personality_v0")))
{
remaining = 0;
more_words = 1;
@@ -15297,7 +15297,7 @@ malformed note encountered in section %s whilst scanning for build-id note\n"),
/* Check if this is the build-id note. If so then convert the build-id
bytes to a hex string. */
if (inote.namesz > 0
- && const_strneq (inote.namedata, "GNU")
+ && startswith (inote.namedata, "GNU")
&& inote.type == NT_GNU_BUILD_ID)
{
unsigned long j;
@@ -15425,7 +15425,7 @@ display_debug_section (int shndx, Elf_Internal_Shdr * section, Filedata * fileda
return false;
}
- if (const_strneq (name, ".gnu.linkonce.wi."))
+ if (startswith (name, ".gnu.linkonce.wi."))
name = ".debug_info";
/* See if we know how to display the contents of this section. */
@@ -15436,7 +15436,7 @@ display_debug_section (int shndx, Elf_Internal_Shdr * section, Filedata * fileda
struct dwarf_section * sec = & display->section;
if (streq (sec->uncompressed_name, name)
- || (id == line && const_strneq (name, ".debug_line."))
+ || (id == line && startswith (name, ".debug_line."))
|| streq (sec->compressed_name, name))
{
bool secondary = (section != find_section (filedata, name));
@@ -15444,7 +15444,7 @@ display_debug_section (int shndx, Elf_Internal_Shdr * section, Filedata * fileda
if (secondary)
free_debug_section (id);
- if (i == line && const_strneq (name, ".debug_line."))
+ if (i == line && startswith (name, ".debug_line."))
sec->name = name;
else if (streq (sec->uncompressed_name, name))
sec->name = sec->uncompressed_name;
@@ -20429,23 +20429,23 @@ process_note (Elf_Internal_Note * pnote,
note type strings. */
nt = get_note_type (filedata, pnote->type);
- else if (const_strneq (pnote->namedata, "GNU"))
+ else if (startswith (pnote->namedata, "GNU"))
/* GNU-specific object file notes. */
nt = get_gnu_elf_note_type (pnote->type);
- else if (const_strneq (pnote->namedata, "FreeBSD"))
+ else if (startswith (pnote->namedata, "FreeBSD"))
/* FreeBSD-specific core file notes. */
nt = get_freebsd_elfcore_note_type (filedata, pnote->type);
- else if (const_strneq (pnote->namedata, "NetBSD-CORE"))
+ else if (startswith (pnote->namedata, "NetBSD-CORE"))
/* NetBSD-specific core file notes. */
nt = get_netbsd_elfcore_note_type (filedata, pnote->type);
- else if (const_strneq (pnote->namedata, "NetBSD"))
+ else if (startswith (pnote->namedata, "NetBSD"))
/* NetBSD-specific core file notes. */
return process_netbsd_elf_note (pnote);
- else if (const_strneq (pnote->namedata, "PaX"))
+ else if (startswith (pnote->namedata, "PaX"))
/* NetBSD-specific core file notes. */
return process_netbsd_elf_note (pnote);
@@ -20456,11 +20456,11 @@ process_note (Elf_Internal_Note * pnote,
name = "SPU";
}
- else if (const_strneq (pnote->namedata, "IPF/VMS"))
+ else if (startswith (pnote->namedata, "IPF/VMS"))
/* VMS/ia64-specific file notes. */
nt = get_ia64_vms_note_type (pnote->type);
- else if (const_strneq (pnote->namedata, "stapsdt"))
+ else if (startswith (pnote->namedata, "stapsdt"))
nt = get_stapsdt_note_type (pnote->type);
else
@@ -20470,7 +20470,7 @@ process_note (Elf_Internal_Note * pnote,
printf (" ");
- if (((const_strneq (pnote->namedata, "GA")
+ if (((startswith (pnote->namedata, "GA")
&& strchr ("*$!+", pnote->namedata[2]) != NULL)
|| strchr ("*$!+", pnote->namedata[0]) != NULL)
&& (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN
@@ -20484,15 +20484,15 @@ process_note (Elf_Internal_Note * pnote,
else
printf (" 0x%08lx\t%s\n", pnote->descsz, nt);
- if (const_strneq (pnote->namedata, "IPF/VMS"))
+ if (startswith (pnote->namedata, "IPF/VMS"))
return print_ia64_vms_note (pnote);
- else if (const_strneq (pnote->namedata, "GNU"))
+ else if (startswith (pnote->namedata, "GNU"))
return print_gnu_note (filedata, pnote);
- else if (const_strneq (pnote->namedata, "stapsdt"))
+ else if (startswith (pnote->namedata, "stapsdt"))
return print_stapsdt_note (pnote);
- else if (const_strneq (pnote->namedata, "CORE"))
+ else if (startswith (pnote->namedata, "CORE"))
return print_core_note (pnote);
- else if (((const_strneq (pnote->namedata, "GA")
+ else if (((startswith (pnote->namedata, "GA")
&& strchr ("*$!+", pnote->namedata[2]) != NULL)
|| strchr ("*$!+", pnote->namedata[0]) != NULL)
&& (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN