This is the mail archive of the binutils@sources.redhat.com 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: Trying to compile binutils 2.15 for BSD/OS 4.3.1


Hi,

Now that that is settled,  I was wondering what would it take
to 'correct' BSD/OS 4.X + from being a.out and shift it to elf?

It appears that the patch to gas/configure was the problem. Using the attached patch I was able to build a toolchain configured as --target=i386-unknown-bsdi which produces ELF format binaries.


Cheers
  Nick


Index: gas/configure.tgt
===================================================================
RCS file: /cvs/src/src/gas/configure.tgt,v
retrieving revision 1.2
diff -c -3 -p -r1.2 configure.tgt
*** gas/configure.tgt	6 Jan 2005 16:13:48 -0000	1.2
--- gas/configure.tgt	17 Jan 2005 15:51:02 -0000
*************** case ${generic_target} in
*** 178,183 ****
--- 178,184 ----
    i386-*-coff)				fmt=coff ;;
    i386-*-elf)				fmt=elf ;;
    i386-*-kaos*)				fmt=elf ;;
+   i386-*-bsdi*)                         fmt=elf ;;
    i386-*-bsd*)				fmt=aout em=386bsd ;;
    i386-*-netbsd0.8)			fmt=aout em=386bsd ;;
    i386-*-netbsdpe*)			fmt=coff em=pe ;;
Index: ld/Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.168
diff -c -3 -p -r1.168 Makefile.am
*** ld/Makefile.am	6 Jan 2005 16:18:24 -0000	1.168
--- ld/Makefile.am	17 Jan 2005 15:51:07 -0000
*************** ALL_EMULATIONS = \
*** 220,225 ****
--- 220,226 ----
  	ei386aout.o \
  	ei386beos.o \
  	ei386bsd.o \
+ 	ei386bsdi.o \
  	ei386coff.o \
  	ei386go32.o \
  	ei386linux.o \
*************** ei386beos.c: $(srcdir)/emulparams/i386be
*** 964,969 ****
--- 965,973 ----
  ei386bsd.c: $(srcdir)/emulparams/i386bsd.sh \
    $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
  	${GENSCRIPTS} i386bsd "$(tdir_i386bsd)"
+ ei386bsdi.c: $(srcdir)/emulparams/i386bsdi.sh \
+   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
+ 	${GENSCRIPTS} i386bsdi.c "$(tdir_i386bsdi)"
  ei386coff.c: $(srcdir)/emulparams/i386coff.sh \
    $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386coff.sc ${GEN_DEPENDS}
  	${GENSCRIPTS} i386coff "$(tdir_i386coff)"
Index: ld/configure.tgt
===================================================================
RCS file: /cvs/src/src/ld/configure.tgt,v
retrieving revision 1.162
diff -c -3 -p -r1.162 configure.tgt
*** ld/configure.tgt	6 Jan 2005 16:18:24 -0000	1.162
--- ld/configure.tgt	17 Jan 2005 15:51:07 -0000
*************** i[3-7]86-*-rtems*)	targ_emul=elf_i386 ;;
*** 149,155 ****
  i[3-7]86-*-aros*)	targ_emul=elf_i386 ;;
  i[3-7]86-*-bsd)		targ_emul=i386bsd ;;
  i[3-7]86-*-bsd386)	targ_emul=i386bsd ;;
! i[3-7]86-*-bsdi*)	targ_emul=i386bsd ;;
  i[3-7]86-*-aout)	targ_emul=i386aout ;;
  i[3-7]86-*-linux*aout*)	targ_emul=i386linux
  			targ_extra_emuls=elf_i386
--- 149,155 ----
  i[3-7]86-*-aros*)	targ_emul=elf_i386 ;;
  i[3-7]86-*-bsd)		targ_emul=i386bsd ;;
  i[3-7]86-*-bsd386)	targ_emul=i386bsd ;;
! i[3-7]86-*-bsdi*)	targ_emul=elf_i386;;
  i[3-7]86-*-aout)	targ_emul=i386aout ;;
  i[3-7]86-*-linux*aout*)	targ_emul=i386linux
  			targ_extra_emuls=elf_i386
Index: bfd/config.bfd
===================================================================
RCS file: /cvs/src/src/bfd/config.bfd,v
retrieving revision 1.180
diff -c -3 -p -r1.180 config.bfd
*** bfd/config.bfd	6 Jan 2005 16:18:18 -0000	1.180
--- bfd/config.bfd	17 Jan 2005 15:51:07 -0000
*************** case "${targ}" in
*** 482,487 ****
--- 482,491 ----
      targ_defvec=i386dynix_vec
      targ_underscore=yes
      ;;
+   i[3456]86-*-bsdi*)
+     targ_defvec=bfd_elf32_i386_vec
+     targ_selvecs=i386bsd_vec
+     ;;
    i[3-7]86-*-bsd*)
      targ_defvec=i386bsd_vec
      targ_underscore=yes
Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.166
diff -c -3 -p -r1.166 configure.in
*** bfd/configure.in	6 Jan 2005 16:18:20 -0000	1.166
--- bfd/configure.in	17 Jan 2005 15:51:08 -0000
*************** changequote([,])dnl
*** 205,211 ****
  changequote(,)dnl
    i[3-7]86-*-bsdi)
  changequote([,])dnl
! 	COREFILE=
  	;;
  changequote(,)dnl
    i[3-7]86-*-bsd* | i[3-7]86-*-freebsd[123] | i[3-7]86-*-freebsd[123]\.* | i[3-7]86-*-freebsd4\.[01234] | i[3-7]86-*-freebsd4\.[01234]\.* | i[3-7]86-*-freebsd*aout*)
--- 205,214 ----
  changequote(,)dnl
    i[3-7]86-*-bsdi)
  changequote([,])dnl
! 	# XXX - we MUST supply a core-dump file reader even
! 	# though this version of libbfd is not used by gdb.
! 	COREFILE=bsdi-core.lo
! 	TRAD_HEADER='"hosts/i386bsdi.h"'
  	;;
  changequote(,)dnl
    i[3-7]86-*-bsd* | i[3-7]86-*-freebsd[123] | i[3-7]86-*-freebsd[123]\.* | i[3-7]86-*-freebsd4\.[01234] | i[3-7]86-*-freebsd4\.[01234]\.* | i[3-7]86-*-freebsd*aout*)
Index: bfd/i386bsd.c
===================================================================
RCS file: /cvs/src/src/bfd/i386bsd.c,v
retrieving revision 1.3
diff -c -3 -p -r1.3 i386bsd.c
*** bfd/i386bsd.c	2 Oct 2001 05:58:41 -0000	1.3
--- bfd/i386bsd.c	17 Jan 2005 15:51:09 -0000
*************** Foundation, Inc., 59 Temple Place - Suit
*** 47,50 ****
--- 47,153 ----
  #include "libbfd.h"
  #include "libaout.h"
  
+ #ifdef __bsdi__
+ 
+ #include "aout/aout64.h"
+ 
+ #define	MY_callback	MY(callback)
+ 
+ static const bfd_target *
+ MY(callback) (bfd *abfd)
+ {
+   struct internal_exec *execp = exec_hdr (abfd);
+   unsigned int arch_align_power;
+   unsigned long arch_align;
+ 
+   /* Calculate the file positions of the parts of a newly read aout header.  */
+   obj_textsec (abfd)->_raw_size = N_TXTSIZE (*execp);
+ 
+   /* The virtual memory addresses of the sections.  */
+   obj_textsec (abfd)->vma = N_TXTADDR (*execp);
+   obj_datasec (abfd)->vma = N_DATADDR (*execp);
+   obj_bsssec  (abfd)->vma = N_BSSADDR (*execp);
+ 
+   /* Check for kernel binaries.  */
+   if ((execp->a_entry & 0xff000000) != 0)
+     {
+       bfd_vma adjust;
+ 
+       adjust = execp->a_entry - obj_textsec (abfd)->vma;
+       /* Adjust only by whole pages.  */
+       adjust &= ~(TARGET_PAGE_SIZE - 1);
+       obj_textsec (abfd)->vma += adjust;
+       obj_datasec (abfd)->vma += adjust;
+       obj_bsssec (abfd)->vma += adjust;
+     }
+ 
+   /* Set the load addresses to be the same as the virtual addresses.  */
+   obj_textsec (abfd)->lma = obj_textsec (abfd)->vma;
+   obj_datasec (abfd)->lma = obj_datasec (abfd)->vma;
+   obj_bsssec (abfd)->lma = obj_bsssec (abfd)->vma;
+ 
+   /* The file offsets of the sections.  */
+   obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
+   obj_datasec (abfd)->filepos = N_DATOFF (*execp);
+ 
+   /* The file offsets of the relocation info.  */
+   obj_textsec (abfd)->rel_filepos = N_TRELOFF (*execp);
+   obj_datasec (abfd)->rel_filepos = N_DRELOFF (*execp);
+ 
+   /* The file offsets of the string table and symbol table.  */
+   obj_sym_filepos (abfd) = N_SYMOFF (*execp);
+   obj_str_filepos (abfd) = N_STROFF (*execp);
+ 
+   /* Determine the architecture and machine type of the object file.  */
+ #ifdef SET_ARCH_MACH
+   SET_ARCH_MACH (abfd, *execp);
+ #else
+   bfd_default_set_arch_mach (abfd, DEFAULT_ARCH, 0);
+ #endif
+ 
+   /* The number of relocation records.  This must be called after
+      SET_ARCH_MACH.  It assumes that SET_ARCH_MACH will set
+      obj_reloc_entry_size correctly, if the reloc size is not
+      RELOC_STD_SIZE.  */
+   obj_textsec (abfd)->reloc_count =
+     execp->a_trsize / obj_reloc_entry_size (abfd);
+   obj_datasec (abfd)->reloc_count =
+     execp->a_drsize / obj_reloc_entry_size (abfd);
+ 
+   /* Now that we know the architecture, set the alignments of the
+      sections.  This is normally done by NAME(aout,new_section_hook),
+      but when the initial sections were created the architecture had
+      not yet been set.  However, for backward compatibility, we don't
+      set the alignment power any higher than as required by the size
+      of the section.  */
+   arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
+   arch_align = 1 << arch_align_power;
+ 
+   if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
+        == obj_textsec (abfd)->_raw_size)
+       && (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
+         == obj_datasec (abfd)->_raw_size)
+       && (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
+         == obj_bsssec (abfd)->_raw_size))
+     {
+       obj_textsec (abfd)->alignment_power = arch_align_power;
+       obj_datasec (abfd)->alignment_power = arch_align_power;
+       obj_bsssec (abfd)->alignment_power = arch_align_power;
+     }
+ 
+   return abfd->xvec;
+ }
+ 
+ /* Make QMAGIC be the default output format.  */
+ 
+ static boolean
+ i386bsd_bfd_final_link (bfd *abfd, struct bfd_link_info *info)
+ {
+   obj_aout_subformat (abfd) = q_magic_format;
+   return NAME(aout,final_link) (abfd, info, MY_final_link_callback);
+ }
+ 
+ #define	MY_bfd_final_link	i386bsd_bfd_final_link
+ #endif
+   
  #include "aout-target.h"

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