From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Clifton To: binutils@sourceware.cygnus.com Subject: Proposed objcopy patch Date: Thu, 01 Jul 1999 00:00:00 -0000 Message-id: <199905142116.OAA18159@elmo.cygnus.com> X-SW-Source: 1999-q2/msg00038.html 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 * 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)