public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@cygnus.com>
To: binutils@sourceware.cygnus.com
Subject: Proposed objcopy patch
Date: Thu, 01 Jul 1999 00:00:00 -0000	[thread overview]
Message-ID: <199905142116.OAA18159@elmo.cygnus.com> (raw)

Hi Guys,

  Would anyone care to comment on the patch below ?  It is a nasty hack
  which fixes a problem encountered when using objcopy to convert from
  a PE format image file into SRECs.  The PE format uses the LMA field
  as a virtual size rather a physical address, which confuses BFD when
  it comes to try to generate SRECs.

  The fix attempts to detect when an input BFD is a PE format image
  file (and the output format is not) so that the VMA address of the
  input section can be used instead of the LMA address.  The
  determination of whether the input or output BFD is in PE format is
  based on the name of the format.  If it contains the substring
  "pei-" it is assumed to be a PE image.  Gross I know, but I am not
  sure of a better way to do it.

Cheers
	Nick


1999-05-14  Nick Clifton  <nickc@cygnus.com>

	* objcopy.c (setup_section): Use the VMA as the LMA of
	sections that have come from a PEI format input BFD and which
	are not going to a PEI format output BFD.

Index: objcopy.c
===================================================================
RCS file: /cvs/cvsfiles/devo/binutils/objcopy.c,v
retrieving revision 1.106
diff -p -w -r1.106 objcopy.c
*** objcopy.c	1999/04/07 03:59:03	1.106
--- objcopy.c	1999/05/14 21:05:45
*************** setup_section (ibfd, isection, obfdarg)
*** 1148,1154 ****
--- 1148,1162 ----
        goto loser;
      }
  
+   /* The LMA field of PE images is used to hold the virtual size of
+      the section not its physical address, so if we are converting
+      from a PE format to a non-PE format we should use the VMA instead.  */
+   if (strstr (bfd_get_target (ibfd), "pei-")
+       && (strstr (bfd_get_target (obfd), "pei-") == NULL))
+     lma = bfd_section_vma (ibfd, isection);
+   else
      lma = isection->lma;
+ 
    if ((p != NULL) && p->change_lma != CHANGE_IGNORE)
      {
        if (p->change_lma == CHANGE_MODIFY)

             reply	other threads:[~1999-07-01  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-07-01  0:00 Nick Clifton [this message]
1999-07-01  0:00 ` Ian Lance Taylor
1999-07-01  0:00   ` Donn Terry
1999-07-01  0:00     ` Ian Lance Taylor
1999-07-01  0:00 ` DJ Delorie
1999-07-01  0:00 Nick Clifton
1999-07-01  0:00 Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199905142116.OAA18159@elmo.cygnus.com \
    --to=nickc@cygnus.com \
    --cc=binutils@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).