Deleted Added
full compact
collect2.c (132718) collect2.c (146895)
1/* Collect static initialization info into data structures that can be
2 traversed by C++ initialization and finalization routines.
3 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 Contributed by Chris Smith (csmith@convex.com).
6 Heavily modified by Michael Meissner (meissner@cygnus.com),
7 Per Bothner (bothner@cygnus.com), and John Gilmore (gnu@cygnus.com).
8

--- 175 unchanged lines hidden (view full) ---

184};
185
186int vflag; /* true if -v */
187static int rflag; /* true if -r */
188static int strip_flag; /* true if -s */
189#ifdef COLLECT_EXPORT_LIST
190static int export_flag; /* true if -bE */
191static int aix64_flag; /* true if -b64 */
1/* Collect static initialization info into data structures that can be
2 traversed by C++ initialization and finalization routines.
3 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 Contributed by Chris Smith (csmith@convex.com).
6 Heavily modified by Michael Meissner (meissner@cygnus.com),
7 Per Bothner (bothner@cygnus.com), and John Gilmore (gnu@cygnus.com).
8

--- 175 unchanged lines hidden (view full) ---

184};
185
186int vflag; /* true if -v */
187static int rflag; /* true if -r */
188static int strip_flag; /* true if -s */
189#ifdef COLLECT_EXPORT_LIST
190static int export_flag; /* true if -bE */
191static int aix64_flag; /* true if -b64 */
192static int aixrtl_flag; /* true if -brtl */
192#endif
193
194int debug; /* true if -debug */
195
196static int shared_obj; /* true if -shared */
197
198static const char *c_file; /* <xxx>.c for constructor/destructor list. */
199static const char *o_file; /* <xxx>.o for constructor/destructor list. */

--- 41 unchanged lines hidden (view full) ---

241
242#ifdef COLLECT_EXPORT_LIST
243/* Lists to keep libraries to be scanned for global constructors/destructors. */
244static struct head libs; /* list of libraries */
245static struct path_prefix cmdline_lib_dirs; /* directories specified with -L */
246static struct path_prefix libpath_lib_dirs; /* directories in LIBPATH */
247static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs,
248 &libpath_lib_dirs, NULL};
193#endif
194
195int debug; /* true if -debug */
196
197static int shared_obj; /* true if -shared */
198
199static const char *c_file; /* <xxx>.c for constructor/destructor list. */
200static const char *o_file; /* <xxx>.o for constructor/destructor list. */

--- 41 unchanged lines hidden (view full) ---

242
243#ifdef COLLECT_EXPORT_LIST
244/* Lists to keep libraries to be scanned for global constructors/destructors. */
245static struct head libs; /* list of libraries */
246static struct path_prefix cmdline_lib_dirs; /* directories specified with -L */
247static struct path_prefix libpath_lib_dirs; /* directories in LIBPATH */
248static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs,
249 &libpath_lib_dirs, NULL};
249static const char *const libexts[3] = {"a", "so", NULL}; /* possible library extensions */
250#endif
251
252static void handler (int);
253static int is_ctor_dtor (const char *);
254static char *find_a_file (struct path_prefix *, const char *);
255static void add_prefix (struct path_prefix *, const char *);
256static void prefix_from_env (const char *, struct path_prefix *);
257static void prefix_from_string (const char *, struct path_prefix *);

--- 817 unchanged lines hidden (view full) ---

1075#ifdef COLLECT_EXPORT_LIST
1076 /* We want to disable automatic exports on AIX when user
1077 explicitly puts an export list in command line */
1078 case 'b':
1079 if (arg[2] == 'E' || strncmp (&arg[2], "export", 6) == 0)
1080 export_flag = 1;
1081 else if (arg[2] == '6' && arg[3] == '4')
1082 aix64_flag = 1;
250#endif
251
252static void handler (int);
253static int is_ctor_dtor (const char *);
254static char *find_a_file (struct path_prefix *, const char *);
255static void add_prefix (struct path_prefix *, const char *);
256static void prefix_from_env (const char *, struct path_prefix *);
257static void prefix_from_string (const char *, struct path_prefix *);

--- 817 unchanged lines hidden (view full) ---

1075#ifdef COLLECT_EXPORT_LIST
1076 /* We want to disable automatic exports on AIX when user
1077 explicitly puts an export list in command line */
1078 case 'b':
1079 if (arg[2] == 'E' || strncmp (&arg[2], "export", 6) == 0)
1080 export_flag = 1;
1081 else if (arg[2] == '6' && arg[3] == '4')
1082 aix64_flag = 1;
1083 else if (arg[2] == 'r' && arg[3] == 't' && arg[4] == 'l')
1084 aixrtl_flag = 1;
1083 break;
1084#endif
1085
1086 case 'd':
1087 if (!strcmp (arg, "-debug"))
1088 {
1089 /* Already parsed. */
1090 ld1--;

--- 1727 unchanged lines hidden (view full) ---

2818#ifdef COLLECT_EXPORT_LIST
2819/* Given a library name without "lib" prefix, this function
2820 returns a full library name including a path. */
2821static char *
2822resolve_lib_name (const char *name)
2823{
2824 char *lib_buf;
2825 int i, j, l = 0;
1085 break;
1086#endif
1087
1088 case 'd':
1089 if (!strcmp (arg, "-debug"))
1090 {
1091 /* Already parsed. */
1092 ld1--;

--- 1727 unchanged lines hidden (view full) ---

2820#ifdef COLLECT_EXPORT_LIST
2821/* Given a library name without "lib" prefix, this function
2822 returns a full library name including a path. */
2823static char *
2824resolve_lib_name (const char *name)
2825{
2826 char *lib_buf;
2827 int i, j, l = 0;
2828 /* Library extensions for AIX dynamic linking. */
2829 const char * const libexts[2] = {"a", "so"};
2826
2827 for (i = 0; libpaths[i]; i++)
2828 if (libpaths[i]->max_len > l)
2829 l = libpaths[i]->max_len;
2830
2831 lib_buf = xmalloc (l + strlen(name) + 10);
2832
2833 for (i = 0; libpaths[i]; i++)
2834 {
2835 struct prefix_list *list = libpaths[i]->plist;
2836 for (; list; list = list->next)
2837 {
2838 /* The following lines are needed because path_prefix list
2839 may contain directories both with trailing '/' and
2840 without it. */
2841 const char *p = "";
2842 if (list->prefix[strlen(list->prefix)-1] != '/')
2843 p = "/";
2830
2831 for (i = 0; libpaths[i]; i++)
2832 if (libpaths[i]->max_len > l)
2833 l = libpaths[i]->max_len;
2834
2835 lib_buf = xmalloc (l + strlen(name) + 10);
2836
2837 for (i = 0; libpaths[i]; i++)
2838 {
2839 struct prefix_list *list = libpaths[i]->plist;
2840 for (; list; list = list->next)
2841 {
2842 /* The following lines are needed because path_prefix list
2843 may contain directories both with trailing '/' and
2844 without it. */
2845 const char *p = "";
2846 if (list->prefix[strlen(list->prefix)-1] != '/')
2847 p = "/";
2844 for (j = 0; libexts[j]; j++)
2848 for (j = 0; j < 2; j++)
2845 {
2846 sprintf (lib_buf, "%s%slib%s.%s",
2849 {
2850 sprintf (lib_buf, "%s%slib%s.%s",
2847 list->prefix, p, name, libexts[j]);
2848if (debug) fprintf (stderr, "searching for: %s\n", lib_buf);
2851 list->prefix, p, name,
2852 libexts[(j + aixrtl_flag) % 2]);
2853 if (debug) fprintf (stderr, "searching for: %s\n", lib_buf);
2849 if (file_exists (lib_buf))
2850 {
2854 if (file_exists (lib_buf))
2855 {
2851if (debug) fprintf (stderr, "found: %s\n", lib_buf);
2856 if (debug) fprintf (stderr, "found: %s\n", lib_buf);
2852 return (lib_buf);
2853 }
2854 }
2855 }
2856 }
2857 if (debug)
2858 fprintf (stderr, "not found\n");
2859 else
2860 fatal ("library lib%s not found", name);
2861 return (NULL);
2862}
2863#endif /* COLLECT_EXPORT_LIST */
2857 return (lib_buf);
2858 }
2859 }
2860 }
2861 }
2862 if (debug)
2863 fprintf (stderr, "not found\n");
2864 else
2865 fatal ("library lib%s not found", name);
2866 return (NULL);
2867}
2868#endif /* COLLECT_EXPORT_LIST */