From: SangYoun Kwak Date: Mon, 27 May 2024 06:34:04 +0000 (+0900) Subject: Remove unused/useless codes/files X-Git-Tag: accepted/tizen/unified/20240603.161048~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=25e812bbdd1f1f0833dca604595ea2e1ca8b05e0;p=platform%2Fhal%2Fbackend%2Frootstrap.git Remove unused/useless codes/files Unused / unnecessary / useless codes from postlinker source code are removed. They don't affect the original functionalities of postlinker. Also, postlinker is built during the gbs build, the pre-built binaries (postlinker and postlinker_64) can be removed. Change-Id: If5567459ceb7461bc7072145997aec7eb2ab62d4 Signed-off-by: SangYoun Kwak --- diff --git a/script/CMakeLists.txt b/script/CMakeLists.txt index 9ff50c8..4931b77 100644 --- a/script/CMakeLists.txt +++ b/script/CMakeLists.txt @@ -1,3 +1,6 @@ PROJECT(postlinker C) + ADD_EXECUTABLE(${PROJECT_NAME} postlinker.c) +ADD_EXECUTABLE(${PROJECT_NAME}_64 postlinker_64.c) + INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /) diff --git a/script/postlinker b/script/postlinker deleted file mode 100755 index 3baab7c..0000000 Binary files a/script/postlinker and /dev/null differ diff --git a/script/postlinker.c b/script/postlinker.c index 99fdc5e..b7a5ee2 100755 --- a/script/postlinker.c +++ b/script/postlinker.c @@ -90,15 +90,12 @@ int PostLinker(char *fileName) int totalSymbolCnt; int pos; - FILE *fp; - int done; - int done2; + FILE *fp = NULL; + int done = 0; int symbolOff = 0; int symEntrySize = 0; int hashOff = 0; - int Len; - fp = NULL; fp = fopen(fileName, "r+"); if (fp == NULL) { @@ -150,7 +147,6 @@ int PostLinker(char *fileName) for (int i = 0; DynEntries[i].d_tag != DT_NULL; ++i) { switch (DynEntries[i].d_tag) { case DT_NEEDED: - done = DT_GARBAGE; DynEntries[i].d_tag = DT_GARBAGE; break; case DT_SYMTAB: @@ -179,31 +175,22 @@ int PostLinker(char *fileName) if (!fread(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp)) printf("error[%s] : file read \n", fileName); - done2 = 0; for (int i = 1; i < totalSymbolCnt; ++i) { if (pMapSymbolTable[i].st_shndx == SHN_UNDEF && pMapSymbolTable[i].st_value == 0 && ((pMapSymbolTable[i].st_info & 0xF) == STT_FUNC || (pMapSymbolTable[i].st_info & 0xF) == STT_OBJECT || (pMapSymbolTable[i].st_info & 0xF) == STT_NOTYPE)) { - if (pMapSymbolTable[i].st_name == 0) - done2 = 0; - pMapSymbolTable[i].st_name = 0; pMapSymbolTable[i].st_value = 0; pMapSymbolTable[i].st_size = 0; pMapSymbolTable[i].st_info = 0; pMapSymbolTable[i].st_shndx = 0; - done2 = 1; + done = 1; } } if (!done) { - //printf("DT_NEEDED field is already removed : %s\n", fileName); - // return 1; - } - - if (!done2) { printf("Undefined symbols are already removed : %s\n", fileName); return 1; } diff --git a/script/postlinker_64 b/script/postlinker_64 deleted file mode 100755 index ea1328b..0000000 Binary files a/script/postlinker_64 and /dev/null differ diff --git a/script/postlinker_64.c b/script/postlinker_64.c index 2df08ac..994cae7 100755 --- a/script/postlinker_64.c +++ b/script/postlinker_64.c @@ -16,15 +16,12 @@ int PostLinker64(char *fileName) int totalSymbolCnt; int pos; - FILE *fp; - int done; - int done2; + FILE *fp = NULL; + int done = 0; int symbolOff = 0; int symEntrySize = 0; int hashOff = 0; - int Len; - fp = NULL; fp = fopen(fileName, "r+"); if (fp == NULL) { @@ -80,7 +77,6 @@ int PostLinker64(char *fileName) for (int i = 0; DynEntries[i].d_tag != DT_NULL; ++i) { switch (DynEntries[i].d_tag) { case DT_NEEDED: - done = DT_GARBAGE; DynEntries[i].d_tag = DT_GARBAGE; break; case DT_SYMTAB: @@ -109,26 +105,22 @@ int PostLinker64(char *fileName) if (!fread(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp)) printf("error[%s] : file read \n", fileName); - done2 = 0; for (int i = 1; i < totalSymbolCnt; ++i) { if (pMapSymbolTable[i].st_shndx == SHN_UNDEF && pMapSymbolTable[i].st_value == 0 && ((pMapSymbolTable[i].st_info & 0xF) == STT_FUNC || (pMapSymbolTable[i].st_info & 0xF) == STT_OBJECT || (pMapSymbolTable[i].st_info & 0xF) == STT_NOTYPE)) { - if (pMapSymbolTable[i].st_name == 0) - done2 = 0; - pMapSymbolTable[i].st_name = 0; pMapSymbolTable[i].st_value = 0; pMapSymbolTable[i].st_size = 0; pMapSymbolTable[i].st_info = 0; pMapSymbolTable[i].st_shndx = 0; - done2 = 1; + done = 1; } } - if (!done2) { + if (!done) { printf("Undefined symbols are already removed : %s\n", fileName); return 1; }