public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: Not linking 32-bit and 64-bit objects
@ 2002-03-12  6:50 Martin Schwidefsky
  2002-03-12  6:55 ` Jakub Jelinek
  0 siblings, 1 reply; 27+ messages in thread
From: Martin Schwidefsky @ 2002-03-12  6:50 UTC (permalink / raw)
  To: Andreas Jaeger; +Cc: Peter Bergner, Alan Modra, binutils


>> On Tue, Mar 12, 2002 at 11:40:18PM +1030, Alan Modra wrote:
>> : On Tue, Mar 12, 2002 at 01:20:38PM +0100, Andreas Jaeger wrote:
>> : >      * cpu-i386.c (i386_compatible): New.  Use it instead of
>> : >      bfd_default_compatible.
>> :
>> : OK.
>>
>> Alan, this seems to be a problem with ppc32 and ppc64 as well.
>> Do we need the same fix???
>
>Other 64-bit platforms might want this also.  Martin, what about S390?

Yes we want that for s390/s390x as well.

blue skies,
   Martin

Linux/390 Design & Development, IBM Deutschland Entwicklung GmbH
Schönaicherstr. 220, D-71032 Böblingen, Telefon: 49 - (0)7031 - 16-2247
E-Mail: schwidefsky@de.ibm.com


^ permalink raw reply	[flat|nested] 27+ messages in thread
* Not linking 32-bit and 64-bit objects
@ 2002-03-12  3:05 Andreas Jaeger
  2002-03-12  3:46 ` Alan Modra
  0 siblings, 1 reply; 27+ messages in thread
From: Andreas Jaeger @ 2002-03-12  3:05 UTC (permalink / raw)
  To: binutils


If I try to link a 32-bit i386 object as 64-bit x86-64 object, it
should fail but I'd like to see a better error message.

Currently I get:
gee:~/tmp:[1]$ /opt/x86-64/bin/x86_64-unknown-linux-gcc k.o 
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/../../../../x86_64-unknown-linux/bin/ld: BFD 2.12.90 20020312 assertion fail /cvs/binutils-ln/bfd/elflink.h:2649

I made the appended (not cleaned up) change and now I get:

gee:~/tmp:[1]$ /opt/x86-64/bin/x86_64-unknown-linux-gcc k.o 
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/../../../../x86_64-unknown-linux/bin/ld: k.o: compiled for a 32 bit system and target is 64 bit
Bad value: failed to merge target specific data of file k.o
/opt/x86-64/lib/gcc-lib/x86_64-unknown-linux/3.1/../../../../x86_64-unknown-linux/bin/ld: BFD 2.12.90 20020312 assertion fail /cvs/binutils-ln/bfd/elflink.h:2649

This is better but I'm not happy, the linker should not abort but exit
cleanly.

So, my questions are:
- is this the right way to go (using merge_private_bfd_data)?
- how can I exit cleanly in this case?

Andreas

2002-03-12  Andreas Jaeger  <aj@suse.de>

	* elf64-x86-64.c (elf64_x86_64_merge_private_bfd_data): New.
	(bfd_elf64_bfd_merge_private_bfd_data): New.


============================================================
Index: bfd/elf64-x86-64.c
--- bfd/elf64-x86-64.c	2002/02/22 10:03:03	1.37
+++ bfd/elf64-x86-64.c	2002/03/12 10:59:09
@@ -2060,6 +2060,37 @@ elf64_x86_64_finish_dynamic_symbol (outp
   return true;
 }
 
+static boolean
+elf64_x86_64_merge_private_bfd_data (ibfd, obfd)
+     bfd *ibfd;
+     bfd *obfd;
+{
+  boolean error = false;
+
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+    return true;
+
+  if (bfd_get_mach (ibfd) != bfd_mach_x86_64
+      && bfd_get_mach (ibfd) != bfd_mach_x86_64_intel_syntax)
+    {
+      error = true;
+      (*_bfd_error_handler)
+	(_("%s: compiled for a 32 bit system and target is 64 bit"),
+	 bfd_archive_filename (ibfd));
+    }
+
+  if (error)
+    {
+      bfd_set_error (bfd_error_bad_value);
+      return false;
+    }
+
+  return true;
+}
+\f
+
+  
 /* Used to decide how to sort relocs in an optimal manner for the
    dynamic linker, before writing them out.  */
 
@@ -2231,6 +2262,7 @@ elf64_x86_64_finish_dynamic_sections (ou
 #define bfd_elf64_bfd_link_hash_table_create \
   elf64_x86_64_link_hash_table_create
 #define bfd_elf64_bfd_reloc_type_lookup	    elf64_x86_64_reloc_type_lookup
+#define bfd_elf64_bfd_merge_private_bfd_data elf64_x86_64_merge_private_bfd_data
 
 #define elf_backend_adjust_dynamic_symbol   elf64_x86_64_adjust_dynamic_symbol
 #define elf_backend_check_relocs	    elf64_x86_64_check_relocs

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de
    http://www.suse.de/~aj

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

end of thread, other threads:[~2002-03-21  7:07 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-12  6:50 Not linking 32-bit and 64-bit objects Martin Schwidefsky
2002-03-12  6:55 ` Jakub Jelinek
2002-03-12  6:58   ` Andreas Jaeger
2002-03-12  7:03     ` Jakub Jelinek
2002-03-12  7:07       ` Andreas Jaeger
2002-03-12 17:54       ` Hans-Peter Nilsson
2002-03-12 18:05         ` Hans-Peter Nilsson
2002-03-12 18:13           ` Hans-Peter Nilsson
2002-03-12 23:48       ` Alan Modra
2002-03-20 23:07       ` matthew green
  -- strict thread matches above, loose matches on Subject: below --
2002-03-12  3:05 Andreas Jaeger
2002-03-12  3:46 ` Alan Modra
2002-03-12  4:20   ` Andreas Jaeger
2002-03-12  5:10     ` Alan Modra
2002-03-12  6:00       ` Peter Bergner
2002-03-12  6:31         ` Andreas Jaeger
2002-03-16 10:21         ` David O'Brien
2002-03-12  8:32   ` Daniel Jacobowitz
2002-03-12 10:22     ` Thiemo Seufer
2002-03-12 16:06     ` Alan Modra
2002-03-12 16:18       ` Ian Lance Taylor
2002-03-12 18:55         ` Alan Modra
2002-03-12 23:30           ` Alan Modra
2002-03-16 10:26           ` David O'Brien
     [not found]             ` <mailpost.1016303179.1035@news-sj1-1>
2002-03-16 12:10               ` cgd
2002-03-16 12:22                 ` David O'Brien
2002-03-16 17:32                   ` Daniel Jacobowitz

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).