This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Help]How to update the section content during the assemble?
- From: Terry Guo <flameroc at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 12 Aug 2014 16:56:32 +0800
- Subject: [Help]How to update the section content during the assemble?
- Authentication-results: sourceware.org; auth=none
Hi there,
Currently the gas will emit the obj attribute section and then do
relaxation. But my target will adjust some target attributes during
the relaxation, so I want to update the already generated attribute
section after relaxation.
Currently I am using the md_post_relax_hook with following code (in
pseudo code):
attribute_sec = bfd_get_section_by_name (abfd, sec_name);
size = bfd_elf_obj_attr_size (abfd);
seginfo = seg_info (attr_sec);
//generate new frag for updated target attributes.
fragS *newf = frag_alloc (ob);
bfd_elf_set_obj_attr_contents (abfd, (bfd_byte *)newf->fr_literal, size);
//link attribute section with this new frag and discard the old one
seginfo->frchainP->frch_root = newf;
seginfo->frchainP->frch_last = newf;
But it doesn't work. I think I am not understanding this frag stuff
very clearly. What's the correct way to do so? Please help.
BR,
Terry