This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Help]How to update the section content during the assemble?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]