typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
-typedef int int32_t;
+typedef int int32_t;
typedef uint16_t Elf32_Half;
typedef uint32_t Elf32_Word;
-typedef int32_t Elf32_Sword;
+typedef int32_t Elf32_Sword;
typedef uint32_t Elf32_Addr;
typedef uint32_t Elf32_Off;
typedef uint16_t Elf32_Section;
#define EI_NIDENT (16)
-typedef struct
-{
- unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
- Elf32_Half e_type; /* Object file type */
- Elf32_Half e_machine; /* Architecture */
- Elf32_Word e_version; /* Object file version */
- Elf32_Addr e_entry; /* Entry point virtual address */
- Elf32_Off e_phoff; /* Program header table file offset */
- Elf32_Off e_shoff; /* Section header table file offset */
- Elf32_Word e_flags; /* Processor-specific flags */
- Elf32_Half e_ehsize; /* ELF header size in bytes */
- Elf32_Half e_phentsize; /* Program header table entry size */
- Elf32_Half e_phnum; /* Program header table entry count */
- Elf32_Half e_shentsize; /* Section header table entry size */
- Elf32_Half e_shnum; /* Section header table entry count */
- Elf32_Half e_shstrndx; /* Section header string table index */
+typedef struct {
+ unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
+ Elf32_Half e_type; /* Object file type */
+ Elf32_Half e_machine; /* Architecture */
+ Elf32_Word e_version; /* Object file version */
+ Elf32_Addr e_entry; /* Entry point virtual address */
+ Elf32_Off e_phoff; /* Program header table file offset */
+ Elf32_Off e_shoff; /* Section header table file offset */
+ Elf32_Word e_flags; /* Processor-specific flags */
+ Elf32_Half e_ehsize; /* ELF header size in bytes */
+ Elf32_Half e_phentsize; /* Program header table entry size */
+ Elf32_Half e_phnum; /* Program header table entry count */
+ Elf32_Half e_shentsize; /* Section header table entry size */
+ Elf32_Half e_shnum; /* Section header table entry count */
+ Elf32_Half e_shstrndx; /* Section header string table index */
} Elf32_Ehdr;
-/* Program segment header. */
-
-typedef struct
-{
- Elf32_Word p_type; /* Segment type */
- Elf32_Off p_offset; /* Segment file offset */
- Elf32_Addr p_vaddr; /* Segment virtual address */
- Elf32_Addr p_paddr; /* Segment physical address */
- Elf32_Word p_filesz; /* Segment size in file */
- Elf32_Word p_memsz; /* Segment size in memory */
- Elf32_Word p_flags; /* Segment flags */
- Elf32_Word p_align; /* Segment alignment */
+/* Program segment header */
+typedef struct {
+ Elf32_Word p_type; /* Segment type */
+ Elf32_Off p_offset; /* Segment file offset */
+ Elf32_Addr p_vaddr; /* Segment virtual address */
+ Elf32_Addr p_paddr; /* Segment physical address */
+ Elf32_Word p_filesz; /* Segment size in file */
+ Elf32_Word p_memsz; /* Segment size in memory */
+ Elf32_Word p_flags; /* Segment flags */
+ Elf32_Word p_align; /* Segment alignment */
} Elf32_Phdr;
-/* Dynamic section entry. */
-
-typedef struct
-{
- Elf32_Sword d_tag; /* Dynamic entry type */
- union
- {
- Elf32_Word d_val; /* Integer value */
- Elf32_Addr d_ptr; /* Address value */
- } d_un;
+/* Dynamic section entry */
+typedef struct {
+ Elf32_Sword d_tag; /* Dynamic entry type */
+ union {
+ Elf32_Word d_val; /* Integer value */
+ Elf32_Addr d_ptr; /* Address value */
+ } d_un;
} Elf32_Dyn;
-/* Symbol table entry. */
-
-typedef struct
-{
- Elf32_Word st_name; /* Symbol name (string tbl index) */
- Elf32_Addr st_value; /* Symbol value */
- Elf32_Word st_size; /* Symbol size */
- unsigned char st_info; /* Symbol type and binding */
- unsigned char st_other; /* No defined meaning, 0 */
- Elf32_Section st_shndx; /* Section index */
+/* Symbol table entry */
+typedef struct {
+ Elf32_Word st_name; /* Symbol name (string tbl index) */
+ Elf32_Addr st_value; /* Symbol value */
+ Elf32_Word st_size; /* Symbol size */
+ unsigned char st_info; /* Symbol type and binding */
+ unsigned char st_other; /* No defined meaning, 0 */
+ Elf32_Section st_shndx; /* Section index */
} Elf32_Sym;
#define PT_DYNAMIC 2 /* Dynamic linking information */
#define DT_SYMTAB 6 /* Address of symbol table */
#define DT_SYMENT 11 /* Size of one symbol table entry */
#define DT_GARBAGE 0xffffffff /* End of processor-specific */
-#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
+#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
-/* Special section index. */
+/* Special section index */
+#define SHN_UNDEF 0 /* No section, undefined symbol */
+#define STT_NOTYPE 0 /* Symbol type is unspecified */
+#define STT_OBJECT 1 /* Symbol is a data object */
+#define STT_FUNC 2 /* Symbol is a code object */
-#define SHN_UNDEF 0 /* No section, undefined symbol. */
-#define STT_NOTYPE 0 /* Symbol type is unspecified */
-#define STT_OBJECT 1 /* Symbol is a data object */
-#define STT_FUNC 2 /* Symbol is a code object */
-
-int PostLinker(char* fileName);
-
-int main(int argc, char* argv[])
-{
- int i;
- for(i=1; i<argc; i++)
- PostLinker(argv[i]);
-}
-int PostLinker(char* fileName)
+int PostLinker(char *fileName)
{
- Elf32_Ehdr elfHeader;
- Elf32_Phdr *pSegmentEntries;
- Elf32_Dyn *DynEntries;
- Elf32_Sym *pMapSymbolTable;
- int totalSymbolCnt;
- int i;
- int pos;
-
- FILE *fp;
- int done, done2;
- int symbolOff = 0;
- int symEntrySize = 0;
- int hashOff = 0;
+ Elf32_Ehdr elfHeader;
+ Elf32_Phdr *pSegmentEntries;
+ Elf32_Dyn *DynEntries;
+ Elf32_Sym *pMapSymbolTable;
+ int totalSymbolCnt;
+ int pos;
+
+ FILE *fp;
+ int done;
+ int done2;
+ int symbolOff = 0;
+ int symEntrySize = 0;
+ int hashOff = 0;
int Len;
fp = NULL;
fp = fopen(fileName, "r+");
- if (fp == NULL)
- {
+ if (fp == NULL) {
printf("error[%s] : file open\n", fileName);
exit(EXIT_FAILURE);
}
/* Get ELF Header Information */
- if(!fread((void*)&elfHeader, sizeof(Elf32_Ehdr), 1, fp))
- {
+ if (!fread((void*)&elfHeader, sizeof(Elf32_Ehdr), 1, fp)) {
printf("error[%s] : file read <header>\n", fileName);
exit(EXIT_FAILURE);
}
- if(*(int*)(elfHeader.e_ident) != ELF_FORMAT)
- {
+ if (*(int*)(elfHeader.e_ident) != ELF_FORMAT) {
printf("error[%s] : no ELF format\n", fileName);
exit(EXIT_FAILURE);
}
- pSegmentEntries = NULL;
- DynEntries = NULL;
+ pSegmentEntries = NULL;
+ DynEntries = NULL;
/* Memory Allocation for Segment and Section entries */
pSegmentEntries = (Elf32_Phdr *)malloc(elfHeader.e_phentsize * elfHeader.e_phnum);
/* Get Segment Header Information using ELF Header */
fseek(fp, elfHeader.e_phoff, SEEK_SET);
- if(!fread(pSegmentEntries, elfHeader.e_phentsize * elfHeader.e_phnum, 1, fp))
- printf("error[%s] : file read <pSegmentEntries>\n", fileName );
+ if (!fread(pSegmentEntries, elfHeader.e_phentsize * elfHeader.e_phnum, 1, fp))
+ printf("error[%s] : file read <pSegmentEntries>\n", fileName);
/* Get Dynamic segment Information using Segment Header */
- for(i=0; i<elfHeader.e_phnum; i++)
- {
- if(pSegmentEntries[i].p_type == PT_DYNAMIC)
- {
+ for (int i = 0; i < elfHeader.e_phnum; ++i) {
+ if (pSegmentEntries[i].p_type == PT_DYNAMIC) {
fseek(fp, pSegmentEntries[i].p_offset, SEEK_SET);
DynEntries = (Elf32_Dyn*)malloc(pSegmentEntries[i].p_memsz);
- if(DynEntries == NULL)
- {
+
+ if (DynEntries == NULL) {
printf("error[%s] : memory allocation <DynEntries>\n", fileName);
exit(EXIT_FAILURE);
}
- if(!fread(DynEntries, pSegmentEntries[i].p_memsz, 1, fp))
- {
+
+ if (!fread(DynEntries, pSegmentEntries[i].p_memsz, 1, fp)) {
printf("error[%s] : file read <DynEntries>\n", fileName);
exit(EXIT_FAILURE);
}
}
}
- for(i=0; DynEntries[i].d_tag != DT_NULL ; i++)
- {
- switch(DynEntries[i].d_tag)
- {
+ 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: symbolOff = DynEntries[i].d_un.d_val; break;
- case DT_SYMENT: symEntrySize = DynEntries[i].d_un.d_val; break;
- case DT_HASH: hashOff = DynEntries[i].d_un.d_val; break;
- case DT_GNU_HASH: hashOff = DynEntries[i].d_un.d_val; break;
- default: break;
+ case DT_SYMTAB:
+ symbolOff = DynEntries[i].d_un.d_val;
+ break;
+ case DT_SYMENT:
+ symEntrySize = DynEntries[i].d_un.d_val;
+ break;
+ case DT_HASH:
+ hashOff = DynEntries[i].d_un.d_val;
+ break;
+ case DT_GNU_HASH:
+ hashOff = DynEntries[i].d_un.d_val;
+ break;
+ default:
+ break;
}
}
- fseek(fp, hashOff+4,SEEK_SET);
- if(!fread(&totalSymbolCnt, sizeof(Elf32_Word), 1, fp))
+ fseek(fp, hashOff + 4, SEEK_SET);
+ if (!fread(&totalSymbolCnt, sizeof(Elf32_Word), 1, fp))
printf("error[%s] : file read <symEntryCnt>\n", fileName);
pMapSymbolTable = (Elf32_Sym*)malloc(totalSymbolCnt * sizeof(Elf32_Sym));
- fseek(fp, symbolOff,SEEK_SET);
- if(!fread(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp))
+ fseek(fp, symbolOff, SEEK_SET);
+ if (!fread(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp))
printf("error[%s] : file read <pMapSymbolTable>\n", fileName);
done2 = 0;
- for(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;
- }
+ 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;
}
}
- if (!done)
- {
-// printf("DT_NEEDED field is already removed : %s\n", fileName);
-// return 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);
+
+ if (!done2) {
+ printf("Undefined symbols are already removed : %s\n", fileName);
return 1;
}
fseek(fp, pSegmentEntries[pos].p_offset, SEEK_SET);
- if(!fwrite(DynEntries, pSegmentEntries[pos].p_memsz, 1, fp))
- {
+ if (!fwrite(DynEntries, pSegmentEntries[pos].p_memsz, 1, fp)) {
printf("error[%s] : file write <DynEntries>\n", fileName);
exit(EXIT_FAILURE);
}
- fseek(fp, symbolOff,SEEK_SET);
- if(!fwrite(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp))
- {
+ fseek(fp, symbolOff, SEEK_SET);
+ if (!fwrite(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp)) {
printf("error[%s] : file write <pMapSymbolTable>\n", fileName);
exit(EXIT_FAILURE);
}
fclose(fp);
- printf("Success : %s\n", fileName);
+ printf("Success : %s\n", fileName);
+
return 1;
}
+
+int main(int argc, char **argv)
+{
+ for (int i = 1; i < argc; ++i)
+ PostLinker(argv[i]);
+ return 0;
+}
#include <elf.h>
#define ELF_FORMAT 0x464c457f
-#define DT_GARBAGE 0xffffffff /* End of processor-specific */
+#define DT_GARBAGE 0xffffffff /* End of processor-specific */
-int PostLinker64(char* fileName);
-
-int main(int argc, char* argv[])
+int PostLinker64(char *fileName)
{
- int i;
- for(i=1; i<argc; i++)
- PostLinker64(argv[i]);
+ Elf64_Ehdr elfHeader;
+ Elf64_Phdr *pSegmentEntries;
+ Elf64_Dyn *DynEntries;
+ Elf64_Sym *pMapSymbolTable;
+ int totalSymbolCnt;
+ int pos;
+
+ FILE *fp;
+ int done;
+ int done2;
+ int symbolOff = 0;
+ int symEntrySize = 0;
+ int hashOff = 0;
+ int Len;
+
+ fp = NULL;
+ fp = fopen(fileName, "r+");
+
+ if (fp == NULL) {
+ printf("error[%s] : file open\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+
+ /* Get ELF Header Information */
+ if (!fread((void*)&elfHeader, sizeof(Elf64_Ehdr), 1, fp)) {
+ printf("error[%s] : file read <header>\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+
+ if (*(int*)(elfHeader.e_ident) != ELF_FORMAT) {
+ printf("error[%s] : no ELF format\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+
+ if (elfHeader.e_ident[EI_CLASS] != 2) {
+ printf("error[%s] : EI_CLASS is not 64-bit format\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+
+ pSegmentEntries = NULL;
+ DynEntries = NULL;
+
+ /* Memory Allocation for Segment and Section entries */
+ pSegmentEntries = (Elf64_Phdr *)malloc(elfHeader.e_phentsize * elfHeader.e_phnum);
+
+ /* Get Segment Header Information using ELF Header */
+ fseek(fp, elfHeader.e_phoff, SEEK_SET);
+ if (!fread(pSegmentEntries, elfHeader.e_phentsize * elfHeader.e_phnum, 1, fp))
+ printf("error[%s] : file read <pSegmentEntries>\n", fileName);
+
+ /* Get Dynamic segment Information using Segment Header */
+ for (int i = 0; i < elfHeader.e_phnum; ++i) {
+ if (pSegmentEntries[i].p_type == PT_DYNAMIC) {
+ fseek(fp, pSegmentEntries[i].p_offset, SEEK_SET);
+ DynEntries = (Elf64_Dyn*)malloc(pSegmentEntries[i].p_memsz);
+ if (DynEntries == NULL) {
+ printf("error[%s] : memory allocation <DynEntries>\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+ if (!fread(DynEntries, pSegmentEntries[i].p_memsz, 1, fp)) {
+ printf("error[%s] : file read <DynEntries>\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+ pos = i;
+ break;
+ }
+ }
+
+ 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:
+ symbolOff = DynEntries[i].d_un.d_val;
+ break;
+ case DT_SYMENT:
+ symEntrySize = DynEntries[i].d_un.d_val;
+ break;
+ case DT_HASH:
+ hashOff = DynEntries[i].d_un.d_val;
+ break;
+ case DT_GNU_HASH:
+ hashOff = DynEntries[i].d_un.d_val;
+ break;
+ default:
+ break;
+ }
+ }
+
+ fseek(fp, hashOff + 4, SEEK_SET);
+ if (!fread(&totalSymbolCnt, sizeof(Elf64_Word), 1, fp))
+ printf("error[%s] : file read <symEntryCnt>\n", fileName);
+
+ pMapSymbolTable = (Elf64_Sym*)malloc(totalSymbolCnt * sizeof(Elf64_Sym));
+ fseek(fp, symbolOff, SEEK_SET);
+ if (!fread(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp))
+ printf("error[%s] : file read <pMapSymbolTable>\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;
+ }
+ }
+
+ if (!done2) {
+ printf("Undefined symbols are already removed : %s\n", fileName);
+ return 1;
+ }
+
+ fseek(fp, pSegmentEntries[pos].p_offset, SEEK_SET);
+ if (!fwrite(DynEntries, pSegmentEntries[pos].p_memsz, 1, fp)) {
+ printf("error[%s] : file write <DynEntries>\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+
+ fseek(fp, symbolOff, SEEK_SET);
+ if (!fwrite(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp)) {
+ printf("error[%s] : file write <pMapSymbolTable>\n", fileName);
+ exit(EXIT_FAILURE);
+ }
+
+ fclose(fp);
+ printf("Success : %s\n", fileName);
+ return 1;
}
-int PostLinker64(char* fileName)
+int main(int argc, char **argv)
{
- Elf64_Ehdr elfHeader;
- Elf64_Phdr *pSegmentEntries;
- Elf64_Dyn *DynEntries;
- Elf64_Sym *pMapSymbolTable;
- int totalSymbolCnt;
- int i;
- int pos;
-
- FILE *fp;
- int done, done2;
- int symbolOff = 0;
- int symEntrySize = 0;
- int hashOff = 0;
- int Len;
-
- fp = NULL;
- fp = fopen(fileName, "r+");
-
- if (fp == NULL)
- {
- printf("error[%s] : file open\n", fileName);
- exit(EXIT_FAILURE);
- }
-
- /* Get ELF Header Information */
- if(!fread((void*)&elfHeader, sizeof(Elf64_Ehdr), 1, fp))
- {
- printf("error[%s] : file read <header>\n", fileName);
- exit(EXIT_FAILURE);
- }
-
- if(*(int*)(elfHeader.e_ident) != ELF_FORMAT)
- {
- printf("error[%s] : no ELF format\n", fileName);
- exit(EXIT_FAILURE);
- }
-
- if (elfHeader.e_ident[EI_CLASS] != 2 )
- {
- printf("error[%s] : EI_CLASS is not 64-bit format\n", fileName);
- exit(EXIT_FAILURE);
- }
-
- pSegmentEntries = NULL;
- DynEntries = NULL;
-
- /* Memory Allocation for Segment and Section entries */
- pSegmentEntries = (Elf64_Phdr *)malloc(elfHeader.e_phentsize * elfHeader.e_phnum);
-
- /* Get Segment Header Information using ELF Header */
- fseek(fp, elfHeader.e_phoff, SEEK_SET);
- if(!fread(pSegmentEntries, elfHeader.e_phentsize * elfHeader.e_phnum, 1, fp))
- printf("error[%s] : file read <pSegmentEntries>\n", fileName );
-
- /* Get Dynamic segment Information using Segment Header */
- for(i=0; i<elfHeader.e_phnum; i++)
- {
- if(pSegmentEntries[i].p_type == PT_DYNAMIC)
- {
- fseek(fp, pSegmentEntries[i].p_offset, SEEK_SET);
- DynEntries = (Elf64_Dyn*)malloc(pSegmentEntries[i].p_memsz);
- if(DynEntries == NULL)
- {
- printf("error[%s] : memory allocation <DynEntries>\n", fileName);
- exit(EXIT_FAILURE);
- }
- if(!fread(DynEntries, pSegmentEntries[i].p_memsz, 1, fp))
- {
- printf("error[%s] : file read <DynEntries>\n", fileName);
- exit(EXIT_FAILURE);
- }
- pos = i;
- break;
- }
- }
-
- for(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: symbolOff = DynEntries[i].d_un.d_val; break;
- case DT_SYMENT: symEntrySize = DynEntries[i].d_un.d_val; break;
- case DT_HASH: hashOff = DynEntries[i].d_un.d_val; break;
- case DT_GNU_HASH: hashOff = DynEntries[i].d_un.d_val; break;
- default: break;
- }
- }
-
- fseek(fp, hashOff+4,SEEK_SET);
- if(!fread(&totalSymbolCnt, sizeof(Elf64_Word), 1, fp))
- printf("error[%s] : file read <symEntryCnt>\n", fileName);
-
- pMapSymbolTable = (Elf64_Sym*)malloc(totalSymbolCnt * sizeof(Elf64_Sym));
- fseek(fp, symbolOff,SEEK_SET);
- if(!fread(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp))
- printf("error[%s] : file read <pMapSymbolTable>\n", fileName);
-
- done2 = 0;
- for(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;
- }
- }
-
- if (!done2)
- {
- printf("Undefined symbols are already removed : %s\n", fileName);
- return 1;
- }
-
- fseek(fp, pSegmentEntries[pos].p_offset, SEEK_SET);
- if(!fwrite(DynEntries, pSegmentEntries[pos].p_memsz, 1, fp))
- {
- printf("error[%s] : file write <DynEntries>\n", fileName);
- exit(EXIT_FAILURE);
- }
-
- fseek(fp, symbolOff,SEEK_SET);
- if(!fwrite(pMapSymbolTable, symEntrySize * totalSymbolCnt, 1, fp))
- {
- printf("error[%s] : file write <pMapSymbolTable>\n", fileName);
- exit(EXIT_FAILURE);
- }
-
- fclose(fp);
- printf("Success : %s\n", fileName);
- return 1;
+ for (int i = 1; i < argc; ++i)
+ PostLinker64(argv[i]);
}