summaryrefslogtreecommitdiff
path: root/m68k-unknown-amigaos/recipes/patches/gcc/gcc.collect2.c.p
blob: 519a71ffd996d444d26a56bb04cf4809a23ebfad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
--- gcc-3.4.6/gcc/collect2.c	2013-05-19 20:08:05.000000000 +0200
+++ gcc/collect2.c	2013-05-19 20:23:32.000000000 +0200
@@ -144,6 +144,12 @@
 #define SCAN_LIBRARIES
 #endif
 
+/* begin-GG-local: dynamic libraries */
+#ifndef DO_COLLECTING
+#define DO_COLLECTING do_collecting
+#endif
+/* end-GG-local */
+
 #ifdef USE_COLLECT2
 int do_collecting = 1;
 #else
@@ -256,8 +262,10 @@
 static void prefix_from_env (const char *, struct path_prefix *);
 static void prefix_from_string (const char *, struct path_prefix *);
 static void do_wait (const char *);
-static void fork_execute (const char *, char **);
-static void maybe_unlink (const char *);
+/* begin-GG-local: dynamic libraries */
+void fork_execute (const char *, char **);
+void maybe_unlink (const char *);
+/* end-GG-local */
 static void add_to_list (struct head *, const char *);
 static int extract_init_priority (const char *);
 static void sort_ids (struct head *);
@@ -335,6 +343,12 @@
   if (status != 0 && output_file != 0 && output_file[0])
     maybe_unlink (output_file);
 
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_EXTRA_CLEANUP
+  COLLECT2_EXTRA_CLEANUP();
+#endif
+/* end-GG-local */
+
   exit (status);
 }
 
@@ -423,6 +437,12 @@
     maybe_unlink (export_file);
 #endif
 
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_EXTRA_CLEANUP
+  COLLECT2_EXTRA_CLEANUP();
+#endif
+/* end-GG-local */
+
   signal (signo, SIG_DFL);
   kill (getpid (), signo);
 }
@@ -609,11 +629,7 @@
 
   /* Determine the filename to execute (special case for absolute paths).  */
 
-  if (*name == '/'
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
-      || (*name && name[1] == ':')
-#endif
-      )
+  if (IS_ABSOLUTE_PATH (name))
     {
       if (access (name, X_OK) == 0)
 	{
@@ -881,6 +897,11 @@
       const char *q = extract_string (&p);
       if (*q == '-' && (q[1] == 'm' || q[1] == 'f'))
 	num_c_args++;
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_GCC_OPTIONS_HOOK
+      COLLECT2_GCC_OPTIONS_HOOK(q);
+#endif
+/* end-GG-local */
     }
   obstack_free (&temporary_obstack, temporary_firstobj);
 
@@ -1112,6 +1133,11 @@
 		add_to_list (&libs, s);
 	      }
 #endif
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_LIBNAME_HOOK
+	      COLLECT2_LIBNAME_HOOK(arg);
+#endif
+/* end-GG-local */
 	      break;
 
 #ifdef COLLECT_EXPORT_LIST
@@ -1146,7 +1172,9 @@
 	      break;
 
 	    case 's':
-	      if (arg[2] == '\0' && do_collecting)
+/* begin-GG-local: dynamic libraries */
+	      if (arg[2] == '\0' && DO_COLLECTING)
+/* end-GG-local */
 		{
 		  /* We must strip after the nm run, otherwise C++ linking
 		     will not work.  Thus we strip in the second ld run, or
@@ -1190,6 +1218,11 @@
               add_to_list (&libs, arg);
             }
 #endif
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_LIBNAME_HOOK
+	  COLLECT2_LIBNAME_HOOK(arg);
+#endif
+/* end-GG-local */
 	}
     }
 
@@ -1283,6 +1316,12 @@
       fprintf (stderr, "\n");
     }
 
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_PRELINK_HOOK
+  COLLECT2_PRELINK_HOOK(ld1_argv, &strip_flag);
+#endif
+/* end-GG-local */
+
   /* Load the program, searching all libraries and attempting to provide
      undefined symbols from repository information.  */
 
@@ -1295,7 +1334,9 @@
      constructor or destructor list, just return now.  */
   if (rflag
 #ifndef COLLECT_EXPORT_LIST
-      || ! do_collecting
+/* begin-GG-local: dynamic libraries */
+      || ! DO_COLLECTING
+/* end-GG-local */
 #endif
       )
     {
@@ -1312,6 +1353,8 @@
       return 0;
     }
 
+/* begin-GG-local: dynamic libraries */
+#ifndef COLLECT2_POSTLINK_HOOK
   /* Examine the namelist with nm and search it for static constructors
      and destructors to call.
      Write the constructor and destructor tables to a .s file and reload.  */
@@ -1331,6 +1374,10 @@
       notice ("%d destructor(s)  found\n", destructors.number);
       notice ("%d frame table(s) found\n", frame_tables.number);
     }
+#else /* COLLECT2_POSTLINK_HOOK */
+  COLLECT2_POSTLINK_HOOK(output_file);
+#endif
+/* end-GG-local */
 
   if (constructors.number == 0 && destructors.number == 0
       && frame_tables.number == 0
@@ -1363,6 +1410,11 @@
 #endif
       maybe_unlink (c_file);
       maybe_unlink (o_file);
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_EXTRA_CLEANUP
+      COLLECT2_EXTRA_CLEANUP();
+#endif
+/* end-GG-local */
       return 0;
     }
 
@@ -1454,6 +1506,11 @@
   maybe_unlink (export_file);
 #endif
 
+/* begin-GG-local: dynamic libraries */
+#ifdef COLLECT2_EXTRA_CLEANUP
+  COLLECT2_EXTRA_CLEANUP();
+#endif
+/* end-GG-local */
   return 0;
 }
 
@@ -1567,7 +1624,7 @@
    fatal_perror (errmsg_fmt, errmsg_arg);
 }
 
-static void
+void
 fork_execute (const char *prog, char **argv)
 {
   collect_execute (prog, argv, NULL);
@@ -1576,7 +1633,7 @@
 
 /* Unlink a file unless we are debugging.  */
 
-static void
+void
 maybe_unlink (const char *file)
 {
   if (!debug)