20 #include <sys/types.h>
31 #define DEFAULT_NAME "wld"
44 fd = open(name, O_RDWR);
46 printf(
" !! couldn't open %s : %s\n", name, strerror(errno));
50 if (fstat(fd, &sb) == -1) {
51 printf(
" !! couldn't stat %s : %s\n", name, strerror(errno));
55 if ((
unsigned int) sb.st_size <
sizeof(Elf32_Ehdr)) {
56 printf(
" !! file %s is too small (%u bytes) to be a valid ELF.\n", name, (
unsigned int) sb.st_size);
60 map = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
61 if (map == MAP_FAILED) {
62 printf(
" !! couldn't mmap %s : %s\n", name, strerror(errno));
66 switch (map[EI_CLASS]) {
68 ehdr32 = (Elf32_Ehdr *) map;
69 ehdr32->e_type = ET_DYN;
72 ehdr64 = (Elf64_Ehdr *) map;
73 ehdr64->e_type = ET_DYN;
76 printf(
" !! unknown ELF class\n");
80 munmap(map, sb.st_size);
87 printf(
"%s version:%s (%s %s)\n", WNAME, WVERSION, WTIME, WDATE);
91 int main(
int argc,
char **argv)
94 if ((argc < 2)||(strncmp(argv[1],
"-libify",7))) {
96 printf(
"\nUsage: %s [options] file\n", argc > 0 ? argv[0] :
DEFAULT_NAME);
97 printf(
"\noptions:\n\n -libify Set Class to ET_DYN in input ELF file.\n\n");
int main(int argc, char **argv)