From nobody@FreeBSD.ORG  Thu Jun 15 20:32:47 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 31C4A37BA59; Thu, 15 Jun 2000 20:32:47 -0700 (PDT)
Message-Id: <20000616033247.31C4A37BA59@hub.freebsd.org>
Date: Thu, 15 Jun 2000 20:32:47 -0700 (PDT)
From: yakisoba@f2.dion.ne.jp
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: Fix to build 'a.out' binary.
X-Send-Pr-Version: www-1.0

>Number:         19327
>Category:       gnu
>Synopsis:       Fix to build 'a.out' binary.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ceri
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 15 20:40:00 PDT 2000
>Closed-Date:    Sun Jun 08 11:00:57 PDT 2003
>Last-Modified:  Sun Jun 08 11:00:57 PDT 2003
>Originator:     Naohiko Tsuji
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
>Environment:
__FreeBSD_version >= 400012 (GCC 2.95.X and later)


>Description:
  After the base compiler is upgraded to GCC 2.95.2, 'a.out' binary
could not build.
  CURRENT and 4.0-STABLE GCC Target Macro still support both 'ELF'
and 'a.out'. So this problem is bug ? Or switch to 'ELF' only soon ?

If fix now, correct '__main.o' in libgcc.a like below.
     
    a.out __main.o:                     ELF  __main.o:
                   U ___CTOR_LIST__
                   U ___DTOR_LIST__
          00000028 T ___do_global_ctors
          00000000 T ___do_global_dtors
          0000007c T ___main
                   U __exit_dummy_decl
          000000a4 D __exit_dummy_ref
                   U _atexit

P.S. Now 'ELF' has garbege.

    ELF   __main.o:
                   U __do_global_ctors
          00000000 T __main

>How-To-Repeat:

>Fix:
  1. Delete define 'INVOKE__main' in GCC Target Macro 'i386/freebsd.h'.

  2. Add the next line to GCC Target Macro 'i386/freebsd.h'.

     #if defined (IN_LIBGCC2) && !defined (__ELF__)
     #undef OBJECT_FORMAT_ELF
     #undef INIT_SECTION_ASM_OP
     #endif

  3. Add CFLAGS to 'gnu/lib/libgcc/Makefile'.

     CFLAGS+=   -DIN_LIBGCC2

  4. Improve 'function.c' hack.

*** contrib/gcc/function.c.orig Tue Nov  2 03:56:02 1999
--- contrib/gcc/function.c      Mon Jun 12 22:35:02 2000
***************
*** 6040,6059 ****
  #define HAS_INIT_SECTION
  #endif
  
- #ifndef GEN_CALL__MAIN
- #define GEN_CALL__MAIN \
-   do {                                                                        \
-     emit_library_call (gen_rtx (SYMBOL_REF, Pmode, NAME__MAIN), 0,    \
-                      VOIDmode, 0);                                    \
-   } while (0)
- #endif
- 
  void
  expand_main_function ()
  {
! #if defined(INVOKE__main) || !defined (HAS_INIT_SECTION)
    GEN_CALL__MAIN;
  #endif /* not HAS_INIT_SECTION */
  }
  
  extern struct obstack permanent_obstack;
--- 6040,6056 ----
  #define HAS_INIT_SECTION
  #endif
  
  void
  expand_main_function ()
  {
! #ifdef GEN_CALL__MAIN
    GEN_CALL__MAIN;
+ #else
+ #if !defined (HAS_INIT_SECTION)
+   emit_library_call (gen_rtx_SYMBOL_REF (Pmode, NAME__MAIN), 0,
+                    VOIDmode, 0);
  #endif /* not HAS_INIT_SECTION */
+ #endif /* GEN_CALL__MAIN */
  }
  
  extern struct obstack permanent_obstack;

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->obrien 
Responsible-Changed-By: johan 
Responsible-Changed-When: Thu Oct 12 12:48:24 PDT 2000 
Responsible-Changed-Why:  
Over to GCC maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19327 
Responsible-Changed-From-To: obrien->freebsd-bugs 
Responsible-Changed-By: obrien 
Responsible-Changed-When: Mon Sep 10 09:29:48 PDT 2001 
Responsible-Changed-Why:  

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=19327 
State-Changed-From-To: open->feedback 
State-Changed-By: iedowse 
State-Changed-When: Fri Aug 9 16:24:48 PDT 2002 
State-Changed-Why:  

Does this problem still exist? Is it useful to keep this PR open 
now that a significant amount of time has elapsed since FreeBSD 
switched to using ELF? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19327 
State-Changed-From-To: feedback->closed 
State-Changed-By: ceri 
State-Changed-When: Sun Jun 8 11:00:55 PDT 2003 
State-Changed-Why:  
Feedback timeout (6 months or more). 
I will handle any feedback that this closure generates. 


Responsible-Changed-From-To: freebsd-bugs->ceri 
Responsible-Changed-By: ceri 
Responsible-Changed-When: Sun Jun 8 11:00:55 PDT 2003 
Responsible-Changed-Why:  
Feedback timeout (6 months or more). 
I will handle any feedback that this closure generates. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19327 
>Unformatted:
