system.h (SUNOS4_SHARED_LIBRARIES): Poison.

* system.h (SUNOS4_SHARED_LIBRARIES): Poison.
	* collect2.c: Remove SUNOS4_SHARED_LIBRARIES code.
	* config/sparc/aout.h (TARGET_ASM_SELECT_SECTION): Don't define.
	* config/sparc/sparc.c (sparc_aout_select_section): Remove.
	(sparc_aout_select_rtx_section): Don't check
	SUNOS4_SHARED_LIBRARIES.
	* config/sparc/sparc.h (SUNOS4_SHARED_LIBRARIES): Don't define.

From-SVN: r79216
This commit is contained in:
Ian Lance Taylor 2004-03-10 00:17:36 +00:00 committed by Ian Lance Taylor
parent b86f05b692
commit 9acd4a03dd
6 changed files with 13 additions and 291 deletions

View File

@ -1,3 +1,13 @@
2004-03-09 Ian Lance Taylor <ian@wasabisystems.com>
* system.h (SUNOS4_SHARED_LIBRARIES): Poison.
* collect2.c: Remove SUNOS4_SHARED_LIBRARIES code.
* config/sparc/aout.h (TARGET_ASM_SELECT_SECTION): Don't define.
* config/sparc/sparc.c (sparc_aout_select_section): Remove.
(sparc_aout_select_rtx_section): Don't check
SUNOS4_SHARED_LIBRARIES.
* config/sparc/sparc.h (SUNOS4_SHARED_LIBRARIES): Don't define.
2004-03-10 Hans-Peter Nilsson <hp@axis.com>
PR other/14474

View File

@ -67,7 +67,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
cross-versions are in the proper directories. */
#ifdef CROSS_COMPILE
#undef SUNOS4_SHARED_LIBRARIES
#undef OBJECT_FORMAT_COFF
#undef MD_EXEC_PREFIX
#undef REAL_LD_FILE_NAME
@ -140,7 +139,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
fprintf ((STREAM), "void _GLOBAL__DD() {\n\t%s();\n}\n", (FUNC))
#endif
#if defined (LDD_SUFFIX) || SUNOS4_SHARED_LIBRARIES
#ifdef LDD_SUFFIX
#define SCAN_LIBRARIES
#endif
@ -2148,269 +2147,6 @@ scan_prog_file (const char *prog_name, enum pass which_pass)
#endif
}
#if SUNOS4_SHARED_LIBRARIES
/* Routines to scan the SunOS 4 _DYNAMIC structure to find shared libraries
that the output file depends upon and their initialization/finalization
routines, if any. */
#include <a.out.h>
#include <fcntl.h>
#include <link.h>
#include <sys/mman.h>
#include <sys/param.h>
#include <unistd.h>
#include <sys/dir.h>
/* pointers to the object file */
unsigned object; /* address of memory mapped file */
unsigned objsize; /* size of memory mapped to file */
char * code; /* pointer to code segment */
char * data; /* pointer to data segment */
struct nlist *symtab; /* pointer to symbol table */
struct link_dynamic *ld;
struct link_dynamic_2 *ld_2;
struct head libraries;
/* Map the file indicated by NAME into memory and store its address. */
static void
mapfile (const char *name)
{
int fp;
struct stat s;
if ((fp = open (name, O_RDONLY)) == -1)
fatal ("unable to open file '%s'", name);
if (fstat (fp, &s) == -1)
fatal ("unable to stat file '%s'", name);
objsize = s.st_size;
object = (unsigned) mmap (0, objsize, PROT_READ|PROT_WRITE, MAP_PRIVATE,
fp, 0);
if (object == (unsigned)-1)
fatal ("unable to mmap file '%s'", name);
close (fp);
}
/* Helpers for locatelib. */
static const char *libname;
static int
libselect (struct direct *d)
{
return (strncmp (libname, d->d_name, strlen (libname)) == 0);
}
/* If one file has an additional numeric extension past LIBNAME, then put
that one first in the sort. If both files have additional numeric
extensions, then put the one with the higher number first in the sort.
We must verify that the extension is numeric, because Sun saves the
original versions of patched libraries with a .FCS extension. Files with
invalid extensions must go last in the sort, so that they will not be used. */
static int
libcompare (struct direct **d1, struct direct **d2)
{
int i1, i2 = strlen (libname);
char *e1 = (*d1)->d_name + i2;
char *e2 = (*d2)->d_name + i2;
while (*e1 && *e2 && *e1 == '.' && *e2 == '.'
&& e1[1] && ISDIGIT (e1[1]) && e2[1] && ISDIGIT (e2[1]))
{
++e1;
++e2;
i1 = strtol (e1, &e1, 10);
i2 = strtol (e2, &e2, 10);
if (i1 != i2)
return i1 - i2;
}
if (*e1)
{
/* It has a valid numeric extension, prefer this one. */
if (*e1 == '.' && e1[1] && ISDIGIT (e1[1]))
return 1;
/* It has an invalid numeric extension, must prefer the other one. */
else
return -1;
}
else if (*e2)
{
/* It has a valid numeric extension, prefer this one. */
if (*e2 == '.' && e2[1] && ISDIGIT (e2[1]))
return -1;
/* It has an invalid numeric extension, must prefer the other one. */
else
return 1;
}
else
return 0;
}
/* Given the name NAME of a dynamic dependency, find its pathname and add
it to the list of libraries. */
static void
locatelib (const char *name)
{
static const char **l;
static int cnt;
char buf[MAXPATHLEN];
char *p, *q;
const char **pp;
if (l == 0)
{
char *ld_rules;
char *ldr = 0;
/* counting elements in array, need 1 extra for null */
cnt = 1;
ld_rules = (char *) (ld_2->ld_rules + code);
if (ld_rules)
{
cnt++;
for (; *ld_rules != 0; ld_rules++)
if (*ld_rules == ':')
cnt++;
ld_rules = (char *) (ld_2->ld_rules + code);
ldr = xstrdup (ld_rules);
}
p = getenv ("LD_LIBRARY_PATH");
q = 0;
if (p)
{
cnt++;
for (q = p ; *q != 0; q++)
if (*q == ':')
cnt++;
q = xstrdup (p);
}
l = xmalloc ((cnt + 3) * sizeof (char *));
pp = l;
if (ldr)
{
*pp++ = ldr;
for (; *ldr != 0; ldr++)
if (*ldr == ':')
{
*ldr++ = 0;
*pp++ = ldr;
}
}
if (q)
{
*pp++ = q;
for (; *q != 0; q++)
if (*q == ':')
{
*q++ = 0;
*pp++ = q;
}
}
/* built in directories are /lib, /usr/lib, and /usr/local/lib */
*pp++ = "/lib";
*pp++ = "/usr/lib";
*pp++ = "/usr/local/lib";
*pp = 0;
}
libname = name;
for (pp = l; *pp != 0 ; pp++)
{
struct direct **namelist;
int entries;
if ((entries = scandir (*pp, &namelist, libselect, libcompare)) > 0)
{
sprintf (buf, "%s/%s", *pp, namelist[entries - 1]->d_name);
add_to_list (&libraries, buf);
if (debug)
fprintf (stderr, "%s\n", buf);
break;
}
}
if (*pp == 0)
{
if (debug)
notice ("not found\n");
else
fatal ("dynamic dependency %s not found", name);
}
}
/* Scan the _DYNAMIC structure of the output file to find shared libraries
that it depends upon and any constructors or destructors they contain. */
static void
scan_libraries (const char *prog_name)
{
struct exec *header;
char *base;
struct link_object *lo;
char buff[MAXPATHLEN];
struct id *list;
mapfile (prog_name);
header = (struct exec *)object;
if (N_BADMAG (*header))
fatal ("bad magic number in file '%s'", prog_name);
if (header->a_dynamic == 0)
return;
code = (char *) (N_TXTOFF (*header) + (long) header);
data = (char *) (N_DATOFF (*header) + (long) header);
symtab = (struct nlist *) (N_SYMOFF (*header) + (long) header);
if (header->a_magic == ZMAGIC && header->a_entry == 0x20)
{
/* shared object */
ld = (struct link_dynamic *) (symtab->n_value + code);
base = code;
}
else
{
/* executable */
ld = (struct link_dynamic *) data;
base = code-PAGSIZ;
}
if (debug)
notice ("dynamic dependencies.\n");
ld_2 = (struct link_dynamic_2 *) ((long) ld->ld_un.ld_2 + (long)base);
for (lo = (struct link_object *) ld_2->ld_need; lo;
lo = (struct link_object *) lo->lo_next)
{
char *name;
lo = (struct link_object *) ((long) lo + code);
name = (char *) (code + lo->lo_name);
if (lo->lo_library)
{
if (debug)
fprintf (stderr, "\t-l%s.%d => ", name, lo->lo_major);
sprintf (buff, "lib%s.so.%d.%d", name, lo->lo_major, lo->lo_minor);
locatelib (buff);
}
else
{
if (debug)
fprintf (stderr, "\t%s\n", name);
add_to_list (&libraries, name);
}
}
if (debug)
fprintf (stderr, "\n");
/* Now iterate through the library list adding their symbols to
the list. */
for (list = libraries.first; list; list = list->next)
scan_prog_file (list->name, PASS_LIB);
}
#else /* SUNOS4_SHARED_LIBRARIES */
#ifdef LDD_SUFFIX
/* Use the List Dynamic Dependencies program to find shared libraries that
@ -2547,7 +2283,6 @@ scan_libraries (const char *prog_name)
}
#endif /* LDD_SUFFIX */
#endif /* SUNOS4_SHARED_LIBRARIES */
#endif /* OBJECT_FORMAT_NONE */

View File

@ -29,7 +29,6 @@ Boston, MA 02111-1307, USA. */
(DEFAULT_WORD_SWITCH_TAKES_ARG (STR) \
|| !strcmp (STR, "target") || !strcmp (STR, "assert"))
#define TARGET_ASM_SELECT_SECTION sparc_aout_select_section
#define TARGET_ASM_SELECT_RTX_SECTION sparc_aout_select_rtx_section
/* Output the label for a function definition. */

View File

@ -160,8 +160,6 @@ static void sparc_function_prologue (FILE *, HOST_WIDE_INT, int);
#ifdef OBJECT_FORMAT_ELF
static void sparc_elf_asm_named_section (const char *, unsigned int);
#endif
static void sparc_aout_select_section (tree, int, unsigned HOST_WIDE_INT)
ATTRIBUTE_UNUSED;
static void sparc_aout_select_rtx_section (enum machine_mode, rtx,
unsigned HOST_WIDE_INT)
ATTRIBUTE_UNUSED;
@ -8125,16 +8123,6 @@ sparc_init_libfuncs (void)
gofast_maybe_init_libfuncs ();
}
/* ??? Similar to the standard section selection, but force reloc-y-ness
if SUNOS4_SHARED_LIBRARIES. Unclear why this helps (as opposed to
pretending PIC always on), but that's what the old code did. */
static void
sparc_aout_select_section (tree t, int reloc, unsigned HOST_WIDE_INT align)
{
default_select_section (t, reloc | SUNOS4_SHARED_LIBRARIES, align);
}
/* Use text section for a constant unless we need more alignment than
that offers. */
@ -8143,8 +8131,7 @@ sparc_aout_select_rtx_section (enum machine_mode mode, rtx x,
unsigned HOST_WIDE_INT align)
{
if (align <= MAX_TEXT_ALIGN
&& ! (flag_pic && (symbolic_operand (x, mode)
|| SUNOS4_SHARED_LIBRARIES)))
&& ! (flag_pic && symbolic_operand (x, mode)))
readonly_data_section ();
else
data_section ();

View File

@ -801,15 +801,6 @@ if (TARGET_ARCH64 \
because the linker fails to align the text section enough!
Put them in the data section. This macro is only used in this file. */
#define MAX_TEXT_ALIGN 32
/* This forces all variables and constants to the data section when PIC.
This is because the SunOS 4 shared library scheme thinks everything in
text is a function, and patches the address to point to a loader stub. */
/* This is defined to zero for every system which doesn't use the a.out object
file format. */
#ifndef SUNOS4_SHARED_LIBRARIES
#define SUNOS4_SHARED_LIBRARIES 0
#endif
/* Standard register usage. */

View File

@ -641,7 +641,7 @@ typedef char _Bool;
FINAL_REG_PARM_STACK_SPACE MAYBE_REG_PARM_STACK_SPACE \
TRADITIONAL_PIPELINE_INTERFACE DFA_PIPELINE_INTERFACE \
DBX_OUTPUT_STANDARD_TYPES BUILTIN_SETJMP_FRAME_VALUE \
MD_ASM_CLOBBERS
MD_ASM_CLOBBERS SUNOS4_SHARED_LIBRARIES
/* Hooks that are no longer used. */
#pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \