Creating BFD with single section

Paulo J. Matos paulo@matos-sorge.com
Tue Dec 6 14:16:00 GMT 2011
Hello,

I am trying to manually create an elf file `tmpfile' with a single 
section `.debug_comment' with content in buffer `idstring_buf'.

Here's the code:
     abfd = bfd_openw(tmpfile, p->target);
     sec = bfd_make_section_with_flags(abfd, ".debug_comment",
                                       SEC_READONLY | SEC_HAS_CONTENTS | 
SEC_DEBUGGING);
     if(sec == NULL)
         einfo("%P%F: cannot create section `.debug_comment' in 
temporary bfd\n");

     if(!bfd_set_section_size(abfd, sec, sz))
         einfo("%P%F: cannot set section size\n");
     if(!bfd_set_section_contents(abfd, sec, idstring_buf, 0, sz))
         einfo("%P%F: cannot set section contents\n");


     bfd_close(abfd);

None of this fails but the file is never really written to disk. What am 
I missing here?

Cheers,

-- 
PMatos



More information about the Binutils mailing list