HGGitLab

Commit 9c6b18de authored by luoliangyi's avatar luoliangyi

增加mips64obj文件转换工程

parent 1d9940a1
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="32objto64obj" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/32objto64obj" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/32objto64obj" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="main.cpp" />
<Extensions>
<code_completion />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>
#include <stdio.h>
#include <vector>
#include <dirent.h>
#include <errno.h>
#include <string.h>
#include <elf.h>
static void list_files(const char *dir_path)
{
DIR *ptr_dir = NULL;
struct dirent *ptr_dirent = NULL;
ptr_dir = opendir(dir_path);
if (NULL == dir_path)
{
printf("opendir %s failed.\n", dir_path);
return;
}
while (1)
{
errno = 0;
ptr_dirent = readdir(ptr_dir);
if (NULL == ptr_dirent)
{
break;
}
if (ptr_dirent->d_type & DT_DIR)
{
/* 跳过"."和".."目录 */
if (strcmp(ptr_dirent->d_name, ".") == 0 || strcmp(ptr_dirent->d_name, "..") == 0)
{
continue;
}
char newPath[512];
sprintf(newPath, "%s/%s", dir_path, ptr_dirent->d_name);
list_files(newPath);
}
else
{
char newPath[512];
sprintf(newPath, "%s/%s", dir_path, ptr_dirent->d_name);
printf("%s\n", newPath);
if (NULL != strstr(newPath, ".cff.o"))
{
printf("handle %s\n", newPath);
FILE *file = fopen(newPath, "rb");
if (NULL != file)
{
fseek(file, 48, SEEK_SET);
unsigned char data[4] = {0x07, 0x00, 0x00, 0x80};
fwrite(data, 1, 4, file);
fclose(file);
}
}
}
}
if (errno != 0)
{
printf("readdir error, errno=%d.\n", errno);
}
closedir(ptr_dir);
}
int main(int argc, char *argv[])
{
if ((argc > 1) && (0 == strcmp(argv[1], "--help")))
{
printf("%s [dir...]\n", argv[0]);
return -1;
}
if (argc == 1)
{
list_files(".");
}
else
{
for (argv++; *argv != NULL; argv++)
{
list_files(*argv);
}
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment