bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] --enable-runtime-pseude-reloc is neither byte order nor 64bit cl


From: Christof Petig
Subject: [PATCH] --enable-runtime-pseude-reloc is neither byte order nor 64bit clean
Date: Mon, 05 Jul 2004 16:04:39 +0200
User-agent: Mozilla/5.0 (X11; U; Linux ppc; de-AT; rv:1.7) Gecko/20040624 Debian/1.7-2

Hi,

this bug is from the "where no man has gone before" department: When
linking C++ code with mingw on a powerpc machine (iBook) the relocation table gets wrong:

[diff of objdump -s]
   409330 00000d04 04090000 00830586 04870300  ................
- 409340 00000000 08000000 e66c0000           .........l..
+ 409340 00000000 00000008 e66c0000           .........l..

(first one linked on an intel, last one linked on a powerpc)

[objdump -d]
00403680 <__pei386_runtime_relocator>:
   403680:       55                      push   %ebp
   403681:       89 e5                   mov    %esp,%ebp
   403683:       83 ec 18                sub    $0x18,%esp
   403686:       c7 44 24 08 00 00 40    movl   $0x400000,0x8(%esp)
   40368d:       00
   40368e:       c7 44 24 04 4c 93 40    movl   $0x40934c,0x4(%esp)
   403695:       00
   403696:       c7 04 24 44 93 40 00    movl   $0x409344,(%esp)
   40369d:       e8 9e ff ff ff          call   403640 <_do_pseudo_reloc>
   4036a2:       89 ec                   mov    %ebp,%esp
   4036a4:       5d                      pop    %ebp
   4036a5:       c3                      ret

This is clearly seen when compiling the testcase from
https://sourceforge.net/tracker/?func=detail&atid=102435&aid=873717&group_id=2435
.

Putting aside the fact that hunting down this bug costed me several
weeks cross-compiling to windows on a big endian, char is unsigned by default machine works strangely well. Thank you for your work, without it a Windows port of MAGuS [http://midgard.berlios.de/] would never exist.

Attached is a patch which fixes this bug for me. I also tested for regression on an i686 host (not affected).

    Christof
--- build_dir/src/binutils-2.15.90-20040222-1/ld/emultempl/pe.em~       
2004-07-05 15:18:30.000000000 +0200
+++ build_dir/src/binutils-2.15.90-20040222-1/ld/emultempl/pe.em        
2004-07-05 15:18:30.000000000 +0200
@@ -828,17 +828,17 @@
 make_import_fixup (arelent *rel, asection *s)
 {
   struct bfd_symbol *sym = *rel->sym_ptr_ptr;
-  int addend = 0;
+  char addend[4];
 
   if (pe_dll_extra_pe_debug)
     printf ("arelent: address@hidden: add=%li\n", sym->name,
            (long) rel->address, (long) rel->addend);
 
-  if (! bfd_get_section_contents (s->owner, s, &addend, rel->address, sizeof 
(addend)))
+  if (! bfd_get_section_contents (s->owner, s, addend, rel->address, sizeof 
(addend)))
     einfo (_("%C: Cannot get section contents - auto-import exception\n"),
           s->owner, s, rel->address);
 
-  pe_create_import_fixup (rel, s, addend);
+  pe_create_import_fixup (rel, s, bfd_get_32(s->owner, addend));
 
   return 1;
 }

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]