Skip to content

Commit

Permalink
1. fix kallsym: find kallsyms_marker error, newest oneplus12 (not nol…
Browse files Browse the repository at this point in the history
…y oneplus12) is ok now, 2. try to fix module install os error 22 or 5, I'm not sure
  • Loading branch information
bmax committed Mar 17, 2024
1 parent 0d9a4a9 commit 5beb1d8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kernel/patch/android/userd.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ static void after_execveat(hook_fargs5_t *args, void *udata)
handle_after_execve(&args->local);
}

#define ORIGIN_RC_FILE "/init.environ.rc"
#define ORIGIN_RC_FILE "/system/etc/init/atrace.rc"
#define REPLACE_RC_FILE "/dev/anduser.rc"

static const char user_rc_data[] = { //
Expand Down
44 changes: 43 additions & 1 deletion tools/kallsym.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static int find_num_syms(kallsym_t *info, char *img, int32_t imglen)
return 0;
}

static int find_markers(kallsym_t *info, char *img, int32_t imglen)
static int find_markers_1(kallsym_t *info, char *img, int32_t imglen)
{
int32_t elem_size = get_markers_elem_size(info);
int32_t cand = info->kallsyms_token_table_offset - elem_size;
Expand All @@ -472,6 +472,48 @@ static int find_markers(kallsym_t *info, char *img, int32_t imglen)
return 0;
}

static int find_markers_2(kallsym_t *info, char *img, int32_t imglen)
{
int32_t elem_size = get_markers_elem_size(info);
int32_t cand = info->kallsyms_token_table_offset - KSYM_MIN_MARKER * elem_size;

int64_t marker, last_marker = 0x7fffffff;
int count = 0;
while (cand > 0x1000) {
marker = int_unpack(img + cand, elem_size, info->is_be);
if (last_marker > marker) {
count++;
if (!marker && count > KSYM_MIN_MARKER) break;
} else {
count = 0;
last_marker = 0x7fffffff;
}

last_marker = marker;
cand -= elem_size;
}

if (count < KSYM_MIN_MARKER) {
tools_logw("find kallsyms_markers error\n");
return -1;
}

int32_t marker_end = cand + count * elem_size + elem_size;
info->kallsyms_markers_offset = cand;
info->_marker_num = count;

tools_logi("kallsyms_markers range: [0x%08x, 0x%08x), count: 0x%08x\n", cand, marker_end, count);
return 0;
}

static inline int find_markers(kallsym_t *info, char *img, int32_t imglen)
{
// todo: remove one
int rc = find_markers_1(info, img, imglen);
if (!rc) return rc;
return find_markers_2(info, img, imglen);
}

static int decompress_symbol_name(kallsym_t *info, char *img, int32_t *pos_to_next, char *out_type, char *out_symbol)
{
int32_t pos = *pos_to_next;
Expand Down
3 changes: 2 additions & 1 deletion tools/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,12 @@ int print_image_patch_info(patched_kimg_t *pimg)

if (pimg->banner[strlen(pimg->banner) - 1] != '\n') fprintf(stdout, "\n");
fprintf(stdout, "patched=%s\n", preset ? "true" : "false");
fprintf(stdout, "extra_num=%d\n", pimg->embed_item_num);

if (preset) {
print_preset_info(preset);

fprintf(stdout, "extra_num=%d\n", pimg->embed_item_num);

fprintf(stdout, INFO_EXTRA_SESSION "\n");
fprintf(stdout, "num=%d\n", pimg->embed_item_num);

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define MAJOR 0
#define MINOR 10
#define PATCH 3
#define PATCH 4

0 comments on commit 5beb1d8

Please sign in to comment.