From 64cc03efd2f2517d1f58d6d2c68a9e48240877be Mon Sep 17 00:00:00 2001 From: l00580197 Date: Fri, 7 Jul 2023 14:57:10 +0800 Subject: [PATCH] fix codex for elf_link Signed-off-by: l00580197 --- src/elf_check_elf.c | 2 +- src/elf_hugepage.c | 2 +- src/elf_hugepage.h | 2 +- src/elf_link_common.c | 38 ++++++++++++++++++++++++++------------ src/elf_link_common.h | 2 +- src/elf_link_elf.c | 22 +++++++++++++++++----- 6 files changed, 47 insertions(+), 21 deletions(-) diff --git a/src/elf_check_elf.c b/src/elf_check_elf.c index 68d76dd..e0f3217 100644 --- a/src/elf_check_elf.c +++ b/src/elf_check_elf.c @@ -1,6 +1,6 @@ // Copyright (c) 2023 Huawei Technologies Co.,Ltd. All rights reserved. // -// sysMaster is licensed under Mulan PSL v2. +// sysboost is licensed under Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan // PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/elf_hugepage.c b/src/elf_hugepage.c index e34dd95..ab6021e 100644 --- a/src/elf_hugepage.c +++ b/src/elf_hugepage.c @@ -1,6 +1,6 @@ // Copyright (c) 2023 Huawei Technologies Co.,Ltd. All rights reserved. // -// sysMaster is licensed under Mulan PSL v2. +// sysboost is licensed under Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan // PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/elf_hugepage.h b/src/elf_hugepage.h index ce39bb9..d115af6 100644 --- a/src/elf_hugepage.h +++ b/src/elf_hugepage.h @@ -1,6 +1,6 @@ // Copyright (c) 2023 Huawei Technologies Co.,Ltd. All rights reserved. // -// sysMaster is licensed under Mulan PSL v2. +// sysboost is licensed under Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan // PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/elf_link_common.c b/src/elf_link_common.c index f482732..0632b54 100644 --- a/src/elf_link_common.c +++ b/src/elf_link_common.c @@ -1,6 +1,6 @@ // Copyright (c) 2023 Huawei Technologies Co.,Ltd. All rights reserved. // -// sysMaster is licensed under Mulan PSL v2. +// sysboost is licensed under Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan // PSL v2. // You may obtain a copy of Mulan PSL v2 at: @@ -29,6 +29,15 @@ #include #include +#define INDEX_ZERO 0 +#define INDEX_ONE 1 +#define INDEX_TWO 2 +#define INDEX_THREE 3 +#define INDEX_FOUR 4 +#define INDEX_FIVE 5 +#define INDEX_SIX 6 +#define INDEX_SEVEN 7 + static char *special_dynsyms[] = { "__pointer_chk_guard", "_ITM_deregisterTMCloneTable", @@ -618,17 +627,22 @@ static char *get_ifunc_nice_name(char *sym_name) // ignore prefix of __memchr __strlen __GI_strlen __GI___strnlen __libc_memmove // direct cmp char for performace, compile will optimize branch - if ((sym_name[0] == '_') && (sym_name[1] == '_') && (sym_name[2] == 'G') && (sym_name[3] == 'I') && (sym_name[4] == '_') && (sym_name[5] == '_') && (sym_name[6] == '_')) { - return sym_name + 7; - } - if ((sym_name[0] == '_') && (sym_name[1] == '_') && (sym_name[2] == 'G') && (sym_name[3] == 'I') && (sym_name[4] == '_')) { - return sym_name + 5; - } - if ((sym_name[0] == '_') && (sym_name[1] == '_') && (sym_name[2] == 'l') && (sym_name[3] == 'i') && (sym_name[4] == 'b') && (sym_name[5] == 'c') && (sym_name[6] == '_')) { - return sym_name + 7; - } - if ((sym_name[0] == '_') && (sym_name[1] == '_')) { - return sym_name + 2; + if ((sym_name[INDEX_ZERO] == '_') && (sym_name[INDEX_ONE] == '_') && (sym_name[INDEX_TWO] == 'G') + && (sym_name[INDEX_THREE] == 'I') && (sym_name[INDEX_FOUR] == '_') + && (sym_name[INDEX_FIVE] == '_') && (sym_name[INDEX_SIX] == '_')) { + return sym_name + INDEX_SEVEN; + } + if ((sym_name[INDEX_ZERO] == '_') && (sym_name[INDEX_ONE] == '_') && (sym_name[INDEX_TWO] == 'G') + && (sym_name[INDEX_THREE] == 'I') && (sym_name[INDEX_FOUR] == '_')) { + return sym_name + INDEX_FIVE; + } + if ((sym_name[INDEX_ZERO] == '_') && (sym_name[INDEX_ONE] == '_') && (sym_name[INDEX_TWO] == 'l') + && (sym_name[INDEX_THREE] == 'i') && (sym_name[INDEX_FOUR] == 'b') + && (sym_name[INDEX_FIVE] == 'c') && (sym_name[INDEX_SIX] == '_')) { + return sym_name + INDEX_SEVEN; + } + if ((sym_name[INDEX_ZERO] == '_') && (sym_name[INDEX_ONE] == '_')) { + return sym_name + INDEX_TWO; } return sym_name; } diff --git a/src/elf_link_common.h b/src/elf_link_common.h index 98585a1..cc37979 100644 --- a/src/elf_link_common.h +++ b/src/elf_link_common.h @@ -1,6 +1,6 @@ // Copyright (c) 2023 Huawei Technologies Co.,Ltd. All rights reserved. // -// sysMaster is licensed under Mulan PSL v2. +// sysboost is licensed under Mulan PSL v2. // You can use this software according to the terms and conditions of the Mulan // PSL v2. // You may obtain a copy of Mulan PSL v2 at: diff --git a/src/elf_link_elf.c b/src/elf_link_elf.c index ea215b9..33912c1 100644 --- a/src/elf_link_elf.c +++ b/src/elf_link_elf.c @@ -1,4 +1,15 @@ -/* SPDX-License-Identifier: MulanPSL-2.0 */ +// Copyright (c) 2023 Huawei Technologies Co.,Ltd. All rights reserved. +// +// sysboost is licensed under Mulan PSL v2. +// You can use this software according to the terms and conditions of the Mulan +// PSL v2. +// You may obtain a copy of Mulan PSL v2 at: +// http://license.coscl.org.cn/MulanPSL2 +// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +// See the Mulan PSL v2 for more details. + #include #include #include @@ -10,14 +21,15 @@ #include #include +#include +#include +#include "si_array.h" + #include "elf_check_elf.h" #include "elf_hugepage.h" #include "elf_link_elf.h" #include "elf_relocation.h" #include "elf_write_elf.h" -#include "si_array.h" -#include -#include #ifdef __aarch64__ #define LD_SO_PATH "/lib/ld-linux-aarch64.so.1" @@ -25,7 +37,7 @@ #define LD_SO_PATH "/lib64/ld-linux-x86-64.so.2" #endif -elf_link_t *elf_link_new() +elf_link_t *elf_link_new(void) { elf_link_t *elf_link = NULL; -- Gitee