[RFA] Kill SOFUN_ADDRESS_MAYBE_MISSING (was Re: multi-arch TODO)

David S. Miller
2002-04-23T10:10:10Z

From: Kevin Buettner <kevinb@redhat.com>
Date: Mon, 22 Apr 2002 08:24:49 -0700

On Apr 22, 4:09am, David S. Miller wrote:

> SOFUN_ADDRESS_MAYBE_MISSING - Gross hack time... some compilation
> environments don't fill in N_FUN/N_SO stabs, you have to compute
> them by hand by looking up function names in the symbol table and
> so forth.
>
> Much confusion in this area, some Linux targets define this, some
> not. All Solaris targets define it, but that makes sense based upon
> the commentary around the changes this macro define protects.
>
> Why don't all Linux targets define this? Do some binutils ports
> perform this optimization and others not? Or was there some bug
> in N_FUN/N_SO stabs in binutils and/or gcc that this is papering
> around? kevinb@cyghat.com is the one who added this to powerpc
> and i386 Linux.

I haven't given it a lot of thought recently, but my opinion is that
the SOFUN_ADDRESS_MAYBE_MISSING code ought to be enabled everywhere.
The only downside that I can think of is that we lose the ability
to put a symbol at address 0.

Sounds find to me, how about this patch?

2002-04-23 David S. Miller <davem@redhat.com>

* config/i386/tm-i386sol2.h, config/i386/tm-linux.h,
config/powerpc/tm-linux.h, config/powerpc/tm-ppc-eabi.h,
config/sparc/tm-sun4sol2.h (SOFUN_ADDRESS_MAYBE_MISSING): Kill.
* dbxread.c, elfread.c, minsyms.c, mdebugread.c, symmisc.c,
symtab.h (whole file): Act as if SOFUN_ADDRESS_MAYBE_MISSING was
always defined, kill ifdefs.

--- ./config/i386/tm-i386sol2.h.~1~ Mon Jul 30 14:45:26 2001
+++ ./config/i386/tm-i386sol2.h Mon Apr 22 23:32:49 2002
@@ -46,10 +46,6 @@
#undef IN_SIGTRAMP
#define IN_SIGTRAMP(pc, name) (pc == 0xFFFFFFFF)

-/* The SunPRO compiler puts out 0 instead of the address in N_SO symbols,
- and for SunPRO 3.0, N_FUN symbols too. */
-#define SOFUN_ADDRESS_MAYBE_MISSING
-
extern char *sunpro_static_transform_name (char *);
#define STATIC_TRANSFORM_NAME(x) sunpro_static_transform_name (x)
#define IS_STATIC_TRANSFORM_NAME(name) ((name)[0] == '.')
--- ./config/i386/tm-linux.h.~1~ Sun Feb 24 14:56:05 2002
+++ ./config/i386/tm-linux.h Mon Apr 22 23:32:58 2002
@@ -105,10 +105,6 @@ extern void i386_linux_write_pc (CORE_AD
SKIP_SOLIB_RESOLVER at the top of infrun.c. */
#define SKIP_SOLIB_RESOLVER i386_linux_skip_solib_resolver
extern CORE_ADDR i386_linux_skip_solib_resolver (CORE_ADDR pc);
-
-/* N_FUN symbols in shared libaries have 0 for their values and need
- to be relocated. */
-#define SOFUN_ADDRESS_MAYBE_MISSING
\f

/* Support for longjmp. */
--- ./config/powerpc/tm-linux.h.~1~ Sun Feb 24 14:56:06 2002
+++ ./config/powerpc/tm-linux.h Mon Apr 22 23:33:05 2002
@@ -63,8 +63,4 @@ extern int ppc_linux_in_sigtramp (CORE_A
#define PROLOGUE_FIRSTLINE_OVERLAP
#endif

-/* N_FUN symbols in shared libaries have 0 for their values and need
- to be relocated. */
-#define SOFUN_ADDRESS_MAYBE_MISSING
-
#endif /* #ifndef TM_LINUX_H */
--- ./config/powerpc/tm-ppc-eabi.h.~1~ Fri Apr 12 12:48:37 2002
+++ ./config/powerpc/tm-ppc-eabi.h Mon Apr 22 23:33:13 2002
@@ -33,10 +33,6 @@
#undef TEXT_SEGMENT_BASE
#define TEXT_SEGMENT_BASE 1

-/* The value of symbols of type N_SO and N_FUN maybe null when
- it shouldn't be. */
-#define SOFUN_ADDRESS_MAYBE_MISSING
-
/* Use generic shared library machinery. */
#include "solib.h"

--- ./config/sparc/tm-sun4sol2.h.~1~ Sun Jun 17 09:57:28 2001
+++ ./config/sparc/tm-sun4sol2.h Mon Apr 22 23:33:25 2002
@@ -68,10 +68,6 @@ extern int get_longjmp_target (CORE_ADDR
#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR)
#endif /* 0 */

-/* The SunPRO compiler puts out 0 instead of the address in N_SO symbols,
- and for SunPRO 3.0, N_FUN symbols too. */
-#define SOFUN_ADDRESS_MAYBE_MISSING
-
extern char *sunpro_static_transform_name (char *);
#define STATIC_TRANSFORM_NAME(x) sunpro_static_transform_name (x)
#define IS_STATIC_TRANSFORM_NAME(name) ((name)[0] == '$')
--- ./dbxread.c.~1~ Thu Mar 21 11:48:54 2002
+++ ./dbxread.c Mon Apr 22 23:31:24 2002
@@ -1498,7 +1498,6 @@ read_dbx_symtab (struct objfile *objfile

prev_textlow_not_set = textlow_not_set;

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* A zero value is probably an indication for the SunPRO 3.0
compiler. end_psymtab explicitly tests for zero, so
don't relocate it. */
@@ -1510,9 +1509,7 @@ read_dbx_symtab (struct objfile *objfile
}
else
textlow_not_set = 0;
-#else
- textlow_not_set = 0;
-#endif
+
past_first_source_file = 1;

if (prev_so_symnum != symnum - 1)
@@ -1865,9 +1862,9 @@ read_dbx_symtab (struct objfile *objfile
xfree (name);
}
nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- /* Kludges for ELF/STABS with Sun ACC */
+
last_function_name = namestring;
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
+
/* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
value for the bottom of the text seg in those cases. */
if (nlist.n_value == ANOFFSET (objfile->section_offsets,
@@ -1888,8 +1885,6 @@ read_dbx_symtab (struct objfile *objfile
TEXTLOW (pst) = nlist.n_value;
textlow_not_set = 0;
}
-#endif
- /* End kludge. */

/* Keep track of the start of the last function so we
can handle end of function symbols. */
@@ -1930,9 +1925,9 @@ read_dbx_symtab (struct objfile *objfile
xfree (name);
}
nlist.n_value += ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
- /* Kludges for ELF/STABS with Sun ACC */
+
last_function_name = namestring;
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
+
/* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
value for the bottom of the text seg in those cases. */
if (nlist.n_value == ANOFFSET (objfile->section_offsets,
@@ -1953,8 +1948,6 @@ read_dbx_symtab (struct objfile *objfile
TEXTLOW (pst) = nlist.n_value;
textlow_not_set = 0;
}
-#endif
- /* End kludge. */

/* Keep track of the start of the last function so we
can handle end of function symbols. */
@@ -2081,7 +2074,6 @@ read_dbx_symtab (struct objfile *objfile
continue;

case N_ENDM:
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* Solaris 2 end of module, finish current partial symbol table.
end_psymtab will set TEXTHIGH (pst) to the proper value, which
is necessary if a module compiled without debugging info
@@ -2096,7 +2088,6 @@ read_dbx_symtab (struct objfile *objfile
includes_used = 0;
dependencies_used = 0;
}
-#endif
continue;

case N_RBRAC:
@@ -2228,7 +2219,6 @@ end_psymtab (struct partial_symtab *pst,
LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst);
TEXTHIGH (pst) = capping_text;

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* Under Solaris, the N_SO symbols always have a value of 0,
instead of the usual address of the .o file. Therefore,
we have to do some tricks to fill in texthigh and textlow.
@@ -2300,9 +2290,6 @@ end_psymtab (struct partial_symtab *pst,
}
}

- /* End of kludge for patching Solaris textlow and texthigh. */
-#endif /* SOFUN_ADDRESS_MAYBE_MISSING. */
-
pst->n_global_syms =
objfile->global_psymbols.next - (objfile->global_psymbols.list + pst->globals_offset);
pst->n_static_syms =
@@ -3106,7 +3093,6 @@ process_one_symbol (int type, int desc,
case 'F':
function_stab_type = type;

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* Deal with the SunPRO 3.0 compiler which omits the address
from N_FUN symbols. */
if (type == N_FUN
@@ -3123,7 +3109,6 @@ process_one_symbol (int type, int desc,
if (minsym_valu != 0)
valu = minsym_valu;
}
-#endif

#ifdef SUN_FIXED_LBRAC_BUG
/* The Sun acc compiler, under SunOS4, puts out
--- ./elfread.c.~1~ Tue Mar 19 11:00:03 2002
+++ ./elfread.c Mon Apr 22 23:31:41 2002
@@ -201,10 +201,8 @@ elf_symtab_read (struct objfile *objfile
/* If filesym is nonzero, it points to a file symbol, but we haven't
seen any section info for it yet. */
asymbol *filesym = 0;
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* Name of filesym, as saved on the symbol_obstack. */
char *filesymname = obsavestring ("", 0, &objfile->symbol_obstack);
-#endif
struct dbx_symfile_info *dbx = objfile->sym_stab_info;
unsigned long size;
int stripped = (bfd_get_symcount (objfile->obfd) == 0);
@@ -269,10 +267,8 @@ elf_symtab_read (struct objfile *objfile
msym = record_minimal_symbol_and_info
((char *) sym->name, symaddr,
mst_solib_trampoline, NULL, sym->section, objfile);
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (msym != NULL)
msym->filename = filesymname;
-#endif
continue;
}

@@ -292,11 +288,9 @@ elf_symtab_read (struct objfile *objfile
sectinfo = NULL;
}
filesym = sym;
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
filesymname =
obsavestring ((char *) filesym->name, strlen (filesym->name),
&objfile->symbol_obstack);
-#endif
}
else if (sym->flags & (BSF_GLOBAL | BSF_LOCAL | BSF_WEAK))
{
@@ -491,10 +485,8 @@ elf_symtab_read (struct objfile *objfile
msym = record_minimal_symbol_and_info
((char *) sym->name, symaddr,
ms_type, (void *) size, sym->section, objfile);
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (msym != NULL)
msym->filename = filesymname;
-#endif
ELF_MAKE_MSYMBOL_SPECIAL (sym, msym);
}
}
--- ./minsyms.c.~1~ Tue Mar 19 11:00:04 2002
+++ ./minsyms.c Mon Apr 22 23:32:21 2002
@@ -157,14 +157,12 @@ lookup_minimal_symbol (register const ch
unsigned int hash = msymbol_hash (name);
unsigned int dem_hash = msymbol_hash_iw (name);

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (sfile != NULL)
{
char *p = strrchr (sfile, '/');
if (p != NULL)
sfile = p + 1;
}
-#endif

for (objfile = object_files;
objfile != NULL && found_symbol == NULL;
@@ -193,17 +191,8 @@ lookup_minimal_symbol (register const ch
case mst_file_text:
case mst_file_data:
case mst_file_bss:
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (sfile == NULL || STREQ (msymbol->filename, sfile))
found_file_symbol = msymbol;
-#else
- /* We have neither the ability nor the need to
- deal with the SFILE parameter. If we find
- more than one symbol, just return the latest
- one (the user can't expect useful behavior in
- that case). */
- found_file_symbol = msymbol;
-#endif
break;

case mst_solib_trampoline:
@@ -264,14 +253,12 @@ lookup_minimal_symbol_text (register con
struct minimal_symbol *found_symbol = NULL;
struct minimal_symbol *found_file_symbol = NULL;

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (sfile != NULL)
{
char *p = strrchr (sfile, '/');
if (p != NULL)
sfile = p + 1;
}
-#endif

for (objfile = object_files;
objfile != NULL && found_symbol == NULL;
@@ -291,17 +278,8 @@ lookup_minimal_symbol_text (register con
switch (MSYMBOL_TYPE (msymbol))
{
case mst_file_text:
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (sfile == NULL || STREQ (msymbol->filename, sfile))
found_file_symbol = msymbol;
-#else
- /* We have neither the ability nor the need to
- deal with the SFILE parameter. If we find
- more than one symbol, just return the latest
- one (the user can't expect useful behavior in
- that case). */
- found_file_symbol = msymbol;
-#endif
break;
default:
found_symbol = msymbol;
@@ -338,14 +316,12 @@ lookup_minimal_symbol_solib_trampoline (
struct minimal_symbol *msymbol;
struct minimal_symbol *found_symbol = NULL;

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (sfile != NULL)
{
char *p = strrchr (sfile, '/');
if (p != NULL)
sfile = p + 1;
}
-#endif

for (objfile = object_files;
objfile != NULL && found_symbol == NULL;
@@ -505,7 +481,6 @@ lookup_minimal_symbol_by_pc (CORE_ADDR p
return lookup_minimal_symbol_by_pc_section (pc, find_pc_mapped_section (pc));
}

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
CORE_ADDR
find_stab_function_addr (char *namestring, char *filename,
struct objfile *objfile)
@@ -549,7 +524,6 @@ find_stab_function_addr (char *namestrin

return msym == NULL ? 0 : SYMBOL_VALUE_ADDRESS (msym);
}
-#endif /* SOFUN_ADDRESS_MAYBE_MISSING */
\f

/* Return leading symbol character for a BFD. If BFD is NULL,
--- ./mdebugread.c.~1~ Mon Apr 22 03:19:35 2002
+++ ./mdebugread.c Mon Apr 22 23:31:53 2002
@@ -2835,7 +2835,6 @@ parse_partial_symbols (struct objfile *o

prev_textlow_not_set = textlow_not_set;

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* A zero value is probably an indication for the SunPRO 3.0
compiler. end_psymtab explicitly tests for zero, so
don't relocate it. */
@@ -2847,9 +2846,7 @@ parse_partial_symbols (struct objfile *o
}
else
textlow_not_set = 0;
-#else
- textlow_not_set = 0;
-#endif
+
past_first_source_file = 1;

if (prev_so_symnum != symnum - 1)
@@ -3229,7 +3226,6 @@ parse_partial_symbols (struct objfile *o
continue;

case N_ENDM:
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* Solaris 2 end of module, finish current partial symbol table.
END_PSYMTAB will set TEXTHIGH (pst) to the proper value, which
is necessary if a module compiled without debugging info
@@ -3240,7 +3236,6 @@ parse_partial_symbols (struct objfile *o
includes_used = 0;
dependencies_used = 0;
}
-#endif
continue;

case N_RBRAC:
--- ./symmisc.c.~1~ Fri Mar 22 10:57:08 2002
+++ ./symmisc.c Mon Apr 22 23:32:29 2002
@@ -321,10 +321,8 @@ dump_msymbols (struct objfile *objfile,
{
fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol));
}
-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
if (msymbol->filename)
fprintf_filtered (outfile, " %s", msymbol->filename);
-#endif
fputs_filtered ("\n", outfile);
}
if (objfile->minimal_symbol_count != index)
--- ./symtab.h.~1~ Tue Apr 9 13:51:33 2002
+++ ./symtab.h Mon Apr 22 23:32:40 2002
@@ -258,10 +258,8 @@ struct minimal_symbol

char *info;

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
/* Which source file is this symbol in? Only relevant for mst_file_*. */
char *filename;
-#endif

/* Classification types for this symbol. These should be taken as "advisory
only", since if gdb can't easily figure out a classification it simply
@@ -1139,9 +1137,7 @@ extern struct minimal_symbol *prim_recor
enum minimal_symbol_type,
char *info, int section, asection * bfd_section, struct objfile *);

-#ifdef SOFUN_ADDRESS_MAYBE_MISSING
extern CORE_ADDR find_stab_function_addr (char *, char *, struct objfile *);
-#endif

extern unsigned int msymbol_hash_iw (const char *);