Hi,
Based on tutorial at "http://sourceforge.net/apps/trac/elftoolchain/"
I wrote a program to create a new section into an existing ELF file.
My program is not writing out the changes into the ELF file.
Here is the snippet starting from the creation of new section till end of file:
--------------------------------------------------------------------------------------------------------------------
  scn = NULL;
  if((scn = elf_newscn(e)) == NULL)
  {
    errx(EX_SOFTWARE , " newscn () failed : %s . ", elf_errmsg(-1));
  }

  if((data = elf_newdata(scn)) == NULL)
  {
    errx(EX_SOFTWARE , " newdata () failed : %s . ", elf_errmsg(-1));
  }
  data->d_align = 4;
  data->d_off = 0LL;
  data->d_buf = hash_words;
  data->d_type = ELF_T_WORD;
  data->d_size = sizeof(hash_words);
  data->d_version = EV_CURRENT;

  if((shdr = elf32_getshdr(scn)) == NULL)
  {
    errx(EX_SOFTWARE , " elf32_getshdr () failed : %s . ", elf_errmsg(-1));
  }

  shdr->sh_name = 9999;
  shdr->sh_type = SHT_HASH;
  shdr->sh_flags = SHF_ALLOC;
  shdr->sh_entsize = 0;

  if (elf_update(e, ELF_C_NULL) < 0)
  {
    errx(EX_SOFTWARE , " elf_update () failed : %s . ", elf_errmsg(-1));
  }

  (void) elf_flagshdr(scn, ELF_C_SET, ELF_F_DIRTY);
  (void) elf_flagscn(scn, ELF_C_SET, ELF_F_DIRTY);
  (void) elf_flagdata(data, ELF_C_SET, ELF_F_DIRTY);
  (void) elf_flagehdr(e, ELF_C_SET, ELF_F_DIRTY);
  (void) elf_flagelf(e, ELF_C_SET, ELF_F_DIRTY);

  if (elf_update(e, ELF_C_WRITE) < 0)
  {
    errx(EX_SOFTWARE , " elf_update () failed : %s . ", elf_errmsg(-1));
  }

  elf_end(e);
  close(fd);
  exit(EX_OK);
--------------------------------------------------------------------------------
Thanks,
- Nikhil