Add related code which make libcareplus can run basic demo on aarch64. Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
150 lines
4.8 KiB
Diff
150 lines
4.8 KiB
Diff
From 3ecebe9ea858d5502af5f5cd79141e4546ae3fe8 Mon Sep 17 00:00:00 2001
|
|
From: Jiajie Li <lijiajie11@huawei.com>
|
|
Date: Mon, 12 Oct 2020 13:58:58 +0800
|
|
Subject: [PATCH 30/89] kpatch_parse: Split function is_function_start
|
|
|
|
The function is_function_start is arch related, so make two
|
|
separate definations in arch/x86/arch_parse.c and arch/aarch64/arch_parse.c
|
|
|
|
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
|
|
Signed-off-by: Ying Fang <fangying1@huawei.com>
|
|
---
|
|
src/arch/aarch64/arch_parse.c | 32 ++++++++++++++++++++++++++++++++
|
|
src/arch/x86/arch_parse.c | 32 ++++++++++++++++++++++++++++++++
|
|
src/kpatch_parse.c | 33 ---------------------------------
|
|
3 files changed, 64 insertions(+), 33 deletions(-)
|
|
|
|
diff --git a/src/arch/aarch64/arch_parse.c b/src/arch/aarch64/arch_parse.c
|
|
index fea09f6..e0f0c8b 100644
|
|
--- a/src/arch/aarch64/arch_parse.c
|
|
+++ b/src/arch/aarch64/arch_parse.c
|
|
@@ -4,6 +4,38 @@
|
|
#include "include/kpatch_parse.h"
|
|
#include "include/kpatch_flags.h"
|
|
|
|
+int is_function_start(struct kp_file *f, int l, kpstr_t *nm)
|
|
+{
|
|
+ char *s;
|
|
+ kpstr_t nm2, attr;
|
|
+ int l0 = l, func = 0;
|
|
+
|
|
+ kpstrset(nm, "", 0);
|
|
+ for (; l < f->nr_lines; l++) {
|
|
+ if (l != l0 && cline(f, l)[0] == '\0')
|
|
+ continue;
|
|
+ if ((is_sect_cmd(f, l) && is_code_sect(csect(f, l))) ||
|
|
+ ctype(f, l) == DIRECTIVE_ALIGN)
|
|
+ continue;
|
|
+ get_type_args(cline(f, l), &nm2, &attr);
|
|
+ if ((ctype(f, l) == DIRECTIVE_WEAK && l0 != l) ||
|
|
+ ctype(f, l) == DIRECTIVE_GLOBL || ctype(f, l) == DIRECTIVE_HIDDEN ||
|
|
+ ctype(f, l) == DIRECTIVE_PROTECTED || ctype(f, l) == DIRECTIVE_INTERNAL ||
|
|
+ (ctype(f, l) == DIRECTIVE_TYPE && !kpstrcmpz(&attr, "%function"))) {
|
|
+ s = cline(f, l);
|
|
+ get_token(&s, &nm2); /* skip command */
|
|
+ get_token(&s, &nm2);
|
|
+ if (nm->l && kpstrcmp(nm, &nm2)) /* verify name matches in all .weak/.globl/.type commands */
|
|
+ return 0;
|
|
+ *nm = nm2;
|
|
+ func = func ? 1 : ctype(f, l) == DIRECTIVE_TYPE;
|
|
+ continue;
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
+ return func;
|
|
+}
|
|
+
|
|
int is_data_def(char *s, int type)
|
|
{
|
|
kpstr_t t;
|
|
diff --git a/src/arch/x86/arch_parse.c b/src/arch/x86/arch_parse.c
|
|
index 81edaf8..c51c49b 100644
|
|
--- a/src/arch/x86/arch_parse.c
|
|
+++ b/src/arch/x86/arch_parse.c
|
|
@@ -4,6 +4,38 @@
|
|
#include "include/kpatch_parse.h"
|
|
#include "include/kpatch_flags.h"
|
|
|
|
+int is_function_start(struct kp_file *f, int l, kpstr_t *nm)
|
|
+{
|
|
+ char *s;
|
|
+ kpstr_t nm2, attr;
|
|
+ int l0 = l, func = 0;
|
|
+
|
|
+ kpstrset(nm, "", 0);
|
|
+ for (; l < f->nr_lines; l++) {
|
|
+ if (l != l0 && cline(f, l)[0] == '\0')
|
|
+ continue;
|
|
+ if ((is_sect_cmd(f, l) && is_code_sect(csect(f, l))) ||
|
|
+ ctype(f, l) == DIRECTIVE_ALIGN)
|
|
+ continue;
|
|
+ get_type_args(cline(f, l), &nm2, &attr);
|
|
+ if ((ctype(f, l) == DIRECTIVE_WEAK && l0 != l) ||
|
|
+ ctype(f, l) == DIRECTIVE_GLOBL || ctype(f, l) == DIRECTIVE_HIDDEN ||
|
|
+ ctype(f, l) == DIRECTIVE_PROTECTED || ctype(f, l) == DIRECTIVE_INTERNAL ||
|
|
+ (ctype(f, l) == DIRECTIVE_TYPE && !kpstrcmpz(&attr, "@function"))) {
|
|
+ s = cline(f, l);
|
|
+ get_token(&s, &nm2); /* skip command */
|
|
+ get_token(&s, &nm2);
|
|
+ if (nm->l && kpstrcmp(nm, &nm2)) /* verify name matches in all .weak/.globl/.type commands */
|
|
+ return 0;
|
|
+ *nm = nm2;
|
|
+ func = func ? 1 : ctype(f, l) == DIRECTIVE_TYPE;
|
|
+ continue;
|
|
+ }
|
|
+ break;
|
|
+ }
|
|
+ return func;
|
|
+}
|
|
+
|
|
int is_data_def(char *s, int type)
|
|
{
|
|
kpstr_t t;
|
|
diff --git a/src/kpatch_parse.c b/src/kpatch_parse.c
|
|
index f486b55..3df658d 100644
|
|
--- a/src/kpatch_parse.c
|
|
+++ b/src/kpatch_parse.c
|
|
@@ -625,39 +625,6 @@ void init_sections(struct kp_file *f)
|
|
}
|
|
|
|
/* ----------------------------------------- code block boundaries detection ---------------------------------------- */
|
|
-
|
|
-int is_function_start(struct kp_file *f, int l, kpstr_t *nm)
|
|
-{
|
|
- char *s;
|
|
- kpstr_t nm2, attr;
|
|
- int l0 = l, func = 0;
|
|
-
|
|
- kpstrset(nm, "", 0);
|
|
- for (; l < f->nr_lines; l++) {
|
|
- if (l != l0 && cline(f, l)[0] == '\0')
|
|
- continue;
|
|
- if ((is_sect_cmd(f, l) && is_code_sect(csect(f, l))) ||
|
|
- ctype(f, l) == DIRECTIVE_ALIGN)
|
|
- continue;
|
|
- get_type_args(cline(f, l), &nm2, &attr);
|
|
- if ((ctype(f, l) == DIRECTIVE_WEAK && l0 != l) ||
|
|
- ctype(f, l) == DIRECTIVE_GLOBL || ctype(f, l) == DIRECTIVE_HIDDEN ||
|
|
- ctype(f, l) == DIRECTIVE_PROTECTED || ctype(f, l) == DIRECTIVE_INTERNAL ||
|
|
- (ctype(f, l) == DIRECTIVE_TYPE && !kpstrcmpz(&attr, "@function"))) {
|
|
- s = cline(f, l);
|
|
- get_token(&s, &nm2); /* skip command */
|
|
- get_token(&s, &nm2);
|
|
- if (nm->l && kpstrcmp(nm, &nm2)) /* verify name matches in all .weak/.globl/.type commands */
|
|
- return 0;
|
|
- *nm = nm2;
|
|
- func = func ? 1 : ctype(f, l) == DIRECTIVE_TYPE;
|
|
- continue;
|
|
- }
|
|
- break;
|
|
- }
|
|
- return func;
|
|
-}
|
|
-
|
|
int is_function_end(struct kp_file *f, int l, kpstr_t *nm)
|
|
{
|
|
/* Functions should always end by .size directive. Previously used to detect .LFe labels, but they are not generated w/o frame pointers */
|
|
--
|
|
2.23.0
|
|
|