public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34136]  New: [g77 regression] Add entry point and symbol for linker
@ 2007-11-17 14:38 burnus at gcc dot gnu dot org
  2007-11-17 15:35 ` [Bug fortran/34136] " w6ws at earthlink dot net
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-11-17 14:38 UTC (permalink / raw)
  To: gcc-bugs

As reported by Jack Howarth
http://gcc.gnu.org/ml/fortran/2007-11/msg00122.html

Analysis by Walter Spector:

a) http://gcc.gnu.org/ml/fortran/2007-11/msg00131.html

Ah - the old "put block data in a library, and use EXTERNAL to make sure
it gets linked in" trick.  Many compilers have gotten this wrong over
the years, because it is kinda on the edge of being required by the
Standard (any of them).

On my cygwin system, g77 and g95 get it right and gfortran gets it wrong.
See below.

While F90 modules fixed this problem by obsoleting BLOCK DATA and
COMMON, quite a number of older library packages depend on this working.

Walter


$ cat testsub.f
      SUBROUTINE TESTSUB
      EXTERNAL BDTEST
      COMMON/TEST/WK
      INTEGER WK
      PRINT *,'TESTSUB: WK = ',WK, '...it should be 20'
      RETURN
      END

$ g77 -c testsub.f
$ nm testsub.o
00000000 b .bss
00000000 d .data
00000000 r .rdata
00000000 t .text
00000004 d ___g77_cilist_0.1
00000000 d ___g77_forceload_0.0
         U _bdtest_               <<<< This references the BLOCK DATA
         U _do_lio
         U _e_wsle
         U _s_wsle
00000010 C _test_
00000000 T _testsub_

$ gfortran -c testsub.f
$ nm testsub.o
00000000 b .bss
00000000 d .data
00000000 r .rdata
00000000 t .text                 <<<< Missing a reference to _bdtest_ here
         U __gfortran_st_write
         U __gfortran_st_write_done
         U __gfortran_transfer_character
         U __gfortran_transfer_integer
00000010 C _test_
00000000 T _testsub_

***************************************************************++

b) http://gcc.gnu.org/ml/fortran/2007-11/msg00132.html

The other half of this issue is on the BLOCK DATA side.  There has to be
an entry point that the linker can find:

$ cat testbd.f
      BLOCKDATA BDTEST
      COMMON/TEST/WK
      INTEGER WK
      DATA WK/20/
      END
$ gfortran testbd.f -c
$ nm testbd.o
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 B _bdtest_    <<<< gfortran creates a BSS section
00000000 D _test_
$ g77 -c testbd.f
$ nm testbd.o
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 T _bdtest_    <<<< g77 creates a TEXT entry (even though no code
exists)
00000000 D _test_
$

Again, while there used to be debates about whether the Standard required
this to work, many older packages depend on it.


-- 
           Summary: [g77 regression] Add entry point and symbol for linker
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34136


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

end of thread, other threads:[~2010-01-05 18:27 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-17 14:38 [Bug fortran/34136] New: [g77 regression] Add entry point and symbol for linker burnus at gcc dot gnu dot org
2007-11-17 15:35 ` [Bug fortran/34136] " w6ws at earthlink dot net
2007-11-22 18:42 ` [Bug fortran/34136] [regression against g77] " howarth at nitro dot med dot uc dot edu
2007-11-22 18:45 ` howarth at nitro dot med dot uc dot edu
2007-11-22 18:47 ` howarth at nitro dot med dot uc dot edu
2007-11-22 18:53 ` howarth at nitro dot med dot uc dot edu
2007-11-22 18:54 ` howarth at nitro dot med dot uc dot edu
2007-11-22 18:55 ` howarth at nitro dot med dot uc dot edu
2007-11-26 20:58 ` mrs at apple dot com
2007-11-27  2:18 ` howarth at nitro dot med dot uc dot edu
2007-11-27  2:19 ` howarth at nitro dot med dot uc dot edu
2007-11-27  2:24 ` howarth at nitro dot med dot uc dot edu
2007-11-27  2:42 ` mrs at apple dot com
2007-11-27  9:49 ` burnus at gcc dot gnu dot org
2007-11-27 14:22 ` howarth at nitro dot med dot uc dot edu
2007-11-27 17:36 ` burnus at gcc dot gnu dot org
2007-11-29  4:34 ` howarth at nitro dot med dot uc dot edu
2008-11-01 12:22 ` [Bug fortran/34136] " jvdelisle at gcc dot gnu dot org
2008-11-01 12:34 ` dominiq at lps dot ens dot fr
2010-01-05 18:15 ` dominiq at lps dot ens dot fr
2010-01-05 18:27 ` howarth at nitro dot med dot uc dot edu

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