Exemplo n.º 1
0
Arquivo: coff.c Projeto: giggi/12step
block_list coff_make(section_list seclist)
{
  block_list blklist;
  block blk_coff_header;
  block blk_optional_header;
  block blk_section_header;
  block blk_sections;
  section text_sec, data_sec, bss_sec;
  int section_header_number;

  blklist = block_list_create();

  blk_coff_header     = block_create("COFF header");
  blk_optional_header = block_create("optional header");
  blk_section_header  = block_create("section header");
  blk_sections        = block_create("sections");

  block_list_insert(blklist, NULL, blk_coff_header);
  block_list_insert(blklist, NULL, blk_optional_header);
  block_list_insert(blklist, NULL, blk_section_header);
  block_list_insert(blklist, NULL, blk_sections);

  section_list_align(seclist, sizeof(long));

  text_sec = section_list_search(seclist, ".text");
  data_sec = section_list_search(seclist, ".data");
  bss_sec  = section_list_search(seclist, ".bss");

  /* 不要なセクション情報を削除 */
  coff_delete_waste_section(seclist);
  section_header_number = section_list_get_length(seclist);

  /* COFFヘッダを作成 */
  coff_make_coff_header(blk_coff_header, section_list_get_length(seclist));

  /* オプションヘッダを作成 */
  coff_make_optional_header(blk_optional_header,
			    section_get_memory_size(text_sec),
			    section_get_memory_size(data_sec),
			    section_get_memory_size(bss_sec),
			    section_list_get_entry_point(seclist),
			    section_get_virtual_addr(text_sec),
			    section_get_virtual_addr(data_sec));

  /* セクションヘッダを作成 */
  coff_make_section_header(blk_section_header, seclist,
			   sizeof(struct coff_header) + sizeof(struct coff_optional_header) + sizeof(struct coff_section_header) * section_header_number);

  /* セクションの本体を作成 */
  coff_make_sections(blk_sections, seclist);

  block_list_align(blklist, sizeof(long));

  return blklist;
}
Exemplo n.º 2
0
void
fill_seafile_blocks (const unsigned char *sha1, BlockList *bl)
{
    char file_id[41];
    Seafile *seafile;
    int i;

    rawdata_to_hex (sha1, file_id, 20);
    seafile = seaf_fs_manager_get_seafile (seaf->fs_mgr, file_id);
    if (!seafile) {
        g_warning ("Failed to find file %s.\n", file_id);
        return;
    }

    for (i = 0; i < seafile->n_blocks; ++i)
        block_list_insert (bl, seafile->blk_sha1s[i]);

    seafile_unref (seafile);
}