315 lines
9.9 KiB
Diff
315 lines
9.9 KiB
Diff
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
||
From: Keith Seitz <keiths@redhat.com>
|
||
Date: Thu, 14 May 2026 10:15:24 -0700
|
||
Subject: gdb-c23-fixes.patch
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
Fix even more -Wdiscarded-qualifers issues
|
||
|
||
Fedora Rawhide is failing to build due to new glibc header changes
|
||
enforcing const-correctness in functions like strchr and memchr.
|
||
For example:
|
||
|
||
../../opcodes/aarch64-dis.c: In function ‘remove_dot_suffix’:
|
||
../../opcodes/aarch64-dis.c:4027:7: error: assignment discards ‘const’ qualifier from po
|
||
inter target type [-Werror=discarded-qualifiers]
|
||
4027 | ptr = strchr (inst->opcode->name, '.');
|
||
| ^
|
||
cc1: all warnings being treated as errors
|
||
|
||
This patch addresses all the discovered issues with --enable-targets=all
|
||
and regenerates a few cgen files along the way.
|
||
|
||
diff --git a/bfd/bfd.c b/bfd/bfd.c
|
||
--- a/bfd/bfd.c
|
||
+++ b/bfd/bfd.c
|
||
@@ -1060,7 +1060,7 @@ _bfd_doprnt (bfd_print_callback print, void *stream, const char *format,
|
||
if (*ptr != '%')
|
||
{
|
||
/* While we have regular characters, print them. */
|
||
- char *end = strchr (ptr, '%');
|
||
+ const char *end = strchr (ptr, '%');
|
||
if (end != NULL)
|
||
result = print (stream, "%.*s", (int) (end - ptr), ptr);
|
||
else
|
||
diff --git a/bfd/elflink.c b/bfd/elflink.c
|
||
--- a/bfd/elflink.c
|
||
+++ b/bfd/elflink.c
|
||
@@ -148,7 +148,7 @@ _bfd_elf_section_for_symbol (struct elf_reloc_cookie *cookie,
|
||
struct elf_link_hash_entry *h;
|
||
|
||
h = get_ext_sym_hash_from_cookie (cookie, r_symndx);
|
||
-
|
||
+
|
||
if (h != NULL)
|
||
{
|
||
if ((h->root.type == bfd_link_hash_defined
|
||
@@ -588,7 +588,7 @@ bfd_elf_link_record_dynamic_symbol (struct bfd_link_info *info,
|
||
if (h->dynindx == -1)
|
||
{
|
||
struct elf_strtab_hash *dynstr;
|
||
- char *p;
|
||
+ const char *p;
|
||
const char *name;
|
||
size_t indx;
|
||
|
||
@@ -718,7 +718,7 @@ bfd_elf_record_link_assignment (bfd *output_bfd,
|
||
if (h->versioned == unknown)
|
||
{
|
||
/* Set versioned if symbol version is unknown. */
|
||
- char *version = strrchr (name, ELF_VER_CHR);
|
||
+ const char *version = strrchr (name, ELF_VER_CHR);
|
||
if (version)
|
||
{
|
||
if (version > name && version[-1] != ELF_VER_CHR)
|
||
@@ -1152,7 +1152,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
|
||
bool newdyn, olddyn, olddef, newdef, newdyncommon, olddyncommon;
|
||
bool newweak, oldweak, newfunc, oldfunc;
|
||
const struct elf_backend_data *bed;
|
||
- char *new_version;
|
||
+ const char *new_version;
|
||
bool default_sym = *matched;
|
||
struct elf_link_hash_table *htab;
|
||
|
||
@@ -1224,7 +1224,7 @@ _bfd_elf_merge_symbol (bfd *abfd,
|
||
{
|
||
/* OLD_VERSION is the symbol version of the existing
|
||
symbol. */
|
||
- char *old_version;
|
||
+ const char *old_version;
|
||
|
||
if (h->versioned >= versioned)
|
||
old_version = strrchr (h->root.root.string,
|
||
@@ -1950,7 +1950,7 @@ _bfd_elf_add_default_symbol (bfd *abfd,
|
||
bool collect;
|
||
bool dynamic;
|
||
bfd *override;
|
||
- char *p;
|
||
+ const char *p;
|
||
size_t len, shortlen;
|
||
asection *tmp_sec;
|
||
bool matched;
|
||
@@ -2642,7 +2642,7 @@ _bfd_elf_link_assign_sym_version (struct elf_link_hash_entry *h, void *data)
|
||
struct bfd_link_info *info;
|
||
const struct elf_backend_data *bed;
|
||
struct elf_info_failed eif;
|
||
- char *p;
|
||
+ const char *p;
|
||
bool hide;
|
||
|
||
sinfo = (struct elf_info_failed *) data;
|
||
@@ -5641,7 +5641,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
|
||
&& !dynamic
|
||
&& (abfd->flags & BFD_PLUGIN) == 0)
|
||
{
|
||
- char *p = strchr (name, ELF_VER_CHR);
|
||
+ const char *p = strchr (name, ELF_VER_CHR);
|
||
if (p != NULL && p[1] != ELF_VER_CHR)
|
||
{
|
||
/* Queue non-default versions so that .symver x, x@FOO
|
||
@@ -5891,7 +5891,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
|
||
for (cnt = 0; cnt < nondeflt_vers_cnt; ++cnt)
|
||
{
|
||
struct elf_link_hash_entry *h = nondeflt_vers[cnt], *hi;
|
||
- char *shortname, *p;
|
||
+ char *shortname;
|
||
+ const char *p;
|
||
size_t amt;
|
||
|
||
p = strchr (h->root.root.string, ELF_VER_CHR);
|
||
@@ -6171,7 +6172,8 @@ _bfd_elf_archive_symbol_lookup (bfd *abfd,
|
||
const char *name)
|
||
{
|
||
struct bfd_link_hash_entry *h;
|
||
- char *p, *copy;
|
||
+ const char *p;
|
||
+ char *copy;
|
||
size_t len, first;
|
||
|
||
h = bfd_link_hash_lookup (info->hash, name, false, false, true);
|
||
@@ -6466,7 +6468,7 @@ elf_collect_hash_codes (struct elf_link_hash_entry *h, void *data)
|
||
name = h->root.root.string;
|
||
if (h->versioned >= versioned)
|
||
{
|
||
- char *p = strchr (name, ELF_VER_CHR);
|
||
+ const char *p = strchr (name, ELF_VER_CHR);
|
||
if (p != NULL)
|
||
{
|
||
alc = (char *) bfd_malloc (p - name + 1);
|
||
@@ -6539,7 +6541,7 @@ elf_collect_gnu_hash_codes (struct elf_link_hash_entry *h, void *data)
|
||
name = h->root.root.string;
|
||
if (h->versioned >= versioned)
|
||
{
|
||
- char *p = strchr (name, ELF_VER_CHR);
|
||
+ const char *p = strchr (name, ELF_VER_CHR);
|
||
if (p != NULL)
|
||
{
|
||
alc = (char *) bfd_malloc (p - name + 1);
|
||
@@ -10378,8 +10380,8 @@ elf_link_output_symstrtab (void *finf,
|
||
{
|
||
/* Keep only one '@' for versioned symbols defined in
|
||
shared objects. */
|
||
- char *version = strrchr (name, ELF_VER_CHR);
|
||
- char *base_end = strchr (name, ELF_VER_CHR);
|
||
+ const char *version = strrchr (name, ELF_VER_CHR);
|
||
+ const char *base_end = strchr (name, ELF_VER_CHR);
|
||
if (version != base_end)
|
||
{
|
||
size_t base_len;
|
||
@@ -11118,7 +11120,7 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
|
||
|| h->ref_dynamic
|
||
|| !h->def_regular))
|
||
{
|
||
- char *p = strrchr (h->root.root.string, ELF_VER_CHR);
|
||
+ const char *p = strrchr (h->root.root.string, ELF_VER_CHR);
|
||
|
||
if (p && p [1] != '\0')
|
||
{
|
||
@@ -11670,7 +11672,7 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
|
||
input_bfd);
|
||
bfd_set_error (bfd_error_bad_value);
|
||
return false;
|
||
- }
|
||
+ }
|
||
|
||
/* Arrange for symbol to be output. */
|
||
h->indx = -2;
|
||
@@ -15142,7 +15144,7 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
|
||
struct elf_link_hash_entry *h;
|
||
|
||
h = get_ext_sym_hash_from_cookie (rcookie, r_symndx);
|
||
-
|
||
+
|
||
if (h != NULL)
|
||
{
|
||
if ((h->root.type == bfd_link_hash_defined
|
||
diff --git a/bfd/targets.c b/bfd/targets.c
|
||
--- a/bfd/targets.c
|
||
+++ b/bfd/targets.c
|
||
@@ -1660,7 +1660,7 @@ bfd_get_target_info (const char *target_name, bfd *abfd,
|
||
|
||
if (arches && tname)
|
||
{
|
||
- char *hyp = strchr (tname, '-');
|
||
+ const char *hyp = strchr (tname, '-');
|
||
|
||
if (hyp != NULL)
|
||
{
|
||
@@ -1673,9 +1673,10 @@ bfd_get_target_info (const char *target_name, bfd *abfd,
|
||
char new_tname[50];
|
||
|
||
strcpy (new_tname, hyp);
|
||
- while ((hyp = strrchr (new_tname, '-')) != NULL)
|
||
+ char *new_hyp;
|
||
+ while ((new_hyp = strrchr (new_tname, '-')) != NULL)
|
||
{
|
||
- *hyp = 0;
|
||
+ *new_hyp = 0;
|
||
if (_bfd_find_arch_match (new_tname, arches,
|
||
def_target_arch))
|
||
break;
|
||
diff --git a/cpu/ip2k.opc b/cpu/ip2k.opc
|
||
--- a/cpu/ip2k.opc
|
||
+++ b/cpu/ip2k.opc
|
||
@@ -94,7 +94,7 @@ parse_fr (CGEN_CPU_DESC cd,
|
||
{
|
||
const char *errmsg;
|
||
const char *old_strp;
|
||
- char *afteroffset;
|
||
+ const char *afteroffset;
|
||
enum cgen_parse_operand_result result_type;
|
||
bfd_vma value;
|
||
extern CGEN_KEYWORD ip2k_cgen_opval_register_names;
|
||
diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c
|
||
--- a/opcodes/aarch64-dis.c
|
||
+++ b/opcodes/aarch64-dis.c
|
||
@@ -4061,7 +4061,7 @@ print_operands (bfd_vma pc, const aarch64_opcode *opcode,
|
||
static void
|
||
remove_dot_suffix (char *name, const aarch64_inst *inst)
|
||
{
|
||
- char *ptr;
|
||
+ const char *ptr;
|
||
size_t len;
|
||
|
||
ptr = strchr (inst->opcode->name, '.');
|
||
diff --git a/opcodes/ia64-opc.c b/opcodes/ia64-opc.c
|
||
--- a/opcodes/ia64-opc.c
|
||
+++ b/opcodes/ia64-opc.c
|
||
@@ -66,7 +66,7 @@ const struct ia64_templ_desc ia64_templ_desc[16] =
|
||
static void
|
||
get_opc_prefix (const char **ptr, char *dest)
|
||
{
|
||
- char *c = strchr (*ptr, '.');
|
||
+ const char *c = strchr (*ptr, '.');
|
||
if (c != NULL)
|
||
{
|
||
memcpy (dest, *ptr, c - *ptr);
|
||
diff --git a/opcodes/ip2k-asm.c b/opcodes/ip2k-asm.c
|
||
--- a/opcodes/ip2k-asm.c
|
||
+++ b/opcodes/ip2k-asm.c
|
||
@@ -59,7 +59,7 @@ parse_fr (CGEN_CPU_DESC cd,
|
||
{
|
||
const char *errmsg;
|
||
const char *old_strp;
|
||
- char *afteroffset;
|
||
+ const char *afteroffset;
|
||
enum cgen_parse_operand_result result_type;
|
||
bfd_vma value;
|
||
extern CGEN_KEYWORD ip2k_cgen_opval_register_names;
|
||
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
|
||
--- a/opcodes/riscv-dis.c
|
||
+++ b/opcodes/riscv-dis.c
|
||
@@ -110,7 +110,7 @@ parse_riscv_dis_option_without_args (const char *option,
|
||
/* Parse RISC-V disassembler option (possibly with arguments). */
|
||
|
||
static void
|
||
-parse_riscv_dis_option (const char *option, struct disassemble_info *info)
|
||
+parse_riscv_dis_option (char *option, struct disassemble_info *info)
|
||
{
|
||
char *equal, *value;
|
||
|
||
@@ -1140,7 +1140,7 @@ riscv_update_map_state (int n,
|
||
|
||
/* ISA mapping string may be numbered, suffixed with '.n'. Do not
|
||
consider this as part of the ISA string. */
|
||
- char *suffix = strchr (name, '.');
|
||
+ const char *suffix = strchr (name, '.');
|
||
if (suffix)
|
||
{
|
||
int suffix_index = (int)(suffix - name);
|
||
diff --git a/opcodes/tilegx-opc.c b/opcodes/tilegx-opc.c
|
||
--- a/opcodes/tilegx-opc.c
|
||
+++ b/opcodes/tilegx-opc.c
|
||
@@ -8003,7 +8003,7 @@ tilegx_spr_compare (const void *a_ptr, const void *b_ptr)
|
||
const char *
|
||
get_tilegx_spr_name (int num)
|
||
{
|
||
- void *result;
|
||
+ const void *result;
|
||
struct tilegx_spr key;
|
||
|
||
key.number = num;
|
||
diff --git a/opcodes/tilepro-opc.c b/opcodes/tilepro-opc.c
|
||
--- a/opcodes/tilepro-opc.c
|
||
+++ b/opcodes/tilepro-opc.c
|
||
@@ -10119,7 +10119,7 @@ tilepro_spr_compare (const void *a_ptr, const void *b_ptr)
|
||
const char *
|
||
get_tilepro_spr_name (int num)
|
||
{
|
||
- void *result;
|
||
+ const void *result;
|
||
struct tilepro_spr key;
|
||
|
||
key.number = num;
|
||
@@ -10131,7 +10131,7 @@ get_tilepro_spr_name (int num)
|
||
return NULL;
|
||
|
||
{
|
||
- struct tilepro_spr *result_ptr = (struct tilepro_spr *) result;
|
||
+ const struct tilepro_spr *result_ptr = (const struct tilepro_spr *) result;
|
||
|
||
return result_ptr->name;
|
||
}
|