public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Patch: Switch Linux/mips to stabs
@ 2001-06-07 10:35 H . J . Lu
  2001-06-07 22:12 ` Maciej W. Rozycki
  0 siblings, 1 reply; 9+ messages in thread
From: H . J . Lu @ 2001-06-07 10:35 UTC (permalink / raw)
  To: binutils; +Cc: GDB, linux-mips

Based on the recommendations from Ian and Daniel, I checked in the
following patches to switch Linux/mips to stabs.

Thanks.

---
2001-06-07  H.J. Lu  <hjl@gnu.org>

	* elf32-mips.c (_bfd_mips_elf_object_p): Set the bad symtab
	for SGI only.

	* config.bfd: Remove ecoff from Linux/mips.

Index: config.bfd
===================================================================
RCS file: /cvs/src/src/bfd/config.bfd,v
retrieving revision 1.58
diff -u -p -r1.58 config.bfd
--- config.bfd	2001/06/02 17:32:09	1.58
+++ config.bfd	2001/06/07 17:28:52
@@ -675,7 +675,7 @@ case "${targ}" in
     ;;
   mips*el*-*-linux-gnu*)
     targ_defvec=bfd_elf32_tradlittlemips_vec
-    targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf64_tradbigmips_vec ecoff_little_vec ecoff_big_vec"
+    targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf64_tradbigmips_vec"
     ;;
   mips*-*-openbsd*)
     targ_defvec=bfd_elf32_bigmips_vec
@@ -683,7 +683,7 @@ case "${targ}" in
     ;;
   mips*-*-linux-gnu*)
     targ_defvec=bfd_elf32_tradbigmips_vec
-    targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
+    targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec"
     ;;
   mn10200-*-*)
     targ_defvec=bfd_elf32_mn10200_vec
Index: elf32-mips.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-mips.c,v
retrieving revision 1.97
diff -u -p -r1.97 elf32-mips.c
--- elf32-mips.c	2001/05/23 17:26:35	1.97
+++ elf32-mips.c	2001/06/07 17:29:12
@@ -2331,7 +2331,8 @@ _bfd_mips_elf_object_p (abfd)
   /* Irix 5 and 6 is broken.  Object file symbol tables are not always
      sorted correctly such that local symbols precede global symbols,
      and the sh_info field in the symbol table is not always right.  */
-  elf_bad_symtab (abfd) = true;
+  if (SGI_COMPAT(abfd))
+    elf_bad_symtab (abfd) = true;
 
   bfd_default_set_arch_mach (abfd, bfd_arch_mips,
 			     elf_mips_mach (elf_elfheader (abfd)->e_flags));

2001-06-07  H.J. Lu  <hjl@gnu.org>

	* configure.in: Use MIPS_STABS_ELF for Linux/mips and remove
	ecoff emulation.
	* configure: Regenerate.

Index: configure.in
===================================================================
RCS file: /cvs/src/src/gas/configure.in,v
retrieving revision 1.69
diff -u -p -r1.69 configure.in
--- configure.in	2001/05/25 07:21:00	1.69
+++ configure.in	2001/06/07 17:20:54
@@ -346,8 +346,13 @@ changequote([,])dnl
       mips-*-irix*)         fmt=ecoff ;;
       mips-*-lnews*)        fmt=ecoff em=lnews ;;
       mips-*-riscos*)       fmt=ecoff ;;
-      mips-*-sysv4*MP* | mips-*-linux-gnu* | mips-*-gnu*)
+      mips-*-sysv4*MP* | mips-*-gnu*)
 			    fmt=elf em=tmips ;;
+      mips-*-linux-gnu*)
+			    fmt=elf em=tmips
+			    AC_DEFINE(MIPS_STABS_ELF, 1,
+				[Use ELF stabs for MIPS, not ECOFF stabs])
+			    ;;
       mips-*-sysv*)         fmt=ecoff ;;
       mips-*-elf* | mips-*-rtems* | mips-*-openbsd*)
 			    fmt=elf ;;
@@ -602,8 +607,8 @@ changequote([,])dnl
     case ${generic_target}-${fmt} in
       mips-*-irix5*-*)	emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
       mips-*-linux-gnu*-*) case "$endian" in
-			big)	emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
-			*)	emulation="mipslelf mipsbelf mipself mipslecoff mipsbecoff mipsecoff" ;;
+			big)	emulation="mipsbelf mipslelf mipself" ;;
+			*)	emulation="mipslelf mipsbelf mipself" ;;
 			esac ;;
       mips-*-lnews*-ecoff) ;;
       mips-*-*-ecoff)	case "$endian" in

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-07 10:35 Patch: Switch Linux/mips to stabs H . J . Lu
@ 2001-06-07 22:12 ` Maciej W. Rozycki
  2001-06-07 23:23   ` H . J . Lu
  2001-06-11 14:40   ` Aaron J. Grier
  0 siblings, 2 replies; 9+ messages in thread
From: Maciej W. Rozycki @ 2001-06-07 22:12 UTC (permalink / raw)
  To: H . J . Lu; +Cc: binutils, GDB, linux-mips

On Thu, 7 Jun 2001, H . J . Lu wrote:

> 	* config.bfd: Remove ecoff from Linux/mips.

 Is it really needed to remove ecoff-littlemips and ecoff-bigmips targets
from the list of default ones for MIPS/Linux?  COFF is the format used by
the firmware of certain MIPS-based machines for network-booting, certainly
by DECstations and I'm told that older SGI workstations use this format,
too.  While the elf2ecoff tool as bundled with the kernel seem to be
sufficient to prepare a suitable COFF image, it's grossly limited in
functionality and was added only as a workaround to bugs in binutils.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-07 22:12 ` Maciej W. Rozycki
@ 2001-06-07 23:23   ` H . J . Lu
  2001-06-11 14:40   ` Aaron J. Grier
  1 sibling, 0 replies; 9+ messages in thread
From: H . J . Lu @ 2001-06-07 23:23 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: binutils, GDB, linux-mips

On Fri, Jun 08, 2001 at 07:12:39AM +0200, Maciej W. Rozycki wrote:
> On Thu, 7 Jun 2001, H . J . Lu wrote:
> 
> > 	* config.bfd: Remove ecoff from Linux/mips.
> 
>  Is it really needed to remove ecoff-littlemips and ecoff-bigmips targets
> from the list of default ones for MIPS/Linux?  COFF is the format used by
> the firmware of certain MIPS-based machines for network-booting, certainly
> by DECstations and I'm told that older SGI workstations use this format,
> too.  While the elf2ecoff tool as bundled with the kernel seem to be
> sufficient to prepare a suitable COFF image, it's grossly limited in
> functionality and was added only as a workaround to bugs in binutils.
> 

Sorry. I put it back.


H.J.
----
2001-06-07  H.J. Lu  <hjl@gnu.org>

	* config.bfd: Put back ecoff for Linux/mips. Firmwares on some
	MIPS-based machines need it.

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-07 22:12 ` Maciej W. Rozycki
  2001-06-07 23:23   ` H . J . Lu
@ 2001-06-11 14:40   ` Aaron J. Grier
  2001-06-11 16:22     ` Ian Lance Taylor
  1 sibling, 1 reply; 9+ messages in thread
From: Aaron J. Grier @ 2001-06-11 14:40 UTC (permalink / raw)
  To: binutils

On Fri, Jun 08, 2001 at 07:12:39AM +0200, Maciej W. Rozycki wrote:

>  Is it really needed to remove ecoff-littlemips and ecoff-bigmips
> targets from the list of default ones for MIPS/Linux?  COFF is the
> format used by the firmware of certain MIPS-based machines for
> network-booting, certainly by DECstations and I'm told that older SGI
> workstations use this format, too.  While the elf2ecoff tool as
> bundled with the kernel seem to be sufficient to prepare a suitable
> COFF image, it's grossly limited in functionality and was added only
> as a workaround to bugs in binutils.

Jason Thorpe in the NetBSD camp was able to persuade binutils to
generate bootable MIPS ECOFF kernels via objcopy.  If objcopy indeed
works, it would be nice to see elf2ecoff go away.  :)

The patch to BFD is here:

http://mail-index.netbsd.org/port-mips/2001/06/07/0001.html

-- 
  Aaron J. Grier   |    Frye Electronics, Tigard, OR   |   aaron@frye.com
    "The only thing we have a problem with is when the government funds
     open-source work. Government funding should be for work that is
     available to everybody."  --  Microsoft President, Steve Ballmer

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-11 14:40   ` Aaron J. Grier
@ 2001-06-11 16:22     ` Ian Lance Taylor
  2001-06-11 19:13       ` Maciej W. Rozycki
  0 siblings, 1 reply; 9+ messages in thread
From: Ian Lance Taylor @ 2001-06-11 16:22 UTC (permalink / raw)
  To: Aaron J. Grier; +Cc: binutils

"Aaron J. Grier" <aaron@frye.com> writes:

> On Fri, Jun 08, 2001 at 07:12:39AM +0200, Maciej W. Rozycki wrote:
> 
> >  Is it really needed to remove ecoff-littlemips and ecoff-bigmips
> > targets from the list of default ones for MIPS/Linux?  COFF is the
> > format used by the firmware of certain MIPS-based machines for
> > network-booting, certainly by DECstations and I'm told that older SGI
> > workstations use this format, too.  While the elf2ecoff tool as
> > bundled with the kernel seem to be sufficient to prepare a suitable
> > COFF image, it's grossly limited in functionality and was added only
> > as a workaround to bugs in binutils.
> 
> Jason Thorpe in the NetBSD camp was able to persuade binutils to
> generate bootable MIPS ECOFF kernels via objcopy.  If objcopy indeed
> works, it would be nice to see elf2ecoff go away.  :)
> 
> The patch to BFD is here:
> 
> http://mail-index.netbsd.org/port-mips/2001/06/07/0001.html

Yes, I spoke with Jason about this.  The basic problem is that the
ECOFF writer does the wrong thing for Jason's purposes if D_PAGED is
set, and there is no way to directly control whether the ELF backend
sets D_PAGED or not.  Jason's patch arranges for the ELF backend to
not set D_PAGED in the particular case that he needs, but that is a
trifle odd.  I don't have time to look into this, but it seems to me
that there must be some clean way to get the ELF backend to not set
D_PAGED.  Anybody want to look into it?

Ian

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-11 16:22     ` Ian Lance Taylor
@ 2001-06-11 19:13       ` Maciej W. Rozycki
  2001-06-11 21:04         ` Jason R Thorpe
  0 siblings, 1 reply; 9+ messages in thread
From: Maciej W. Rozycki @ 2001-06-11 19:13 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Aaron J. Grier, binutils

On 11 Jun 2001, Ian Lance Taylor wrote:

> > Jason Thorpe in the NetBSD camp was able to persuade binutils to
> > generate bootable MIPS ECOFF kernels via objcopy.  If objcopy indeed
> > works, it would be nice to see elf2ecoff go away.  :)
> > 
> > The patch to BFD is here:
> > 
> > http://mail-index.netbsd.org/port-mips/2001/06/07/0001.html
> 
> Yes, I spoke with Jason about this.  The basic problem is that the
> ECOFF writer does the wrong thing for Jason's purposes if D_PAGED is
> set, and there is no way to directly control whether the ELF backend
> sets D_PAGED or not.  Jason's patch arranges for the ELF backend to
> not set D_PAGED in the particular case that he needs, but that is a
> trifle odd.  I don't have time to look into this, but it seems to me
> that there must be some clean way to get the ELF backend to not set
> D_PAGED.  Anybody want to look into it?

 I'm not sure objcopy is the right tool here -- while the tool is right
for converting between binary formats, it's not the one to modify
binaries' internals.  The desired effect can be achieved with ld, which
indeed is the right tool here:

$ cat test.s
        .globl  __start
__start:

$ mipsel-linux-as -o test.o test.s

$ file test.o
test.o: ELF 32-bit LSB relocatable, MIPS R3000_BE - invalid byte order,
version 1, not stripped

$ mipsel-linux-objdump -f test.o
test.o:     file format elf32-littlemips
architecture: mips:3000, flags 0x00000010:
HAS_SYMS
start address 0x0000000000000000

$ mipsel-linux-ld -m mipslit -o test test.o

$ file test
test: MIPSEL-LE COFF executable (paged) not stripped - version 0.0

$ mipsel-linux-objdump -f test
test:     file format ecoff-littlemips
architecture: mips:3000, flags 0x00000132:
EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
start address 0x0000000000400120

$ mipsel-linux-ld -N -m mipslit -o test test.o

$ file test
test: MIPSEL-LE COFF executable (impure) not stripped - version 0.0

$ mipsel-linux-objdump -f test
test:     file format ecoff-littlemips
architecture: mips:3000, flags 0x00000032:
EXEC_P, HAS_SYMS, HAS_LOCALS
start address 0x0000000000400120

It seems to work as it should.  And that's with default ld scripts.  I
can't run-time test it, unfortunately, as my DECstation's firmware doesn't
grok TFTP for any of my network devices and MOP uses raw binary format
instead of COFF for booting.

 That said we could certainly support -[Nn] for ELF as well. 

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-11 19:13       ` Maciej W. Rozycki
@ 2001-06-11 21:04         ` Jason R Thorpe
  2001-06-13  6:34           ` Maciej W. Rozycki
  0 siblings, 1 reply; 9+ messages in thread
From: Jason R Thorpe @ 2001-06-11 21:04 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Ian Lance Taylor, Aaron J. Grier, binutils

On Tue, Jun 12, 2001 at 04:15:13AM +0200, Maciej W. Rozycki wrote:

 >  I'm not sure objcopy is the right tool here -- while the tool is right
 > for converting between binary formats, it's not the one to modify
 > binaries' internals.  The desired effect can be achieved with ld, which
 > indeed is the right tool here:

I don't want to modify the binary's internals.  The executable, a
kernel, is comprised of a single loadable section, a'la OMAGIC, and
-N is provided to the linker along with a linker script that arranges
the ELF image the right way.  It is not intended to be paged.

I simply want objcopy to copy the ELF image to an ECOFF image, and
stamp the ECOFF image with the appropriate magic number.  But because
the ELF backend pretty much always sets D_PAGED, the ECOFF backend
! OMAGIC into the magic number.

Now, if the linker were to not align the loadable part of the ELF
image at 0x1000 offset into the file, then D_PAGED would not be set
by the ELF backend, but I haven't been able to figure out why it's
even doing so, considering I'm using ld -N.

 >  That said we could certainly support -[Nn] for ELF as well. 

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-11 21:04         ` Jason R Thorpe
@ 2001-06-13  6:34           ` Maciej W. Rozycki
  2001-06-13 10:40             ` Ian Lance Taylor
  0 siblings, 1 reply; 9+ messages in thread
From: Maciej W. Rozycki @ 2001-06-13  6:34 UTC (permalink / raw)
  To: Jason R Thorpe; +Cc: Ian Lance Taylor, Aaron J. Grier, binutils

On Mon, 11 Jun 2001, Jason R Thorpe wrote:

> I don't want to modify the binary's internals.  The executable, a
> kernel, is comprised of a single loadable section, a'la OMAGIC, and
> -N is provided to the linker along with a linker script that arranges
> the ELF image the right way.  It is not intended to be paged.

 OK -- I thought you want to reset D_PAGED upon objcopy.

> I simply want objcopy to copy the ELF image to an ECOFF image, and
> stamp the ECOFF image with the appropriate magic number.  But because
> the ELF backend pretty much always sets D_PAGED, the ECOFF backend
> ! OMAGIC into the magic number.

 Indeed.

> Now, if the linker were to not align the loadable part of the ELF
> image at 0x1000 offset into the file, then D_PAGED would not be set
> by the ELF backend, but I haven't been able to figure out why it's
> even doing so, considering I'm using ld -N.

 I consider it a bug in the ELF backend.  I'll look into it when my time
permits.  Don't hold your breath, though.

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +

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

* Re: Patch: Switch Linux/mips to stabs
  2001-06-13  6:34           ` Maciej W. Rozycki
@ 2001-06-13 10:40             ` Ian Lance Taylor
  0 siblings, 0 replies; 9+ messages in thread
From: Ian Lance Taylor @ 2001-06-13 10:40 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: Jason R Thorpe, Aaron J. Grier, binutils

"Maciej W. Rozycki" <macro@ds2.pg.gda.pl> writes:

> > Now, if the linker were to not align the loadable part of the ELF
> > image at 0x1000 offset into the file, then D_PAGED would not be set
> > by the ELF backend, but I haven't been able to figure out why it's
> > even doing so, considering I'm using ld -N.
> 
>  I consider it a bug in the ELF backend.  I'll look into it when my time
> permits.  Don't hold your breath, though.

In these lines in assign_file_positions_except_relocs in bfd/elf.c:

	      if ((abfd->flags & D_PAGED) != 0)
		off += (hdr->sh_addr - off) % bed->maxpagesize;
	      else
		off += (hdr->sh_addr - off) % hdr->sh_addralign;

it's not clear to me why we use hdr->sh_addralign when figuring out
the file offset.  I think I wrote that, but I don't remember why.  If
we didn't do that, I expect that Jason's case would work.

Another approach would be to add an option to objcopy to control the
file level flags.

Ian

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

end of thread, other threads:[~2001-06-13 10:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-07 10:35 Patch: Switch Linux/mips to stabs H . J . Lu
2001-06-07 22:12 ` Maciej W. Rozycki
2001-06-07 23:23   ` H . J . Lu
2001-06-11 14:40   ` Aaron J. Grier
2001-06-11 16:22     ` Ian Lance Taylor
2001-06-11 19:13       ` Maciej W. Rozycki
2001-06-11 21:04         ` Jason R Thorpe
2001-06-13  6:34           ` Maciej W. Rozycki
2001-06-13 10:40             ` Ian Lance Taylor

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