代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/binutils 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From a74d8d8d9f7f05666ff34d27ac22cecb61c88a4b Mon Sep 17 00:00:00 2001
From: Xing Li <[email protected]>
Date: Thu, 5 Jan 2023 15:49:52 +0800
Subject: [PATCH] Fix gas bug: 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
Signed-off-by: Xing Li <[email protected]>
---
gas/config/tc-loongarch.c | 7 +++++--
include/opcode/loongarch.h | 4 ++--
opcodes/loongarch-coder.c | 15 ++++++++++-----
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index 26ee3f1a..9ab015a3 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -921,7 +921,8 @@ assember_macro_helper (const char * const args[], void *context_ptr)
}
while (0);
- ret = loongarch_expand_macro (insns_buf, arg_strs, NULL, NULL);
+ ret = loongarch_expand_macro (insns_buf, arg_strs, NULL, NULL,
+ sizeof (args_buf));
}
return ret;
}
@@ -932,6 +933,7 @@ static void
loongarch_assemble_INSNs (char *str)
{
char *rest;
+ size_t len_str = strlen(str);
for (rest = str; *rest != ';' && *rest != '\0'; rest++);
if (*rest == ';')
@@ -971,7 +973,8 @@ loongarch_assemble_INSNs (char *str)
{
char *c_str =
loongarch_expand_macro (the_one.insn->macro,
- the_one.arg_strs, assember_macro_helper, &the_one);
+ the_one.arg_strs, assember_macro_helper,
+ &the_one, len_str);
loongarch_assemble_INSNs (c_str);
free (c_str);
}
diff --git a/include/opcode/loongarch.h b/include/opcode/loongarch.h
index 47a9d94b..fc0be236 100644
--- a/include/opcode/loongarch.h
+++ b/include/opcode/loongarch.h
@@ -151,12 +151,12 @@ loongarch_expand_macro_with_format_map (const char *format, const char *macro,
char * (*helper) (
const char * const arg_strs[],
void *context),
- void *context);
+ void *context, size_t len_str);
extern 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);
extern size_t
loongarch_bits_imm_needed (int64_t imm, int si);
diff --git a/opcodes/loongarch-coder.c b/opcodes/loongarch-coder.c
index 399af4f0..aa6a2388 100644
--- a/opcodes/loongarch-coder.c
+++ b/opcodes/loongarch-coder.c
@@ -352,13 +352,18 @@ loongarch_expand_macro_with_format_map (const char *format, const char *macro,
char * (*helper) (
const char * const arg_strs[],
void *context),
- 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(1000 + 6 * len_str);
if (format)
loongarch_parse_format (format, esc1s, esc2s, bit_fields);
@@ -396,17 +401,17 @@ loongarch_expand_macro_with_format_map (const char *format, const char *macro,
*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);
+ (NULL, macro, arg_strs, I, helper, context, len_str);
}
size_t
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。