public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* arm-wince-pe support resurrection
@ 2003-11-20 13:31 Dmitry Semyonov
  2003-12-01 18:43 ` Nick Clifton
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Dmitry Semyonov @ 2003-11-20 13:31 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: TEXT/PLAIN, Size: 295 bytes --]

Hello all.

Attached patches are aimed to resurrect some broken or incompatible with
MS linker features of arm-wince-pe support:
 - partial linking (ld -r)
 - flags of special sections
 - relocations

Changelog entries are at the end of each patch.

Your comments are welcome.


...Bye..Dmitry.

[-- Attachment #2: Type: APPLICATION/x-gzip, Size: 654 bytes --]

[-- Attachment #3: Type: APPLICATION/x-gzip, Size: 1220 bytes --]

[-- Attachment #4: Type: APPLICATION/x-gzip, Size: 1557 bytes --]

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

* Re: arm-wince-pe support resurrection
  2003-11-20 13:31 arm-wince-pe support resurrection Dmitry Semyonov
@ 2003-12-01 18:43 ` Nick Clifton
  2003-12-05 19:39   ` Dmitry Semyonov
  2003-12-04 17:47 ` Nick Clifton
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2003-12-01 18:43 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

> Attached patches are aimed to resurrect some broken or incompatible
> with MS linker features of arm-wince-pe support:
>  - partial linking (ld -r)
>  - flags of special sections
>  - relocations

These patches contain quite a few different changes/fixes, so I am
going to go through them one by one over the next few days.  Here is
the first:

  bfd/ChangeLog
  2003-11-20  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>
  
  	* coffcode.h (coff_compute_section_file_positions): set page_size
  	to 1 instead of 0 in the case file alignment value is zero. This
  	eliminates 'ld -r' "bad value" failure for arm-wince-pe target.
  
  diff -rNc3p binutils-031114/bfd/coffcode.h /home/sdv/cross/binutils-031114/bfd/coffcode.h
  *** binutils-031114/bfd/coffcode.h	Tue Nov  4 13:41:51 2003
  --- /home/sdv/cross/binutils-031114/bfd/coffcode.h	Mon Nov 17 21:06:50 2003
  *************** coff_compute_section_file_positions (abf
  *** 3014,3019 ****
  --- 3014,3023 ----
      if (coff_data (abfd)->link_info)
        {
          page_size = pe_data (abfd)->pe_opthdr.FileAlignment;
  + 
  +       /* Improve robustness. This repairs 'ld -r' for arm-wince-pe target. */
  +       if (page_size == 0)
  +         page_size++;
        }
      else
        page_size = PE_DEF_FILE_ALIGNMENT;
          
I have approved this patch and applied it.  I altered the comment
slightly to make it more obvious why page_size is being changed.

Cheers
        Nick
        

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

* Re: arm-wince-pe support resurrection
  2003-11-20 13:31 arm-wince-pe support resurrection Dmitry Semyonov
  2003-12-01 18:43 ` Nick Clifton
@ 2003-12-04 17:47 ` Nick Clifton
  2003-12-04 17:51 ` Nick Clifton
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 22+ messages in thread
From: Nick Clifton @ 2003-12-04 17:47 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

I have applied this part of your patch.

Cheers
        Nick

bfd/ChangeLog
2003-12-04  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>

	* coff-arm.c (coff_arm_relocate_section, bfd_arm_process_before_allocation):
	Change ARM26* to ARM_26* in comments to match definitions.
	(coff_arm_adjust_symndx): Replace hard-coded constants with
	appropriate definitions (ARM_26*).

        

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

* Re: arm-wince-pe support resurrection
  2003-11-20 13:31 arm-wince-pe support resurrection Dmitry Semyonov
  2003-12-01 18:43 ` Nick Clifton
  2003-12-04 17:47 ` Nick Clifton
@ 2003-12-04 17:51 ` Nick Clifton
  2003-12-04 18:11 ` Nick Clifton
  2003-12-04 18:19 ` Nick Clifton
  4 siblings, 0 replies; 22+ messages in thread
From: Nick Clifton @ 2003-12-04 17:51 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

  And this part has now been checked in.

Cheers
        Nick

ld/ChangeLog
2003-11-20  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>

	* armpe.sh: Add RELOCATEABLE_OUTPUT_FORMAT="pe-arm-little".
	(default one was "pei-arm-little", which is incorrect).
                

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

* Re: arm-wince-pe support resurrection
  2003-11-20 13:31 arm-wince-pe support resurrection Dmitry Semyonov
                   ` (2 preceding siblings ...)
  2003-12-04 17:51 ` Nick Clifton
@ 2003-12-04 18:11 ` Nick Clifton
  2003-12-05 12:48   ` Dmitry Semyonov
  2003-12-04 18:19 ` Nick Clifton
  4 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2003-12-04 18:11 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

  With regards to this patch:
-------------------------------------------------------------------------------
2003-11-18  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>

	* bfd/peXXigen.c (_bfd_XXi_swap_scnhdr_out): Set flags for some special
	sections (.text, .rdata, .data, .bss) as described in
	"MS PE & COFF Specification".

diff -rNc3p binutils-031114/bfd/peXXigen.c /home/sdv/cross/binutils-031114/bfd/peXXigen.c
*** binutils-031114/bfd/peXXigen.c	Fri Nov 14 21:46:53 2003
--- /home/sdv/cross/binutils-031114/bfd/peXXigen.c	Fri Nov 14 22:11:43 2003
*************** _bfd_XXi_swap_scnhdr_out (abfd, in, out)
*** 959,964 ****
--- 959,993 ----
  
    {
      int flags = scnhdr_int->s_flags;
+     
+     if (strcmp (scnhdr_int->s_name, ".text") == 0)
+       {
+         /* Executable code */
+         flags &= ~IMAGE_SCN_MEM_WRITE;
+         flags |= IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE |
+                  IMAGE_SCN_MEM_READ;
+       }
+     else if (strcmp (scnhdr_int->s_name, ".rdata") == 0)
+       {
+         /* Read-only initialized data */
+         flags &= ~IMAGE_SCN_MEM_WRITE;
+         flags |= IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ;
+       }
+     else if (strcmp (scnhdr_int->s_name, ".data") == 0)
+       {
+         /* Initialized data */
+         flags |= IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
+                  IMAGE_SCN_MEM_WRITE;
+       }
+     else if (strcmp (scnhdr_int->s_name, ".bss") == 0)
+       {
+         /* Uninitialized data */
+         flags |= IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ |
+                  IMAGE_SCN_MEM_WRITE;
+       }
+ 
+     /* FIXME: Still not all reserved sections and their characteristics
+      *        are covered here. */
  
      H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
    }
-------------------------------------------------------------------------------

I am not sure that this is the right place to be doing this.  So you
have an example of how, without this patch applied, the linker is
producing section with incorrect flag bits set ?

Cheers
        Nick
        

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

* Re: arm-wince-pe support resurrection
  2003-11-20 13:31 arm-wince-pe support resurrection Dmitry Semyonov
                   ` (3 preceding siblings ...)
  2003-12-04 18:11 ` Nick Clifton
@ 2003-12-04 18:19 ` Nick Clifton
  2003-12-04 19:34   ` Dmitry Semyonov
  4 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2003-12-04 18:19 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

  With regard to this patch:

---------------------------------------------------------
diff -rNc3p binutils-031114/bfd/coff-arm.c /home/sdv/cross/binutils-031114/bfd/coff-arm.c
*** binutils-031114/bfd/coff-arm.c	Fri Jul 25 14:50:03 2003
--- /home/sdv/cross/binutils-031114/bfd/coff-arm.c	Fri Nov 14 22:11:43 2003
*************** coff_arm_reloc (abfd, reloc_entry, symbo
*** 252,262 ****
  #undef  ARM_THUMB12
  #undef  ARM_26D
  
  #define ARM_32       1
  #define ARM_RVA32    2
  #define ARM_26	     3
  #define ARM_THUMB12  4
- #define ARM_26D      5
  #define ARM_SECTION  14
  #define ARM_SECREL   15
  #endif
--- 252,262 ----
  #undef  ARM_THUMB12
  #undef  ARM_26D
  
+ #define ARM_26D      0
  #define ARM_32       1
  #define ARM_RVA32    2
  #define ARM_26	     3
  #define ARM_THUMB12  4
  #define ARM_SECTION  14
  #define ARM_SECREL   15
  #endif
*************** coff_arm_reloc (abfd, reloc_entry, symbo
*** 264,270 ****
  static reloc_howto_type aoutarm_std_reloc_howto[] =
    {
  #ifdef ARM_WINCE
!     EMPTY_HOWTO (-1),
      HOWTO (ARM_32,
  	   0,
  	   2,
--- 264,282 ----
  static reloc_howto_type aoutarm_std_reloc_howto[] =
    {
  #ifdef ARM_WINCE
!     HOWTO (ARM_26D,
! 	   2,
! 	   2,
! 	   24,
! 	   FALSE,
! 	   0,
! 	   complain_overflow_dont,
! 	   aoutarm_fix_pcrel_26_done,
! 	   "ARM_26D",
! 	   FALSE,
! 	   0x00ffffff,
! 	   0x0,
! 	   FALSE),
      HOWTO (ARM_32,
  	   0,
  	   2,
*************** static reloc_howto_type aoutarm_std_relo
*** 274,280 ****
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_32",
! 	   TRUE,
  	   0xffffffff,
  	   0xffffffff,
  	   PCRELOFFSET),
--- 286,292 ----
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_32",
! 	   FALSE,
  	   0xffffffff,
  	   0xffffffff,
  	   PCRELOFFSET),
*************** static reloc_howto_type aoutarm_std_relo
*** 287,293 ****
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_RVA32",
! 	   TRUE,
  	   0xffffffff,
  	   0xffffffff,
  	   PCRELOFFSET),
--- 299,305 ----
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_RVA32",
! 	   FALSE,
  	   0xffffffff,
  	   0xffffffff,
  	   PCRELOFFSET),
*************** static reloc_howto_type aoutarm_std_relo
*** 317,335 ****
  	   0x000007ff,
  	   0x000007ff,
  	   PCRELOFFSET),
!     HOWTO (ARM_26D,
! 	   2,
! 	   2,
! 	   24,
! 	   FALSE,
! 	   0,
! 	   complain_overflow_dont,
! 	   aoutarm_fix_pcrel_26_done,
! 	   "ARM_26D",
! 	   TRUE,
! 	   0x00ffffff,
! 	   0x0,
! 	   FALSE),
      EMPTY_HOWTO (-1),
      EMPTY_HOWTO (-1),
      EMPTY_HOWTO (-1),
--- 329,335 ----
  	   0x000007ff,
  	   0x000007ff,
  	   PCRELOFFSET),
!     EMPTY_HOWTO (-1),
      EMPTY_HOWTO (-1),
      EMPTY_HOWTO (-1),
      EMPTY_HOWTO (-1),
*************** static reloc_howto_type aoutarm_std_relo
*** 347,353 ****
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_16",
! 	   TRUE,
  	   0x0000ffff,
  	   0x0000ffff,
  	   PCRELOFFSET),
--- 347,353 ----
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_16",
! 	   FALSE,
  	   0x0000ffff,
  	   0x0000ffff,
  	   PCRELOFFSET),
*************** static reloc_howto_type aoutarm_std_relo
*** 360,366 ****
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_32",
! 	   TRUE,
  	   0xffffffff,
  	   0xffffffff,
  	   PCRELOFFSET),
--- 360,366 ----
  	   complain_overflow_bitfield,
  	   coff_arm_reloc,
  	   "ARM_32",
! 	   FALSE,
  	   0xffffffff,
  	   0xffffffff,
  	   PCRELOFFSET),
diff -rNc3p binutils-031114/ld/pe-dll.c /home/sdv/cross/binutils-031114/ld/pe-dll.c
*** binutils-031114/ld/pe-dll.c	Fri Oct 31 08:32:44 2003
--- /home/sdv/cross/binutils-031114/ld/pe-dll.c	Fri Nov 14 22:11:43 2003
*************** generate_reloc (bfd *abfd, struct bfd_li
*** 1155,1161 ****
  		      total_relocs++;
  		      break;
  		    case BITS_AND_SHIFT (24, 2):
! 		      if (relocs[i]->howto->type == 5)
  			/* This is an ARM_26D reloc, which is an ARM_26 reloc
  			   that has already been fully processed during a
  			   previous link stage, so ignore it here.  */
--- 1155,1164 ----
  		      total_relocs++;
  		      break;
  		    case BITS_AND_SHIFT (24, 2):
!                         /* FIXME: 0 is ARM_26D, it is defined in bfd/coff-arm.c
!                                   Those ARM_xxx definitions should go in proper
!                                   header someday. */
! 		      if (relocs[i]->howto->type == 0)
  			/* This is an ARM_26D reloc, which is an ARM_26 reloc
  			   that has already been fully processed during a
  			   previous link stage, so ignore it here.  */


2003-11-18  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>

	* coff-arm.c (coff_arm_reloc): 
	Do not put relocation information into object code.
	MS linker adds the value from "COFF relocations" to the data stored
	in object code. This leads to invalid linking.

	* coff-arm.c (coff_arm_reloc):
	Re-map ARM_26D relocation from 5 to 0. This fixes "bad fixup" error
	generated by MS linker.

2003-11-18  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>

	* pe-dll.c (generate_reloc):
	Re-map ARM_26D relocation from 5 to 0. This fixes "bad fixup" error
	generated by MS linker.

----------------------------------------------------------------------
I think that the changes to coff-arm.c should be made conditional upon
ARM_WINCE beign defined.  In fact I am not sure that it is a good idea
to change reloc numbers at all, but assuming that it needs to be done,
I think that we need to ensure that we maintain backwards comptability
with older toolchains which still produce ARM_26D relocs with a value
of 5.

Cheers
        Nick
        

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

* Re: arm-wince-pe support resurrection
  2003-12-04 18:19 ` Nick Clifton
@ 2003-12-04 19:34   ` Dmitry Semyonov
  2003-12-05 11:29     ` Nick Clifton
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2003-12-04 19:34 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Hello Nick.

On Thu, 4 Dec 2003, Nick Clifton wrote:

[...]

> diff -rNc3p binutils-031114/ld/pe-dll.c /home/sdv/cross/binutils-031114/ld/pe-dll.c
> *** binutils-031114/ld/pe-dll.c	Fri Oct 31 08:32:44 2003
> --- /home/sdv/cross/binutils-031114/ld/pe-dll.c	Fri Nov 14 22:11:43 2003
> *************** generate_reloc (bfd *abfd, struct bfd_li
> *** 1155,1161 ****
>   		      total_relocs++;
>   		      break;
>   		    case BITS_AND_SHIFT (24, 2):
> ! 		      if (relocs[i]->howto->type == 5)
>   			/* This is an ARM_26D reloc, which is an ARM_26 reloc
>   			   that has already been fully processed during a
>   			   previous link stage, so ignore it here.  */
> --- 1155,1164 ----
>   		      total_relocs++;
>   		      break;
>   		    case BITS_AND_SHIFT (24, 2):
> !                         /* FIXME: 0 is ARM_26D, it is defined in bfd/coff-arm.c
> !                                   Those ARM_xxx definitions should go in proper
> !                                   header someday. */
> ! 		      if (relocs[i]->howto->type == 0)
>   			/* This is an ARM_26D reloc, which is an ARM_26 reloc
>   			   that has already been fully processed during a
>   			   previous link stage, so ignore it here.  */
>

[...]

> 2003-11-18  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>
>
> 	* pe-dll.c (generate_reloc):
> 	Re-map ARM_26D relocation from 5 to 0. This fixes "bad fixup" error
> 	generated by MS linker.
>
> ----------------------------------------------------------------------
> I think that the changes to coff-arm.c should be made conditional upon
> ARM_WINCE beign defined.

The modified parts of coff-arm.c are already protected by ARM_WINCE
macro. The modified part of pe-dll.c obviously requires cleanup as
stated in the comments.


> In fact I am not sure that it is a good idea
> to change reloc numbers at all, but assuming that it needs to be done,
> I think that we need to ensure that we maintain backwards comptability
> with older toolchains which still produce ARM_26D relocs with a value
> of 5.

It is explicitly stated in MS PE COFF specification (section 5.2: ARM
Processors) that relocation 0 is ignored. 5th one is not
mentioned, so in my opinion it should be treated as reserved, and should
not be used.

I suspect patched binutils will not be backward compatible with object
files produced by the older toolchains. (At least the condition from the
above patch should test for both 5 and 0 values for compatibility.) But
why not to recompile the files if it is really necessary to use new
binutils?

In fact I have doubts there are active users of arm-wince-pe target
currently at all. (I have not seen the ones for several months in such
mailing lists like gcc*, binutils*, crossgcc, wince-devel). So, I don't
think the change will hurt someone.


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2003-12-04 19:34   ` Dmitry Semyonov
@ 2003-12-05 11:29     ` Nick Clifton
  0 siblings, 0 replies; 22+ messages in thread
From: Nick Clifton @ 2003-12-05 11:29 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

> It is explicitly stated in MS PE COFF specification (section 5.2: ARM
> Processors) that relocation 0 is ignored. 5th one is not
> mentioned, so in my opinion it should be treated as reserved, and should
> not be used.

Thanks for the section reference.  I agree with you now that 5 is a
bad value for the ARM_26D reloc, so I will commit this part of your
patch.

> I suspect patched binutils will not be backward compatible with object
> files produced by the older toolchains. (At least the condition from the
> above patch should test for both 5 and 0 values for compatibility.) But
> why not to recompile the files if it is really necessary to use new
> binutils?
>
> In fact I have doubts there are active users of arm-wince-pe target
> currently at all. (I have not seen the ones for several months in such
> mailing lists like gcc*, binutils*, crossgcc, wince-devel). So, I don't
> think the change will hurt someone.

This is probably true - but just in case I have amended your patch to
pe-dll.c to accept either 0 or 5 as the value for the ARM-26D reloc.
With this change made, I have applied the rest of this patch.

Cheers
        Nick
        

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

* Re: arm-wince-pe support resurrection
  2003-12-04 18:11 ` Nick Clifton
@ 2003-12-05 12:48   ` Dmitry Semyonov
  2003-12-11 17:54     ` Nick Clifton
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2003-12-05 12:48 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick,

On Thu, 4 Dec 2003, Nick Clifton wrote:

>   With regards to this patch:
> -------------------------------------------------------------------------------
> 2003-11-18  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>
>
> 	* bfd/peXXigen.c (_bfd_XXi_swap_scnhdr_out): Set flags for some special
> 	sections (.text, .rdata, .data, .bss) as described in
> 	"MS PE & COFF Specification".
>
> diff -rNc3p binutils-031114/bfd/peXXigen.c /home/sdv/cross/binutils-031114/bfd/peXXigen.c
> *** binutils-031114/bfd/peXXigen.c	Fri Nov 14 21:46:53 2003
> --- /home/sdv/cross/binutils-031114/bfd/peXXigen.c	Fri Nov 14 22:11:43 2003
> *************** _bfd_XXi_swap_scnhdr_out (abfd, in, out)
> *** 959,964 ****
> --- 959,993 ----
>
>     {
>       int flags = scnhdr_int->s_flags;

[...]

>       H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
>     }
> -------------------------------------------------------------------------------
>
> I am not sure that this is the right place to be doing this.

May be, but I'm not familiar enough with binutils to quickly find the
right place. I was hoping that somebody (you?) could point to the good
place for the fix.


> So you have an example of how, without this patch applied, the linker is
> producing section with incorrect flag bits set ?

Refer to the beginning of section 6 (Special sections) of MS PE COFF
specification.


Warnings produced by MS linker are:
a.obj : warning LNK4078: multiple '.text' sections found with different attributes (E0000020)
a.obj : warning LNK4078: multiple '.rdata' sections found with different attributes (C0000040)


I don't know whether different flags affect the final result, but I'm
feeling more comfortable without any warnings.


The source file file I'm compiling with arm-wince-pe is:
 --- begin ---
void show(const char *s);

static const char *str = "xxx";
static char arr[3] = { 1, 2 ,3 };

void
test(void)
{
    show(str);
}
 --- end ---


It was compiled with the command:
$ arm-wince-pe-gcc -c -fno-leading-underscore test.c


Section flags are:
$ arm-wince-pe-objdump -h test.o

test.o:     file format pe-arm-little

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000020  00000000  00000000  000000b4  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, CODE
  1 .data         00000008  00000000  00000000  000000d4  2**2
                  CONTENTS, RELOC
  2 .bss          00000000  00000000  00000000  00000000  2**2
                  ALLOC
  3 .rdata        00000004  00000000  00000000  000000dc  2**2
                  CONTENTS, ALLOC, LOAD, DATA


Below is the file I'm compiling with WinCE compiler, and linking
with the mentioned above object:
 -- begin --
extern void test(void);

static wchar_t *b = L"Error\r\n";

void show(const char *s)
{
    if (s[0] != 'x' || s[1] != 'x' || s[2] != 'x')
        NKDbgPrintfW (b);
}

int main(void)
{
    b[0] = L'e';
    test();
    return 0;
}
 --- end ---


Below are some extras from MS's 'dumpbin /headers' command output
(dumpbin is - Microsoft (R) COFF/PE Dumper Version 6.24.3064):

GNU arm-wince-pe created object
-------------------------------

FILE HEADER VALUES
             1C0 machine (ARM)
               4 number of sections
               0 time date stamp Thu Jan 01 03:00:00 1970
              FE file pointer to symbol table
               F number of symbols
               0 size of optional header
            4D04 characteristics
                   Line numbers stripped
                   32 bit word machine
                   CD - run from swapfile
                   Net - run from swapfile
                   Uniprocessor Only

SECTION HEADER #1
   .text name
    [...]
E0000020 flags
         Code
         (no align specified)
         Execute Read Write

SECTION HEADER #2
   .data name
    [...]
C0000000 flags
         (no align specified)
         Read Write

SECTION HEADER #3
    .bss name
    [...]
C0000080 flags
         Uninitialized Data
         (no align specified)
         Read Write

SECTION HEADER #4
  .rdata name
    [...]
C0000040 flags
         Initialized Data
         (no align specified)
         Read Write



MS's compiler (clarm) created object
------------------------------------

FILE HEADER VALUES
             1C0 machine (ARM)
               6 number of sections
        3FCF98AF time date stamp Thu Dec 04 23:27:27 2003
             770 file pointer to symbol table
              2B number of symbols
               0 size of optional header
             100 characteristics
                   32 bit word machine
    [...]

SECTION HEADER #3
   .data name
    [...]
C0300040 flags
         Initialized Data
         4 byte align
         Read Write

SECTION HEADER #4
   .text name
    [...]
60300020 flags
         Code
         4 byte align
         Execute Read

SECTION HEADER #5
  .pdata name
    [...]
40300040 flags
         Initialized Data
         4 byte align
         Read Only



With my patch applied the warnings are gone away. Although there could
be still a source of possible problem -- alignment is not set inside the
section flags by bfd.


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2003-12-01 18:43 ` Nick Clifton
@ 2003-12-05 19:39   ` Dmitry Semyonov
  2003-12-15 15:20     ` Nick Clifton
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2003-12-05 19:39 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick,

On Mon, 1 Dec 2003, Nick Clifton wrote:

> > Attached patches are aimed to resurrect some broken or incompatible
> > with MS linker features of arm-wince-pe support:
> >  - partial linking (ld -r)
> >  - flags of special sections
> >  - relocations
>
> These patches contain quite a few different changes/fixes, so I am
> going to go through them one by one over the next few days.

Please review one more patch. It fixes some more issues
with partial relocation. The patch should be applied after the mentioned
above 'ld -r' related one. (You have already applied it.)


2003-12-05  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>

	* coff-arm.c (aoutarm_std_reloc_howto): [ARM_WINCE] Synchronize ARM_26D
	relocation howto with ARM_26 one for consistency.
	(coff_arm_relocate_section): Set partial_inplace for ARM_26 relocations
	that will be converted to ARM_26D ones, since we always want 'done'
	relocations to be reflected in section's data.
	(coff_arm_relocate_section): [ARM_WINCE] Quick fix for BL instruction
	offset.
	(_bfd_final_link_relocate): Do not modify "inplace" data, if not
	requested.


diff -rNc3pad binutils-031118.orig/bfd/coff-arm.c binutils-031118/bfd/coff-arm.c
*** binutils-031118.orig/bfd/coff-arm.c	Mon Nov 24 18:39:44 2003
--- binutils-031118/bfd/coff-arm.c	Mon Nov 24 16:29:26 2003
*************** static reloc_howto_type aoutarm_std_relo
*** 268,274 ****
  	   2,
  	   2,
  	   24,
! 	   FALSE,
  	   0,
  	   complain_overflow_dont,
  	   aoutarm_fix_pcrel_26_done,
--- 268,274 ----
  	   2,
  	   2,
  	   24,
! 	   TRUE,
  	   0,
  	   complain_overflow_dont,
  	   aoutarm_fix_pcrel_26_done,
*************** static reloc_howto_type aoutarm_std_relo
*** 276,282 ****
  	   FALSE,
  	   0x00ffffff,
  	   0x0,
! 	   FALSE),
      HOWTO (ARM_32,
  	   0,
  	   2,
--- 276,282 ----
  	   FALSE,
  	   0x00ffffff,
  	   0x0,
! 	   PCRELOFFSET),
      HOWTO (ARM_32,
  	   0,
  	   2,
*************** coff_arm_relocate_section (output_bfd, i
*** 1250,1256 ****
           when doing a relocatable link.  However, we want to convert
           ARM_26 to ARM_26D relocs if possible.  We return a fake howto in
           this case without pcrel_offset set, and adjust the addend to
!          compensate.  */
        if (rel->r_type == ARM_26
            && h != NULL
            && info->relocatable
--- 1250,1257 ----
           when doing a relocatable link.  However, we want to convert
           ARM_26 to ARM_26D relocs if possible.  We return a fake howto in
           this case without pcrel_offset set, and adjust the addend to
!          compensate. 'partial_inplace' is also set, since we want 'done'
!          relocations to be reflected in section's data. */
        if (rel->r_type == ARM_26
            && h != NULL
            && info->relocatable
*************** coff_arm_relocate_section (output_bfd, i
*** 1269,1280 ****
      	       complain_overflow_signed,
      	       aoutarm_fix_pcrel_26 ,
      	       "ARM_26",
!     	       FALSE,
      	       0x00ffffff,
      	       0x00ffffff,
!     	       FALSE);

            addend -= rel->r_vaddr - input_section->vma;
            howto = &fake_arm26_reloc;
          }

--- 1270,1286 ----
      	       complain_overflow_signed,
      	       aoutarm_fix_pcrel_26 ,
      	       "ARM_26",
!     	       TRUE,            /* partial_inplace */
      	       0x00ffffff,
      	       0x00ffffff,
!     	       FALSE);          /* pcrel_offset */

            addend -= rel->r_vaddr - input_section->vma;
+ #ifdef ARM_WINCE
+           /* FIXME: I don't know why, but the hack is necessary for correct
+                     generation of bl's instruction offset. */
+           addend -= 8;
+ #endif
            howto = &fake_arm26_reloc;
          }

diff -rNc3pad binutils-031118.orig/bfd/reloc.c binutils-031118/bfd/reloc.c
*** binutils-031118.orig/bfd/reloc.c	Fri Oct 31 08:32:46 2003
--- binutils-031118/bfd/reloc.c	Sun Nov 23 21:33:24 2003
*************** _bfd_final_link_relocate (reloc_howto_ty
*** 1353,1358 ****
--- 1353,1361 ----
    if (address > input_section->_raw_size)
      return bfd_reloc_outofrange;

+   if (!howto->partial_inplace)
+     return bfd_reloc_ok;  /* Do not modify "inplace" data, if not requested. */
+
    /* This function assumes that we are dealing with a basic relocation
       against a symbol.  We want to compute the value of the symbol to
       relocate to.  This is just VALUE, the value of the symbol, plus


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2003-12-05 12:48   ` Dmitry Semyonov
@ 2003-12-11 17:54     ` Nick Clifton
  2003-12-11 19:05       ` Dmitry Semyonov
  0 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2003-12-11 17:54 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

  [Sorry about the delay in replying - I have been caught up in all
  kinds of work here].

> With my patch applied the warnings are gone away.

I see - that makes things a lot clearer.  I think that your approach
is OK, but it does not go far enough.  The PE spec mandates the
section flags for quite a few sections, not just the ones you
covered.  So how about this alternative patch (attached) ?  Would you
mind trying it out and letting me know if it works ?

> Although there could be still a source of possible problem --
> alignment is not set inside the section flags by bfd.

Hmm - since at the moment we do not appear to be setting the alignment
for any sections adding the necessary flags in would probably not
hurt.  I wonder if we can deduce the alignment based on the target ?
I suspect that 4byte alignment is going to be the default for the
.text section of most targets, so we may be able to just set that
along with the other flags and then only modify if necessary for
individual targets.

Cheers
        Nick

Index: bfd/peXXigen.c
===================================================================
RCS file: /cvs/src/src/bfd/peXXigen.c,v
retrieving revision 1.19
diff -c -3 -p -r1.19 peXXigen.c
*** bfd/peXXigen.c	30 Nov 2003 18:40:41 -0000	1.19
--- bfd/peXXigen.c	11 Dec 2003 17:47:54 -0000
*************** _bfd_XXi_swap_scnhdr_out (abfd, in, out)
*** 953,964 ****
       (0x02000000).  Also, the resource data should also be read and
       writable.  */
  
!   /* FIXME: alignment is also encoded in this field, at least on ppc (krk) */
!   /* FIXME: even worse, I don't see how to get the original alignment field*/
!   /*        back...                                                        */
! 
    {
      int flags = scnhdr_int->s_flags;
  
      H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
    }
--- 953,1001 ----
       (0x02000000).  Also, the resource data should also be read and
       writable.  */
  
!   /* FIXME: alignment is also encoded in this field, at least on PPC and
!      ARM-WINCE.  */
!   /* FIXME: even worse, I don't see how to get the original alignment
!      field back ...  */
    {
+     /* The PE File Format specification mandates certain flags
+        for certain sections.  This is encoded in this array.  */
+     typedef struct
+     {
+       const char * 	name;
+       unsigned long	must_have;
+     }
+     pe_section_flags;
+     
+     pe_section_flags known_sections [] =
+       {
+ 	{ ".arch",  IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE | IMAGE_SCN_ALIGN_8BYTES },
+ 	{ ".bss",   IMAGE_SCN_CNT_UNINITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE },
+ 	{ ".data",  IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE },
+ 	{ ".edata", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ },
+ 	{ ".idata", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE },
+ 	{ ".pdata", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ },
+ 	{ ".rdata", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ },
+ 	{ ".reloc", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_DISCARDABLE },
+ 	{ ".rsrc",  IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE },
+ 	{ ".text" , IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ },
+ 	{ ".tls",   IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE },
+ 	{ ".xdata", IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ },
+ 	{ NULL, 0}
+       };
+ 
+     pe_section_flags * p;
      int flags = scnhdr_int->s_flags;
+ 
+     for (p = known_sections; p->name; p++)
+       if (strcmp (scnhdr_int->s_name, p->name) == 0)
+ 	{
+ 	  /* We have defaulted to adding the IMAGE_SCN_MEM_WRITE flag, but now
+ 	     we know that this specific section may or may not want this flag.  */
+ 	  flags &= ~IMAGE_SCN_MEM_WRITE;
+ 	  flags |= p->must_have;
+ 	  break;
+ 	}
  
      H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
    }
        

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

* Re: arm-wince-pe support resurrection
  2003-12-11 17:54     ` Nick Clifton
@ 2003-12-11 19:05       ` Dmitry Semyonov
  2003-12-15 11:51         ` Nick Clifton
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2003-12-11 19:05 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick,

On Thu, 11 Dec 2003, Nick Clifton wrote:

> The PE spec mandates the section flags for quite a few sections, not
> just the ones you covered.  So how about this alternative patch
> (attached) ?  Would you mind trying it out and letting me know if it
> works ?

Yes, it works fine, (at least for .text, .data, .rdata, and .bss
sections my object file has).


> > Although there could be still a source of possible problem --
> > alignment is not set inside the section flags by bfd.
>
> Hmm - since at the moment we do not appear to be setting the alignment
> for any sections adding the necessary flags in would probably not
> hurt.  I wonder if we can deduce the alignment based on the target ?
> I suspect that 4byte alignment is going to be the default for the
> .text section of most targets, so we may be able to just set that
> along with the other flags and then only modify if necessary for
> individual targets.

This sounds reasonable.
In fact, you may consider it as a TODO item for future.
Up to now I had no problems with zero alignment flags, so currently
this is not a high priority issue for me.


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2003-12-11 19:05       ` Dmitry Semyonov
@ 2003-12-15 11:51         ` Nick Clifton
  0 siblings, 0 replies; 22+ messages in thread
From: Nick Clifton @ 2003-12-15 11:51 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

> Yes, it works fine, (at least for .text, .data, .rdata, and .bss
> sections my object file has).

Good - I have checked the patch in.

Cheers
        Nick

bfd/ChangeLog
2003-12-15  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>
	    Nick Clifton  <nickc@redhat.com>

	* peXXigen.c (_bfd_XXi_swap_scnhdr_out): Ensure that correct flags
	are set on known section types.
	
        

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

* Re: arm-wince-pe support resurrection
  2003-12-05 19:39   ` Dmitry Semyonov
@ 2003-12-15 15:20     ` Nick Clifton
  2003-12-15 15:54       ` Dmitry Semyonov
  0 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2003-12-15 15:20 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

  [Sorry for the slow response on this patch]

> *************** coff_arm_relocate_section (output_bfd, i
> *** 1269,1280 ****
>       	       complain_overflow_signed,
>       	       aoutarm_fix_pcrel_26 ,
>       	       "ARM_26",
> !     	       FALSE,
>       	       0x00ffffff,
>       	       0x00ffffff,
> !     	       FALSE);
>
>             addend -= rel->r_vaddr - input_section->vma;
>             howto = &fake_arm26_reloc;
>           }
>
> --- 1270,1286 ----
>       	       complain_overflow_signed,
>       	       aoutarm_fix_pcrel_26 ,
>       	       "ARM_26",
> !     	       TRUE,            /* partial_inplace */
>       	       0x00ffffff,
>       	       0x00ffffff,
> !     	       FALSE);          /* pcrel_offset */
>
>             addend -= rel->r_vaddr - input_section->vma;
> + #ifdef ARM_WINCE
> +           /* FIXME: I don't know why, but the hack is necessary for correct
> +                     generation of bl's instruction offset. */
> +           addend -= 8;
> + #endif
>             howto = &fake_arm26_reloc;
>           }


This looks like a hack.  It would be much better if we could find out
why this was needed and fix the *real* bug.  Besides, it looks like
this problem has already been encountered before.  The code just
beyond this patch reads:

  #ifdef ARM_WINCE
      /* MS ARM-CE makes the reloc relative to the opcode's pc, not
	 the next opcode's pc, so is off by one.  */
  #if 0 /* This appears to have been true for WINCE 2.0, but it is not
	 true for WINCE 3.0.  */
      if (howto->pc_relative && !info->relocatable)
	addend -= 8;
  #endif
  #endif

So - it looks like this might be dependent upon the version of WinCE
that you are using.  Which version do you use ?

Cheers
        Nick
        

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

* Re: arm-wince-pe support resurrection
  2003-12-15 15:20     ` Nick Clifton
@ 2003-12-15 15:54       ` Dmitry Semyonov
  2003-12-16 17:43         ` Nick Clifton
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2003-12-15 15:54 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Hello Nick.

On Mon, 15 Dec 2003, Nick Clifton wrote:

> > *************** coff_arm_relocate_section (output_bfd, i
> > *** 1269,1280 ****
> >       	       complain_overflow_signed,
> >       	       aoutarm_fix_pcrel_26 ,
> >       	       "ARM_26",
> > !     	       FALSE,
> >       	       0x00ffffff,
> >       	       0x00ffffff,
> > !     	       FALSE);
> >
> >             addend -= rel->r_vaddr - input_section->vma;
> >             howto = &fake_arm26_reloc;
> >           }
> >
> > --- 1270,1286 ----
> >       	       complain_overflow_signed,
> >       	       aoutarm_fix_pcrel_26 ,
> >       	       "ARM_26",
> > !     	       TRUE,            /* partial_inplace */
> >       	       0x00ffffff,
> >       	       0x00ffffff,
> > !     	       FALSE);          /* pcrel_offset */
> >
> >             addend -= rel->r_vaddr - input_section->vma;
> > + #ifdef ARM_WINCE
> > +           /* FIXME: I don't know why, but the hack is necessary for correct
> > +                     generation of bl's instruction offset. */
> > +           addend -= 8;
> > + #endif
> >             howto = &fake_arm26_reloc;
> >           }
>
>
> This looks like a hack.  It would be much better if we could find out
> why this was needed and fix the *real* bug.  Besides, it looks like
> this problem has already been encountered before.  The code just
> beyond this patch reads:
>
>   #ifdef ARM_WINCE
>       /* MS ARM-CE makes the reloc relative to the opcode's pc, not
> 	 the next opcode's pc, so is off by one.  */
>   #if 0 /* This appears to have been true for WINCE 2.0, but it is not
> 	 true for WINCE 3.0.  */
>       if (howto->pc_relative && !info->relocatable)
> 	addend -= 8;
>   #endif
>   #endif
>
> So - it looks like this might be dependent upon the version of WinCE
> that you are using.  Which version do you use ?

WindowsCE.net Version 4.2

Note that my hack with pc adjustment, and the switched off one apply
to mutually exclusive cases (based on the info->relocatable field).

As I understand, in my case, the relocation is resolved during creation
of object files with GNU as. So the code is not further affected by
WinCE tools.


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2003-12-15 15:54       ` Dmitry Semyonov
@ 2003-12-16 17:43         ` Nick Clifton
  2003-12-16 20:27           ` Dmitry Semyonov
  0 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2003-12-16 17:43 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

> Note that my hack with pc adjustment, and the switched off one apply
> to mutually exclusive cases (based on the info->relocatable field).

True - I had not spotted that.

> As I understand, in my case, the relocation is resolved during
> creation of object files with GNU as. So the code is not further
> affected by WinCE tools.

Ok - that makes sense.  But now I have just noticed another bit of
your patch that I think might be a bigger problem:

  --- binutils-031118/bfd/reloc.c	Sun Nov 23 21:33:24 2003
  *************** _bfd_final_link_relocate (reloc_howto_ty
  *** 1353,1358 ****
  --- 1353,1361 ----
      if (address > input_section->_raw_size)
        return bfd_reloc_outofrange;

  +   if (!howto->partial_inplace)
  +     return bfd_reloc_ok;  /* Do not modify "inplace" data, if not requested. */
  +

This looks wrong to me.  First of all you are modifying a generic
routine which is used by all ports, not just the arm-wince-pe, so any
change has to be reviewed carefully.

Secondly this patch appears to be preventing _bfd_final_link_relocate
from performing any relocation for which partial_inplace is FALSE.
This would include all ELF ports which use RELA relocations, which
cannot be right.

What was the purpose of this part of the patch ?  Were you trying to
stop the ARM_26D reloc from being processed any further ?  If so then
it would probably be easier to change a different field, eg the
bitsize.

Cheers
        Nick
        

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

* Re: arm-wince-pe support resurrection
  2003-12-16 17:43         ` Nick Clifton
@ 2003-12-16 20:27           ` Dmitry Semyonov
  2003-12-22 15:22             ` Dmitry Semyonov
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2003-12-16 20:27 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Hello Nick,

On Tue, 16 Dec 2003, Nick Clifton wrote:

>   --- binutils-031118/bfd/reloc.c	Sun Nov 23 21:33:24 2003
>   *************** _bfd_final_link_relocate (reloc_howto_ty
>   *** 1353,1358 ****
>   --- 1353,1361 ----
>       if (address > input_section->_raw_size)
>         return bfd_reloc_outofrange;
>
>   +   if (!howto->partial_inplace)
>   +     return bfd_reloc_ok;  /* Do not modify "inplace" data, if not requested. */
>   +
>
> This looks wrong to me.  First of all you are modifying a generic
> routine which is used by all ports, not just the arm-wince-pe, so any
> change has to be reviewed carefully.
>
> Secondly this patch appears to be preventing _bfd_final_link_relocate
> from performing any relocation for which partial_inplace is FALSE.
> This would include all ELF ports which use RELA relocations, which
> cannot be right.
>
> What was the purpose of this part of the patch ?

Sorry, I've made the change under wrong suspicions.

What I'm trying to do is prevent modification of "inplace" section
data if partial_inplace is set to FALSE and the relocation record
remains in resulting object (or executable) file. Obviously, in this
case we need only to modify the relocation record. This kind of
processing is implemented in bfd_perform_relocation() via the
modification of arelent *reloc_entry structure.

It seems I need a closer look on the sources.


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2003-12-16 20:27           ` Dmitry Semyonov
@ 2003-12-22 15:22             ` Dmitry Semyonov
  2004-01-02 13:42               ` Nick Clifton
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2003-12-22 15:22 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick,

On Tue, 16 Dec 2003, Dmitry Semyonov wrote:

> On Tue, 16 Dec 2003, Nick Clifton wrote:
>
> >   --- binutils-031118/bfd/reloc.c	Sun Nov 23 21:33:24 2003
> >   *************** _bfd_final_link_relocate (reloc_howto_ty
> >   *** 1353,1358 ****
> >   --- 1353,1361 ----
> >       if (address > input_section->_raw_size)
> >         return bfd_reloc_outofrange;
> >
> >   +   if (!howto->partial_inplace)
> >   +     return bfd_reloc_ok;  /* Do not modify "inplace" data, if not requested. */
> >   +
> >
> > This looks wrong to me.  First of all you are modifying a generic
> > routine which is used by all ports, not just the arm-wince-pe, so any
> > change has to be reviewed carefully.
> >
> > Secondly this patch appears to be preventing _bfd_final_link_relocate
> > from performing any relocation for which partial_inplace is FALSE.
> > This would include all ELF ports which use RELA relocations, which
> > cannot be right.
> >
> > What was the purpose of this part of the patch ?

Nothing shall be relocated inside raw sections data during partial
linking if howto->partial_inplace is set to FALSE.

What would you say about the following patch instead of the above
one?

Note that I can only verify the partial linking since the final link
stage is performed with MS tools.


*** coff-arm.c.1.49	Wed Dec 17 21:29:45 2003
--- coff-arm.c	Fri Dec 19 23:07:11 2003
*************** coff_arm_relocate_section (output_bfd, i
*** 1734,1743 ****
  #endif
        else
  #endif /* THUMBEXTENSION */
!         rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
!                                           contents,
!                                           rel->r_vaddr - input_section->vma,
!                                           val, addend);
  #if 1 /* THUMBEXTENSION */
        /* FIXME:
  	 Is this the best way to fix up thumb addresses? krk@cygnus.com
--- 1734,1746 ----
  #endif
        else
  #endif /* THUMBEXTENSION */
!         if (info->relocatable && ! howto->partial_inplace)
!             rstat = bfd_reloc_ok;
!         else
!             rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
!                                               contents,
!                                               rel->r_vaddr - input_section->vma,
!                                               val, addend);
  #if 1 /* THUMBEXTENSION */
        /* FIXME:
  	 Is this the best way to fix up thumb addresses? krk@cygnus.com


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2003-12-22 15:22             ` Dmitry Semyonov
@ 2004-01-02 13:42               ` Nick Clifton
  2004-01-08 10:37                 ` Dmitry Semyonov
  0 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2004-01-02 13:42 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

>> > What was the purpose of this part of the patch ?
>
> Nothing shall be relocated inside raw sections data during partial
> linking if howto->partial_inplace is set to FALSE.
>
> What would you say about the following patch instead of the above
> one?

Much better - I defintely prefer patches to target specific files as
opposed to generic files.

> Note that I can only verify the partial linking since the final link
> stage is performed with MS tools.
>
>
> *** coff-arm.c.1.49	Wed Dec 17 21:29:45 2003
> --- coff-arm.c	Fri Dec 19 23:07:11 2003
> *************** coff_arm_relocate_section (output_bfd, i
> *** 1734,1743 ****
>   #endif
>         else
>   #endif /* THUMBEXTENSION */
> !         rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
> !                                           contents,
> !                                           rel->r_vaddr - input_section->vma,
> !                                           val, addend);
>   #if 1 /* THUMBEXTENSION */
>         /* FIXME:
>   	 Is this the best way to fix up thumb addresses? krk@cygnus.com
> --- 1734,1746 ----
>   #endif
>         else
>   #endif /* THUMBEXTENSION */
> !         if (info->relocatable && ! howto->partial_inplace)
> !             rstat = bfd_reloc_ok;
> !         else
> !             rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
> !                                               contents,
> !                                               rel->r_vaddr - input_section->vma,
> !                                               val, addend);
>   #if 1 /* THUMBEXTENSION */
>         /* FIXME:
>   	 Is this the best way to fix up thumb addresses? krk@cygnus.com

A simpler version of this patch would be to set the 'done' variable if
performing a relocatable link and the reloc has partial_inplace set as
false...

Cheers
        Nick
        

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

* Re: arm-wince-pe support resurrection
  2004-01-02 13:42               ` Nick Clifton
@ 2004-01-08 10:37                 ` Dmitry Semyonov
  2004-01-08 16:48                   ` Nick Clifton
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Semyonov @ 2004-01-08 10:37 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick,

On Fri, 2 Jan 2004, Nick Clifton wrote:

> >> > What was the purpose of this part of the patch ?
> >
> > Nothing shall be relocated inside raw sections data during partial
> > linking if howto->partial_inplace is set to FALSE.

> > *** coff-arm.c.1.49	Wed Dec 17 21:29:45 2003
> > --- coff-arm.c	Fri Dec 19 23:07:11 2003
> > *************** coff_arm_relocate_section (output_bfd, i
> > *** 1734,1743 ****
> >   #endif
> >         else
> >   #endif /* THUMBEXTENSION */
> > !         rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
> > !                                           contents,
> > !                                           rel->r_vaddr - input_section->vma,
> > !                                           val, addend);
> >   #if 1 /* THUMBEXTENSION */
> >         /* FIXME:
> >   	 Is this the best way to fix up thumb addresses? krk@cygnus.com
> > --- 1734,1746 ----
> >   #endif
> >         else
> >   #endif /* THUMBEXTENSION */
> > !         if (info->relocatable && ! howto->partial_inplace)
> > !             rstat = bfd_reloc_ok;
> > !         else
> > !             rstat = _bfd_final_link_relocate (howto, input_bfd, input_section,
> > !                                               contents,
> > !                                               rel->r_vaddr - input_section->vma,
> > !                                               val, addend);
> >   #if 1 /* THUMBEXTENSION */
> >         /* FIXME:
> >   	 Is this the best way to fix up thumb addresses? krk@cygnus.com
>
> A simpler version of this patch would be to set the 'done' variable if
> performing a relocatable link and the reloc has partial_inplace set as
> false...

Simpler but not safer. The if..else statement before
_bfd_final_link_relocate is conditionally switched on via
#if 1 /* THUMBEXTENSION */
preprocessor directive.

My patch has nothing to do with THUMBEXTENSION, so I don't want the
mentioned conditional compilation to affect the patch.


...Bye..Dmitry.

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

* Re: arm-wince-pe support resurrection
  2004-01-08 10:37                 ` Dmitry Semyonov
@ 2004-01-08 16:48                   ` Nick Clifton
  2004-01-08 18:39                     ` Dmitry Semyonov
  0 siblings, 1 reply; 22+ messages in thread
From: Nick Clifton @ 2004-01-08 16:48 UTC (permalink / raw)
  To: Dmitry.Semyonov; +Cc: binutils

Hi Dmitry,

>> A simpler version of this patch would be to set the 'done' variable if
>> performing a relocatable link and the reloc has partial_inplace set as
>> false...
>
> Simpler but not safer. The if..else statement before
> _bfd_final_link_relocate is conditionally switched on via
> #if 1 /* THUMBEXTENSION */
> preprocessor directive.
>
> My patch has nothing to do with THUMBEXTENSION, so I don't want the
> mentioned conditional compilation to affect the patch.

Fair enough.  In which case I have approved and applied yoru version
of the patch.

Cheers
        Nick

bfd/ChangeLog
2004-01-08  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>

	* coff-arm.c (coff_arm_relocate_section): Do not alter relocs that
	are not partial_inplace during a relocatable link.

        

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

* Re: arm-wince-pe support resurrection
  2004-01-08 16:48                   ` Nick Clifton
@ 2004-01-08 18:39                     ` Dmitry Semyonov
  0 siblings, 0 replies; 22+ messages in thread
From: Dmitry Semyonov @ 2004-01-08 18:39 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

Nick,

On Thu, 8 Jan 2004, Nick Clifton wrote:

> Fair enough.  In which case I have approved and applied yoru version
> of the patch.

> bfd/ChangeLog
> 2004-01-08  Dmitry Semyonov  <Dmitry.Semyonov@oktet.ru>
>
> 	* coff-arm.c (coff_arm_relocate_section): Do not alter relocs that
> 	are not partial_inplace during a relocatable link.

Please, don't forget to apply the remaining part from the following
message:
http://sources.redhat.com/ml/binutils/2003-12/msg00128.html
(Everything relevant to coff-arm.c).


...Bye..Dmitry.

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

end of thread, other threads:[~2004-01-08 18:39 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-20 13:31 arm-wince-pe support resurrection Dmitry Semyonov
2003-12-01 18:43 ` Nick Clifton
2003-12-05 19:39   ` Dmitry Semyonov
2003-12-15 15:20     ` Nick Clifton
2003-12-15 15:54       ` Dmitry Semyonov
2003-12-16 17:43         ` Nick Clifton
2003-12-16 20:27           ` Dmitry Semyonov
2003-12-22 15:22             ` Dmitry Semyonov
2004-01-02 13:42               ` Nick Clifton
2004-01-08 10:37                 ` Dmitry Semyonov
2004-01-08 16:48                   ` Nick Clifton
2004-01-08 18:39                     ` Dmitry Semyonov
2003-12-04 17:47 ` Nick Clifton
2003-12-04 17:51 ` Nick Clifton
2003-12-04 18:11 ` Nick Clifton
2003-12-05 12:48   ` Dmitry Semyonov
2003-12-11 17:54     ` Nick Clifton
2003-12-11 19:05       ` Dmitry Semyonov
2003-12-15 11:51         ` Nick Clifton
2003-12-04 18:19 ` Nick Clifton
2003-12-04 19:34   ` Dmitry Semyonov
2003-12-05 11:29     ` 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).