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

   Date: Fri, 14 May 1999 22:04:28 -0600
   From: Donn Terry <donn@verinet.com>

   3) A fix in the back end propigates itself back to user space
   in a way I think Ian should comment upon.  PE basically has
   changed the meaning of the s_paddr/lma field, and it's resonable
   to have both meanings in the internal data structure in separate
   fields.  For most of BFD and its users, that's probably an
   improvement, but it presents a problem for objdump.  Either
   the format of the --headers output needs to change or there
   needs to be special case code so that the "interesting" value
   is printed, as a function of the object format being dumped.
   (That is, one "COFF" field will go into one of two places; when
   printing either both (one guaranteed to be zero) need to be printed,
   or objdump needs to know which is "live".)

objdump -h should print the VMA and LMA as always.  Since PE does not
store a separate LMA, objdump -h should probably set the LMA to the
VMA.

objdump -p can print the doubled section size.  objdump -p is used to
print information that can not be stored in the generic BFD format.

Ian

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

* 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 Proposed objcopy patch Nick Clifton
  1999-07-01  0:00 ` Ian Lance Taylor
@ 1999-07-01  0:00 ` DJ Delorie
  1 sibling, 0 replies; 7+ messages in thread
From: DJ Delorie @ 1999-07-01  0:00 UTC (permalink / raw)
  To: nickc; +Cc: binutils

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.

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

* Re: Proposed objcopy patch
  1999-07-01  0:00 ` Ian Lance Taylor
@ 1999-07-01  0:00   ` Donn Terry
  1999-07-01  0:00     ` Ian Lance Taylor
  0 siblings, 1 reply; 7+ messages in thread
From: Donn Terry @ 1999-07-01  0:00 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: nickc, binutils

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.

2) PE is probably better named "not-quite-COFF" but let's not
go there.

3) A fix in the back end propigates itself back to user space
in a way I think Ian should comment upon.  PE basically has
changed the meaning of the s_paddr/lma field, and it's resonable
to have both meanings in the internal data structure in separate
fields.  For most of BFD and its users, that's probably an
improvement, but it presents a problem for objdump.  Either
the format of the --headers output needs to change or there
needs to be special case code so that the "interesting" value
is printed, as a function of the object format being dumped.
(That is, one "COFF" field will go into one of two places; when
printing either both (one guaranteed to be zero) need to be printed,
or objdump needs to know which is "live".)

In general, that problem has been a continuing nuisance about
PE format, so a good solution would probably pay itself back
many times over.

Donn


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

* Re: Proposed objcopy patch
  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 ` DJ Delorie
  1 sibling, 1 reply; 7+ messages in thread
From: Ian Lance Taylor @ 1999-07-01  0:00 UTC (permalink / raw)
  To: nickc; +Cc: binutils

   Date: Fri, 14 May 1999 14:16:02 -0700
   From: Nick Clifton <nickc@cygnus.com>

     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.

Please, no.  The LMA in isection->lma is in a BFD internal structure.
Those structures should be storing generic information.  That is, the
LMA field should always hold the LMA.  If the section lma field does
not hold the LMA for PE, then the correct solution is to change the PE
backend to store the correct value in the section lma field.  Right
now PE is probably simply setting the LMA field from the s_paddr
field; that would have to change.

Of course, the PE backend may rely on this on other ways, so the true
section size would to be stored elsewhere in PE specific information,
and any code which expected to see the section size in the lma field
would have to be changed.

Basically, though, it's unacceptable to change objcopy in order to
support a specific file format.  That destroys the whole point of
using BFD in the first place.

Ian

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