aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorliuzhensong <liuzhensong@loongson.cn>2022-03-20 09:18:00 +0800
committerliuzhensong <liuzhensong@loongson.cn>2022-03-20 09:37:12 +0800
commit5fb13d7ef45088d8c2b89a3b4b22c36a0e3a5715 (patch)
tree8c3e44bf1f8f1d03b64c9b24ef488d369c2371f3 /opcodes
parent748594bc07f39fda35aba5f46d6e058b42c9c49d (diff)
downloadgdb-5fb13d7ef45088d8c2b89a3b4b22c36a0e3a5715.zip
gdb-5fb13d7ef45088d8c2b89a3b4b22c36a0e3a5715.tar.gz
gdb-5fb13d7ef45088d8c2b89a3b4b22c36a0e3a5715.tar.bz2
gas:LoongArch: Fix segment error in compilation due to too long symbol name.
Change "char buffer[8192];" into "char *buffer = (char *) malloc(1000 + 6 * len_str);" in function loongarch_expand_macro_with_format_map. gas/ * config/tc-loongarch.c include/ * opcode/loongarch.h opcodes/ * loongarch-coder.c
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/loongarch-coder.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/opcodes/loongarch-coder.c b/opcodes/loongarch-coder.c
index c957b95..f5e10b9 100644
--- a/opcodes/loongarch-coder.c
+++ b/opcodes/loongarch-coder.c
@@ -378,13 +378,18 @@ char *
loongarch_expand_macro_with_format_map (
const char *format, const char *macro, const char *const arg_strs[],
const char *(*map) (char esc1, char esc2, const char *arg),
- char *(*helper) (const char *const arg_strs[], void *context), void *context)
+ char *(*helper) (const char *const arg_strs[], void *context), void *context,
+ size_t len_str)
{
char esc1s[MAX_ARG_NUM_PLUS_2 - 1], esc2s[MAX_ARG_NUM_PLUS_2 - 1];
const char *bit_fields[MAX_ARG_NUM_PLUS_2 - 1];
const char *src;
char *dest;
- char buffer[8192];
+
+ /* The expanded macro character length does not exceed 1000, and number of
+ label is 6 at most in the expanded macro. The len_str is the length of
+ str. */
+ char *buffer =(char *) malloc(1024 + 6 * len_str);
if (format)
loongarch_parse_format (format, esc1s, esc2s, bit_fields);
@@ -422,17 +427,17 @@ loongarch_expand_macro_with_format_map (
*dest++ = *src++;
*dest = '\0';
- return strdup (buffer);
+ return buffer;
}
char *
loongarch_expand_macro (const char *macro, const char *const arg_strs[],
char *(*helper) (const char *const arg_strs[],
void *context),
- void *context)
+ void *context, size_t len_str)
{
return loongarch_expand_macro_with_format_map (NULL, macro, arg_strs, I,
- helper, context);
+ helper, context, len_str);
}
size_t