public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Proposed objcopy patch
@ 1999-07-01  0:00 Nick Clifton
  1999-07-01  0:00 ` Ian Lance Taylor
  1999-07-01  0:00 ` DJ Delorie
  0 siblings, 2 replies; 7+ messages in thread
From: Nick Clifton @ 1999-07-01  0:00 UTC (permalink / raw)
  To: binutils

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)

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Proposed objcopy patch
@ 1999-07-01  0:00 Nick Clifton
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Clifton @ 1999-07-01  0:00 UTC (permalink / raw)
  To: donn; +Cc: ian, binutils

: Date: Fri, 14 May 1999 22:04:28 -0600
: From: Donn Terry <donn@verinet.com>
: 
: In short, Ian suggests propigating the patch backwards into the PE
: reader, so the internal BFD structures are correct.
: 
: 1)  I concur completely with the spirit of that.

Me too.  I am a little pressed for time right now, so I will put off
trying to find abetter way to fix this problem until next week.

Cheers
	Nick

^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: Proposed objcopy patch
@ 1999-07-01  0:00 Nick Clifton
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Clifton @ 1999-07-01  0:00 UTC (permalink / raw)
  To: binutils

Hi DJ,

: I'd use strncmp, not strstr, as you only want to check if "pei-"
: appears at the *beginning* of the target name.  Still not bulletproof,
: but better.

Except that it would miss the 'epoc-pei-arm-...' targets.

Cheers
	Nick

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-07-01  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-01  0:00 Proposed objcopy patch Nick Clifton
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
  -- strict thread matches above, loose matches on Subject: below --
1999-07-01  0:00 Nick Clifton
1999-07-01  0:00 Nick Clifton

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).