This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING][PATCH,DWARF,gfortran] Change DWARF-2 output for Fortran COMMON symbols
- From: George Helffrich <george at geology dot bristol dot ac dot uk>
- To: geoffk at geoffk dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Nov 2007 04:50:47 +0000
- Subject: Re: [PING][PATCH,DWARF,gfortran] Change DWARF-2 output for Fortran COMMON symbols
A similar problem arises with .stabs debug information -- for the long
answer, please see the discussion linked from
http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02475.html
Briefly, it not possible to fix this in GDB. The problem lies in
Darwin loader, which refuses to relocate references like SYM+offset in
non .text sections -- a design decision unlikely to be changed by
Apple. To relocate symbols in .comm, Apple's GDB for Darwin gets
around this restriction by assuming that every DWARF symbol reference
is either 1) a symbol whose name is the name of the .comm section;
otherwise 2) an offset into the .text section. Assumption (1) is valid
for C, but not for Fortran -- the program symbol is not the .comm
section name in Fortran (not even a mangled form). By explicitly
declaring the symbol's membership in .comm through DW_TAG_common, it
averts the problem in a compatible way by naming the .comm section
involved independently from the program's symbol. This is the same
spirit as the workaround proposed, in another patch, for .stabs
behavior.
This only affects Fortran, and this patch only changes the behavior for
gfortran-compiled code. It also uses a DWARF feature designed for
Fortran in a way that (non-Apple) GDB already handles properly, so it
seems clear and straightforward to use it, even if the motivation is a
Darwin loader workaround.
George Helffrich