return 1;
return 0;
main(int argc, char *argv[]){  int fd;  unsigned char *mapping;  Elf32_Word size;  struct stat statbuf;  Elf32_Shdr *dynamic;  Elf32_Shdr *dynsym;  Elf32_Shdr *symtab;  Elf32_Shdr *dynstr;  Elf32_Shdr *hash;  Elf32_Shdr *higher_section;  int dynstr_index;  Elf32_Shdr *ver_r;  Elf32_Shdr *ver_d;  char *dynstr_data;  char *new_dynstr;  Elf32_Word old_dynstr_size;  Elf32_Word new_dynstr_size;    if (argc != 2) {    fprintf(stderr, "Usage: %s <filename>\n", argv[0]);    return 1;  }  fd = open(argv[1], O_RDWR);  if (fd == -1) {    fprintf(stderr, "Cannot open file %s\n", argv[1]);    return 1;  }    if (fstat(fd, &statbuf) == -1) {    fprintf(stderr, "Cannot stat file %s\n", argv[1]);    return 1;  }    size = statbuf.st_size;      mapping = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);  if (mapping == (unsigned char *)-1) {    fprintf(stderr, "Cannot mmap file %s\n", argv[1]);    return 1;  }  used_dynamic_symbols = g_hash_table_new(g_direct_hash, g_direct_equal);  elf_header = (Elf32_Ehdr *)mapping;  if (strncmp((void *)elf_header, ELFMAG, SELFMAG)!=0) {    fprintf(stderr, "Not an ELF file\n");    return 1;  }  if (elf_header->e_ident[EI_VERSION] != EV_CURRENT) {    fprintf(stderr, "Wrong ELF file version\n");    return 1;  }  if (elf_header->e_ident[EI_CLASS] != ELFCLASS32) {    fprintf(stderr, "Only 32bit ELF files supported\n");    return 1;  }  if ( (elf_header->e_ident[EI_DATA] != ELFDATA2LSB) ||       ((elf_header->e_machine !=  EM_386 && elf_header->e_machine != EM_486)) ) {    fprintf(stderr, "Only intel LSB binaries are supported right now\n");    return 1;  }  if (elf_header->e_type != ET_DYN) {    fprintf(stderr, "Not an ELF shared object\n");    return 1;  }    dynamic = elf_find_section(SHT_DYNAMIC);  dynsym = elf_find_section(SHT_DYNSYM);  symtab = elf_find_section(SHT_SYMTAB);  dynstr_index = dynsym->sh_link;  dynstr = elf_find_section_num(dynstr_index);  dynstr_data = FILE_OFFSET(dynstr->sh_offset);  old_dynstr_size = dynstr->sh_size;  ver_d = elf_find_section(SHT_GNU_verdef);  ver_r = elf_find_section(SHT_GNU_verneed);  hash = elf_find_section(SHT_HASH);  /* Generate hash table with all used strings: */    add_strings_from_dynsym(dynsym, dynstr_data);  add_strings_from_dynamic(dynamic, dynstr_data);  if (ver_d && (ver_d->sh_link == dynstr_index))    add_strings_from_ver_d(ver_d, dynstr_data);  if (ver_r && (ver_r->sh_link == dynstr_index))    add_strings_from_ver_r(ver_r, dynstr_data);  /* Generate new dynstr section from the used strings hashtable: */    new_dynstr = generate_new_dynstr(&new_dynstr_size);  /*  printf("New dynstr size: %d\n", new_dynstr_size);  printf("Old dynstr size: %d\n", old_dynstr_size);  */    if (new_dynstr_size >= old_dynstr_size) {    fprintf(stderr, "Couldn't GC any strings, exiting.\n");    return 1;  }  /* Fixup all references: */    fixup_strings_in_dynsym(dynsym);  fixup_strings_in_dynamic(dynamic);  if (ver_d && (ver_d->sh_link == dynstr_index))    fixup_strings_in_ver_d(ver_d);  if (ver_r && (ver_r->sh_link == dynstr_index))    fixup_strings_in_ver_r(ver_r);    /* Copy over the new dynstr: */  memcpy(dynstr_data, new_dynstr, new_dynstr_size);  memset(dynstr_data + new_dynstr_size, ' ', old_dynstr_size-new_dynstr_size);  /* Compact the dynstr section and the file: */  /* 1. Set up the data for the fixup_offset() function: */  hole_index = dynstr->sh_offset + new_dynstr_size;  higher_section = elf_find_next_higher_section(hole_index);  hole_end = higher_section->sh_offset;  align_hole(&hole_index, &hole_end);    hole_len = hole_end - hole_index;  hole_addr_start = hole_index; /* TODO: Fix this to something better */  find_segment_addr_min_max(dynstr->sh_offset,			    &hole_addr_remap_start, &hole_addr_remap_end);    /*  printf("Hole remap: 0x%lx - 0x%lx\n", hole_addr_remap_start, hole_addr_remap_end);  printf("hole: %lu - %lu (%lu bytes)\n", hole_index, hole_end, hole_len);  printf("hole: 0x%lx - 0x%lx (0x%lx bytes)\n", hole_index, hole_end, hole_len);  */    /* 2. Change all section and segment sizes and offsets: */    remap_symtab(dynsym);  if (symtab)    remap_symtab(symtab);    remap_i386_got();  remap_dynamic(dynamic, new_dynstr_size);    remap_sections(); /* After this line the section headers are wrong */  remap_segments();  remap_elf_header();      /* 3. Do the real compacting. */  memmove(mapping + hole_index,	  mapping + hole_index + hole_len,	  size - (hole_index + hole_len));    munmap(mapping, size);  ftruncate(fd, size - hole_len);  close(fd);}