public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [Help]How to update the section content during the assemble?
@ 2014-08-12  8:56 Terry Guo
  0 siblings, 0 replies; only message in thread
From: Terry Guo @ 2014-08-12  8:56 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-08-12  8:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-12  8:56 [Help]How to update the section content during the assemble? Terry Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).