This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: puzzled - old release works, newer doesn't


Nick Clifton wrote:
Hi Danny,

The old environment is based on gcc 3.4.2, gas 2.13.2, binutils 2.15.
(Yes there's a mixup there.) The new environment is using gcc 4.1 and
binutils 2.16. In all versions, the target platform is "arm-wince-pe".

The person who created this distribution explains the mixup by saying
that the GAS from 2.13 works, whereas the one in newer binutils doesn't.

My personal experience with the 2.16 release appears to confirm that.

Are you upgrading to the new GCC new GAS and new LD all at the same time ? If not then that might be the cause.


Are you aware of the --support-old-code linker switch which is specific to the arm-wince-pe target ? Using this might help you.

Using the latest binutils sources from CVS repository might also help. If not then I would recommend comparing a disassembly of a working binary and broken binary to see where there are changes. (Do not compare the object files, but linked binaries. This should allow you to find out how relocs may have been processed differently).

Cheers
  Nick

Here is a patch that "fixes" the differences between binutils cvs 20050202 and cvs head. Probably I got it all wrong, but at least it
shows where the differences are. It fix most of the differences, but here is still something in the dll generation that produces quite
some differences. I am still looking into it.


That TE_WINCE addition is there because I didn't take the time yet to find the correct place. Any hints where that should be?

Mind you, the both the 20050202 and the head versions I tested with, have quite a few more patches applied.
This is just the portion that tries to fix the differences. It should also fix them for a pristine cvs version.
Attached is the tar.gz with the tests I used, inspired on Danny's tests.


Particularly, compiling this file (in the tar.gz) shows all the differences I could find.

   .global    _ctype_
   .text
   .global    global_sym
   .def    global_sym;    .scl    2;    .type    32;    .endef

_ctype_:
   .word    _ctype_+7

global_sym:
def_sym:
undef_sym:
   nop
   nop
   nop
   b    global_sym
   bl    global_sym
   beq    global_sym
   b    def_sym
   bl    def_sym
   beq    def_sym
   b    undef_sym
   bl    undef_sym
   ldr    r0, global_sym
   ldr    r0, def_sym
   ldr    r0, undef_sym

Cheers,
Pedro Alves

Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.256
diff -u -r1.256 tc-arm.c
--- gas/config/tc-arm.c    7 Apr 2006 15:11:19 -0000    1.256
+++ gas/config/tc-arm.c    25 Apr 2006 15:52:17 -0000
@@ -11182,8 +11182,12 @@
     then we just want to put out any pipeline compensation that the linker
     will need.  Otherwise we want to use the calculated base.  */
  if (fixP->fx_pcrel
-      && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
-      || arm_force_relocation (fixP)))
+    && ((fixP->fx_addsy && S_GET_SEGMENT (fixP->fx_addsy) != seg)
+#ifdef TE_WINCE
+    || (!S_IS_EXTERNAL (fixP->fx_addsy) && arm_force_relocation (fixP))))
+#else
+    || arm_force_relocation (fixP)))
+#endif
    base = 0;

switch (fixP->fx_r_type)
@@ -11220,7 +11224,19 @@
case BFD_RELOC_ARM_PCREL_BLX:
case BFD_RELOC_ARM_PLT32:
#ifdef TE_WINCE
- return base;
+ /*
+ * When handling fixups immediately, because we have already
+ * discovered the value of a symbol, or the address of the frag involved
+ * we must account for the offset by +8, as the OS loader will never see the reloc.
+ * see fixup_segment() in write.c
+ * The S_IS_EXTERNAL test handles the case of global symbols.
+ * Those need the calculated base, not just the pipe compensation the linker will need.
+ */
+ if (fixP->fx_pcrel && fixP->fx_addsy && (S_GET_SEGMENT (fixP->fx_addsy) == seg)
+ && (S_IS_EXTERNAL (fixP->fx_addsy) || !arm_force_relocation (fixP)))
+ return base + 8;
+ else
+ return base;
#else
return base + 8;
#endif
@@ -12107,10 +12123,16 @@
case BFD_RELOC_ARM_ROSEGREL32:
case BFD_RELOC_ARM_SBREL32:
case BFD_RELOC_32_PCREL:
+#ifdef TE_WINCE
+ if (seg->use_rela_p && !fixP->fx_done)
+ break;
+ if (fixP->fx_done || fixP->fx_pcrel)
+ md_number_to_chars (buf, value, 4);
+#else
if (fixP->fx_done || !seg->use_rela_p)
md_number_to_chars (buf, value, 4);
+#endif
break;
-
#ifdef OBJ_ELF
case BFD_RELOC_ARM_PREL31:
if (fixP->fx_done || !seg->use_rela_p)
Index: gas/config/te-pe.h
===================================================================
RCS file: /cvs/src/src/gas/config/te-pe.h,v
retrieving revision 1.2
diff -u -r1.2 te-pe.h
--- gas/config/te-pe.h 6 Nov 2002 19:36:19 -0000 1.2
+++ gas/config/te-pe.h 25 Apr 2006 15:52:24 -0000
@@ -1,3 +1,4 @@
+#define TE_WINCE
#define TE_PE
#define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) /* Can have @'s inside labels. */



Attachment: binutils-hunt.tar.gz
Description: application/gzip


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]