This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: puzzled - old release works, newer doesn't
Hi all,
Pedro Alves wrote:
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?
Ignore me here. Obviously in gas/config/te-wince-pe.h. Missed that
before. Humm, this file isn't included anywhere.
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.
I have reduced my patches against both cvs20050202, which is the version
I am using to work on the cegcc toolchain (http://cegcc.berlios.de), and
cvs head. If you tried my previous patch and saw no differences, it was
because you need this full patch.
I am suffering from weird network problems, so I can't do a cvs diff
now. Because of that I hand edited the patches to remove some messing
I've done regarding target underscoring. That part of my original
patches should not make any difference to the problem at hand now.
Some of the code in the patches is found in several places in the web,
and I don't know who is the original author. Sorry for that.
Cheers,
Pedro Alves
Index: bfd/coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.63
diff -u -r1.63 coff-arm.c
--- bfd/coff-arm.c 16 Mar 2006 12:20:15 -0000 1.63
+++ bfd/coff-arm.c 26 Apr 2006 22:29:05 -0000
@@ -220,7 +220,7 @@
complain_overflow_dont,
aoutarm_fix_pcrel_26_done,
"ARM_26D",
- FALSE,
+ TRUE,
0x00ffffff,
0x0,
PCRELOFFSET),
@@ -233,7 +233,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_32",
- FALSE,
+ TRUE,
0xffffffff,
0xffffffff,
PCRELOFFSET),
@@ -246,7 +246,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_RVA32",
- FALSE,
+ TRUE,
0xffffffff,
0xffffffff,
PCRELOFFSET),
@@ -294,7 +294,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_SECTION",
- FALSE,
+ TRUE,
0x0000ffff,
0x0000ffff,
PCRELOFFSET),
@@ -307,7 +307,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_SECREL",
- FALSE,
+ TRUE,
0xffffffff,
0xffffffff,
PCRELOFFSET),
@@ -1215,6 +1215,9 @@
#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 (howto->pc_relative && !info->relocatable)
+ addend -= 8;
#endif
/* If we are doing a relocatable link, then we can just ignore
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 26 Apr 2006 22:30:19 -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 26 Apr 2006 22:30:19 -0000
@@ -1,3 +1,4 @@
+#define TE_WINCE
#define TE_PE
#define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) /* Can have @'s inside labels. */
Index: ld/pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.83
diff -u -r1.83 pe-dll.c
--- ld/pe-dll.c 31 Jan 2006 22:08:14 -0000 1.83
+++ ld/pe-dll.c 26 Apr 2006 22:31:22 -0000
@@ -216,6 +216,9 @@
static autofilter_entry_type autofilter_symbollist[] =
{
+ { "DllMain", 7 },
+ { "DllMainCRTStartup", 17 },
+ { "_DllMainCRTStartup", 18 },
{ "DllMain@12", 10 },
{ "DllEntryPoint@0", 15 },
{ "DllMainCRTStartup@12", 20 },
@@ -226,12 +229,14 @@
{ "_pei386_runtime_relocator", 25 },
{ "do_pseudo_reloc", 15 },
{ "cygwin_crt0", 11 },
+ { ".text", 5 },
{ NULL, 0 }
};
/* Do not specify library suffix explicitly, to allow for dllized versions. */
static autofilter_entry_type autofilter_liblist[] =
{
+ { "libcegcc", 8 },
{ "libcygwin", 9 },
{ "libgcc", 6 },
{ "libstdc++", 9 },
@@ -261,9 +266,10 @@
static autofilter_entry_type autofilter_symbolprefixlist[] =
{
- /* { "__imp_", 6 }, */
+ { "__imp_", 6 },
/* Do __imp_ explicitly to save time. */
{ "__rtti_", 7 },
+ { ".idata$", 7 },
/* Don't re-export auto-imported symbols. */
{ "_nm_", 4 },
{ "__builtin_", 10 },
@@ -1130,9 +1167,14 @@
asymbol **symbols;
int nsyms, symsize;
+#if 0
/* If it's not loaded, we don't need to relocate it this way. */
+ /* sometimes .data section gets no SEC_LOAD flag, but contains relocs */
if (!(s->output_section->flags & SEC_LOAD))
continue;
+#endif
+ if (strncmp (bfd_get_section_name (abfd, s), ".idata",6) == 0)
+ continue;
/* I don't know why there would be a reloc for these, but I've
seen it happen - DJ */
@@ -1780,6 +1824,14 @@
0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
};
+static unsigned char arm_jtab[] =
+{
+ 0x00, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */
+ 0x00, 0xf0, 0x9c, 0xe5, /* ldr pc, [ip] */
+ 0, 0, 0, 0
+};
+
+
static bfd *
make_one (def_file_export *exp, bfd *parent)
{
@@ -1801,6 +1853,10 @@
jmp_bytes = jmp_sh_bytes;
jmp_byte_count = sizeof (jmp_sh_bytes);
break;
+ case PE_ARCH_arm:
+ jmp_bytes = arm_jtab;
+ jmp_byte_count = sizeof (arm_jtab);
+ break;
case PE_ARCH_mips:
jmp_bytes = jmp_mips_bytes;
jmp_byte_count = sizeof (jmp_mips_bytes);
@@ -1873,6 +1933,9 @@
case PE_ARCH_sh:
quick_reloc (abfd, 8, BFD_RELOC_32, 2);
break;
+ case PE_ARCH_arm:
+ quick_reloc (abfd, 8, BFD_RELOC_32, 2);
+ break;
case PE_ARCH_mips:
quick_reloc (abfd, 0, BFD_RELOC_HI16_S, 2);
quick_reloc (abfd, 0, BFD_RELOC_LO16, 0); /* MIPS_R_PAIR */
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.113
diff -u -r1.113 pe.em
--- ld/emultempl/pe.em 24 Nov 2005 06:02:08 -0000 1.113
+++ ld/emultempl/pe.em 26 Apr 2006 22:31:27 -0000
@@ -283,7 +283,7 @@
D(MajorImageVersion,"__major_image_version__", 1),
D(MinorImageVersion,"__minor_image_version__", 0),
#ifdef TARGET_IS_armpe
- D(MajorSubsystemVersion,"__major_subsystem_version__", 2),
+ D(MajorSubsystemVersion,"__major_subsystem_version__", 3),
#else
D(MajorSubsystemVersion,"__major_subsystem_version__", 4),
#endif
diff -Nur binutils-cvs20050202_2/bfd/coff-arm.c binutils-cvs20050202/bfd/coff-arm.c
--- binutils-cvs20050202_2/bfd/coff-arm.c 2005-01-31 23:13:16.000000000 +0000
+++ binutils-cvs20050202/bfd/coff-arm.c 2005-12-11 10:46:00.000000000 +0000
@@ -273,7 +273,7 @@
complain_overflow_dont,
aoutarm_fix_pcrel_26_done,
"ARM_26D",
- FALSE,
+ TRUE,
0x00ffffff,
0x0,
PCRELOFFSET),
@@ -286,7 +286,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_32",
- FALSE,
+ TRUE,
0xffffffff,
0xffffffff,
PCRELOFFSET),
@@ -299,7 +299,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_RVA32",
- FALSE,
+ TRUE,
0xffffffff,
0xffffffff,
PCRELOFFSET),
@@ -347,7 +347,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_SECTION",
- FALSE,
+ TRUE,
0x0000ffff,
0x0000ffff,
PCRELOFFSET),
@@ -360,7 +360,7 @@
complain_overflow_bitfield,
coff_arm_reloc,
"ARM_SECREL",
- FALSE,
+ TRUE,
0xffffffff,
0xffffffff,
PCRELOFFSET),
@@ -1288,6 +1295,8 @@
#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 (howto->pc_relative && !info->relocatable)
+ addend -= 8;
#endif
/* If we are doing a relocatable link, then we can just ignore
@@ -1303,7 +1312,7 @@
VxWorks and EPOC-PE targets, but it is also known that it
was suppressed for other ARM targets. This ought to be
sorted out one day. */
-#ifdef ARM_COFF_BUGFIX
+#if 1//def ARM_COFF_BUGFIX
/* We must not ignore the symbol value. If the symbol is
within the same section, the relocation should have already
been fixed, but if it is not, we'll be handed a reloc into
diff -Nur binutils-cvs20050202_2/gas/config/tc-arm.c binutils-cvs20050202/gas/config/tc-arm.c
--- binutils-cvs20050202_2/gas/config/tc-arm.c 2005-01-31 23:18:26.000000000 +0000
+++ binutils-cvs20050202/gas/config/tc-arm.c 2005-12-08 21:59:08.000000000 +0000
@@ -1106,7 +1106,10 @@
}
inst.reloc.exp.X_op = O_symbol;
- inst.reloc.exp.X_add_number = ((int) entry) * 4 - 8;
+ inst.reloc.exp.X_add_number = ((int) entry) * 4;
+#ifndef TE_WINCE
+ inst.reloc.exp.X_add_number -= 8; /* PC relative adjust. */
+#endif
inst.reloc.exp.X_add_symbol = pool->symbol;
return SUCCESS;
@@ -2404,7 +2407,9 @@
return FAIL;
inst.reloc.type = BFD_RELOC_ARM_CP_OFF_IMM;
+#ifndef TE_WINCE
inst.reloc.exp.X_add_number -= 8; /* PC rel adjust. */
+#endif
inst.reloc.pc_rel = 1;
inst.instruction |= (REG_PC << 16);
pre_inc = PRE_INDEX;
@@ -2540,7 +2545,9 @@
return FAIL;
inst.reloc.type = BFD_RELOC_ARM_CP_OFF_IMM_S2;
- inst.reloc.exp.X_add_number -= 8; /* PC rel adjust. */
+#ifndef TE_WINCE
+ inst.reloc.exp.X_add_number -= 8; /* PC relative adjust. */
+#endif
inst.reloc.pc_rel = 1;
inst.instruction |= (REG_PC << 16);
pre_inc = PRE_INDEX;
@@ -3054,7 +3061,9 @@
inst.instruction |= HWOFFSET_IMM; /* The I bit. */
inst.reloc.type = BFD_RELOC_ARM_OFFSET_IMM8;
+#ifndef TE_WINCE
inst.reloc.exp.X_add_number -= 8; /* PC rel adjust. */
+#endif
inst.reloc.pc_rel = 1;
inst.instruction |= (REG_PC << 16);
diff -Nur binutils-cvs20050202_2/gas/config/te-pe.h binutils-cvs20050202/gas/config/te-pe.h
--- binutils-cvs20050202_2/gas/config/te-pe.h 2002-11-06 19:36:20.000000000 +0000
+++ binutils-cvs20050202/gas/config/te-pe.h 2005-12-04 19:26:56.000000000 +0000
@@ -1,3 +1,4 @@
+#define TE_WINCE
#define TE_PE
#define LEX_AT (LEX_BEGIN_NAME | LEX_NAME) /* Can have @'s inside labels. */
diff -Nur binutils-cvs20050202_2/ld/pe-dll.c binutils-cvs20050202/ld/pe-dll.c
--- binutils-cvs20050202_2/ld/pe-dll.c 2005-01-21 04:16:00.000000000 +0000
+++ binutils-cvs20050202/ld/pe-dll.c 2005-12-05 00:45:10.000000000 +0000
@@ -199,7 +199,7 @@
11 /* ARM_RVA32 */,
PE_ARCH_arm,
bfd_arch_arm,
- 1
+ 0
},
{
"epoc-pei-arm-little",
@@ -226,6 +226,7 @@
{ "_pei386_runtime_relocator", 25 },
{ "do_pseudo_reloc", 15 },
{ "cygwin_crt0", 11 },
+ { ".text", 5 },
{ NULL, 0 }
};
@@ -261,9 +262,10 @@
static autofilter_entry_type autofilter_symbolprefixlist[] =
{
- /* { "__imp_", 6 }, */
+ { "__imp_", 6 },
/* Do __imp_ explicitly to save time. */
{ "__rtti_", 7 },
+ { ".idata$", 7 },
/* Don't re-export auto-imported symbols. */
{ "_nm_", 4 },
{ "__builtin_", 10 },
@@ -735,8 +768,8 @@
else
{
/* xgettext:c-format */
- einfo (_("%XCannot export %s: symbol not found\n"),
- pe_def_file->exports[i].internal_name);
+ einfo (_("%XCannot export %s (%s): symbol not found\n"),
+ pe_def_file->exports[i].internal_name,pe_def_file->exports[i].name);
}
free (name);
}
@@ -1083,9 +1116,14 @@
asymbol **symbols;
int nsyms, symsize;
+#if 0
/* If it's not loaded, we don't need to relocate it this way. */
+ /* sometimes .data section gets no SEC_LOAD flag, but contains relocs */
if (!(s->output_section->flags & SEC_LOAD))
continue;
+#endif
+ if (strncmp (bfd_get_section_name (abfd, s), ".idata",6) == 0)
+ continue;
/* I don't know why there would be a reloc for these, but I've
seen it happen - DJ */
@@ -1733,6 +1773,14 @@
0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
};
+static unsigned char arm_jtab[] =
+{
+ 0x00, 0xc0, 0x9f, 0xe5, /* ldr ip, [pc] */
+ 0x00, 0xf0, 0x9c, 0xe5, /* ldr pc, [ip] */
+ 0, 0, 0, 0
+};
+
+
static bfd *
make_one (def_file_export *exp, bfd *parent)
{
@@ -1754,6 +1802,10 @@
jmp_bytes = jmp_sh_bytes;
jmp_byte_count = sizeof (jmp_sh_bytes);
break;
+ case PE_ARCH_arm:
+ jmp_bytes = arm_jtab;
+ jmp_byte_count = sizeof (arm_jtab);
+ break;
case PE_ARCH_mips:
jmp_bytes = jmp_mips_bytes;
jmp_byte_count = sizeof (jmp_mips_bytes);
@@ -1826,6 +1882,9 @@
case PE_ARCH_sh:
quick_reloc (abfd, 8, BFD_RELOC_32, 2);
break;
+ case PE_ARCH_arm:
+ quick_reloc (abfd, 8, BFD_RELOC_32, 2);
+ break;
case PE_ARCH_mips:
quick_reloc (abfd, 0, BFD_RELOC_HI16_S, 2);
quick_reloc (abfd, 0, BFD_RELOC_LO16, 0); /* MIPS_R_PAIR */