summaryrefslogtreecommitdiffstats
path: root/contrib/crossrpms/patches/binutils-2.17-rtems4.7-20061021.diff
blob: a5b2216a5cf8fdaa38cccfba06c4db94682fd893 (plain) (blame)
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
diff -uNr binutils-2.17.orig/bfd/bfd-in2.h binutils-2.17/bfd/bfd-in2.h
--- binutils-2.17.orig/bfd/bfd-in2.h	2006-03-26 01:38:42.000000000 +0100
+++ binutils-2.17/bfd/bfd-in2.h	2006-10-21 13:53:23.000000000 +0200
@@ -643,6 +643,12 @@
   DYN_NO_NEEDED = 8
 };
 
+enum notice_asneeded_action {
+  notice_as_needed,
+  notice_not_needed,
+  notice_needed
+};
+
 extern bfd_boolean bfd_elf_record_link_assignment
   (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
    bfd_boolean);
diff -uNr binutils-2.17.orig/bfd/bfd-in.h binutils-2.17/bfd/bfd-in.h
--- binutils-2.17.orig/bfd/bfd-in.h	2006-03-16 13:20:15.000000000 +0100
+++ binutils-2.17/bfd/bfd-in.h	2006-10-21 13:53:23.000000000 +0200
@@ -636,6 +636,12 @@
   DYN_NO_NEEDED = 8
 };
 
+enum notice_asneeded_action {
+  notice_as_needed,
+  notice_not_needed,
+  notice_needed
+};
+
 extern bfd_boolean bfd_elf_record_link_assignment
   (bfd *, struct bfd_link_info *, const char *, bfd_boolean,
    bfd_boolean);
diff -uNr binutils-2.17.orig/bfd/ChangeLog binutils-2.17/bfd/ChangeLog
--- binutils-2.17.orig/bfd/ChangeLog	2006-06-23 20:18:16.000000000 +0200
+++ binutils-2.17/bfd/ChangeLog	2006-10-21 13:53:23.000000000 +0200
@@ -1,3 +1,25 @@
+2006-08-08  Nick Clifton  <nickc@redhat.com>
+
+	PR binutils/2724
+	* coffcode.h (coff_new_section_hook): Only modify the section
+	symbol of sections which were created by the user.
+
+2006-07-19  Alan Modra  <amodra@bigpond.net.au>
+
+	* bfd-in.h (enum notice_asneeded_action): Define.
+	* bfd-in2.h: Regenerate.
+	* elflink.c (elf_link_add_object_symbols): Call linker "notice"
+	function with NULL name for as-needed handling.
+
+2006-07-12  Matthew R. Dempsky  <mrd@alkemio.org>
+
+	* cpu-m68k.c (bfd_m68k_compatible): Handle CPU32.
+
+2006-06-23  Daniel Jacobowitz  <dan@codesourcery.com>
+
+	* Makefile.am: Clear RELEASE.
+	* Makefile.in: Regenerated.
+
 2006-06-23  Daniel Jacobowitz  <dan@codesourcery.com>
 
 	* configure.in: Update version to 2.17.
diff -uNr binutils-2.17.orig/bfd/coffcode.h binutils-2.17/bfd/coffcode.h
--- binutils-2.17.orig/bfd/coffcode.h	2005-10-25 19:40:09.000000000 +0200
+++ binutils-2.17/bfd/coffcode.h	2006-10-21 13:53:24.000000000 +0200
@@ -1546,9 +1546,6 @@
 static bfd_boolean
 coff_new_section_hook (bfd * abfd, asection * section)
 {
-  combined_entry_type *native;
-  bfd_size_type amt;
-
   section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
 
 #ifdef RS6000COFF_C
@@ -1560,27 +1557,34 @@
     section->alignment_power = bfd_xcoff_data_align_power (abfd);
 #endif
 
-  /* Allocate aux records for section symbols, to store size and
-     related info.
-
-     @@ The 10 is a guess at a plausible maximum number of aux entries
-     (but shouldn't be a constant).  */
-  amt = sizeof (combined_entry_type) * 10;
-  native = bfd_zalloc (abfd, amt);
-  if (native == NULL)
-    return FALSE;
-
-  /* We don't need to set up n_name, n_value, or n_scnum in the native
-     symbol information, since they'll be overridden by the BFD symbol
-     anyhow.  However, we do need to set the type and storage class,
-     in case this symbol winds up getting written out.  The value 0
-     for n_numaux is already correct.  */
-
-  native->u.syment.n_type = T_NULL;
-  native->u.syment.n_sclass = C_STAT;
+  /* PR binutils/2724: Only real sections have a symbol that
+     has the coff_symbol_type structure allocated for it.  */
+  if (! bfd_is_const_section (section))
+    {
+      combined_entry_type *native;
+      bfd_size_type amt;
+
+      /* Allocate aux records for section symbols, to store size and
+	 related info.
+
+	 @@ The 10 is a guess at a plausible maximum number of aux entries
+	 (but shouldn't be a constant).  */
+      amt = sizeof (combined_entry_type) * 10;
+      native = bfd_zalloc (abfd, amt);
+      if (native == NULL)
+	return FALSE;
 
-  coffsymbol (section->symbol)->native = native;
+      /* We don't need to set up n_name, n_value, or n_scnum in the native
+	 symbol information, since they'll be overridden by the BFD symbol
+	 anyhow.  However, we do need to set the type and storage class,
+	 in case this symbol winds up getting written out.  The value 0
+	 for n_numaux is already correct.  */
+      native->u.syment.n_type = T_NULL;
+      native->u.syment.n_sclass = C_STAT;
 
+      coffsymbol (section->symbol)->native = native;
+    }
+  
   coff_set_custom_section_alignment (abfd, section,
 				     coff_section_alignment_table,
 				     coff_section_alignment_table_size);
diff -uNr binutils-2.17.orig/bfd/cpu-m68k.c binutils-2.17/bfd/cpu-m68k.c
--- binutils-2.17.orig/bfd/cpu-m68k.c	2006-03-25 11:24:27.000000000 +0100
+++ binutils-2.17/bfd/cpu-m68k.c	2006-10-21 13:53:24.000000000 +0200
@@ -202,6 +202,9 @@
   if (a->mach <= bfd_mach_m68060 && b->mach <= bfd_mach_m68060)
     /* Merge m68k machine. */
     return a->mach > b->mach ? a : b;
+  else if (a->mach == bfd_mach_cpu32 && b->mach == bfd_mach_cpu32)
+    /* CPU32 is compatible with itself. */
+    return a;
   else if (a->mach >= bfd_mach_mcf_isa_a_nodiv
 	   && b->mach >= bfd_mach_mcf_isa_a_nodiv)
     {
diff -uNr binutils-2.17.orig/bfd/elflink.c binutils-2.17/bfd/elflink.c
--- binutils-2.17.orig/bfd/elflink.c	2006-05-22 17:06:36.000000000 +0200
+++ binutils-2.17/bfd/elflink.c	2006-10-21 13:53:24.000000000 +0200
@@ -3496,6 +3496,13 @@
       if (alloc_mark == NULL)
 	goto error_free_vers;
 
+      /* Make a special call to the linker "notice" function to
+	 tell it that we are about to handle an as-needed lib.  */
+      if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
+				       notice_as_needed))
+	return FALSE;
+
+
       /* Clone the symbol table and sym hashes.  Remember some
 	 pointers into the symbol table, and dynamic symbol count.  */
       old_hash = (char *) old_tab + tabsize;
@@ -4169,6 +4176,12 @@
 	    }
 	}
 
+      /* Make a special call to the linker "notice" function to
+	 tell it that symbols added for crefs may need to be removed.  */
+      if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
+				       notice_not_needed))
+	return FALSE;
+
       free (old_tab);
       objalloc_free_block ((struct objalloc *) htab->root.table.memory,
 			   alloc_mark);
@@ -4179,6 +4192,9 @@
 
   if (old_tab != NULL)
     {
+      if (!(*info->callbacks->notice) (info, NULL, abfd, NULL,
+				       notice_needed))
+	return FALSE;
       free (old_tab);
       old_tab = NULL;
     }
diff -uNr binutils-2.17.orig/bfd/version.h binutils-2.17/bfd/version.h
--- binutils-2.17.orig/bfd/version.h	2006-06-23 20:14:41.000000000 +0200
+++ binutils-2.17/bfd/version.h	2006-10-21 13:53:24.000000000 +0200
@@ -1,3 +1,3 @@
-#define BFD_VERSION_DATE 20060623
+#define BFD_VERSION_DATE 20061021
 #define BFD_VERSION @bfd_version@
 #define BFD_VERSION_STRING @bfd_version_string@
diff -uNr binutils-2.17.orig/binutils/ChangeLog binutils-2.17/binutils/ChangeLog
--- binutils-2.17.orig/binutils/ChangeLog	2006-06-12 15:05:03.000000000 +0200
+++ binutils-2.17/binutils/ChangeLog	2006-10-21 13:53:24.000000000 +0200
@@ -1,3 +1,8 @@
+2006-08-15  Nick Clifton  <nickc@redhat.com>
+
+	PR binutils/3039
+	* wrstabs.c (stab_tag_type): Initialize 'size'.
+
 2006-06-07  Joseph S. Myers  <joseph@codesourcery.com>
 
 	* po/Make-in (pdf, ps): New dummy targets.
diff -uNr binutils-2.17.orig/binutils/wrstabs.c binutils-2.17/binutils/wrstabs.c
--- binutils-2.17.orig/binutils/wrstabs.c	2006-03-16 13:20:16.000000000 +0100
+++ binutils-2.17/binutils/wrstabs.c	2006-10-21 13:53:24.000000000 +0200
@@ -1869,7 +1869,7 @@
 {
   struct stab_write_handle *info = (struct stab_write_handle *) p;
   long index;
-  unsigned int size;
+  unsigned int size = 0;
 
   index = stab_get_struct_index (info, name, id, kind, &size);
   if (index < 0)
diff -uNr binutils-2.17.orig/gas/ChangeLog binutils-2.17/gas/ChangeLog
--- binutils-2.17.orig/gas/ChangeLog	2006-06-12 15:05:03.000000000 +0200
+++ binutils-2.17/gas/ChangeLog	2006-10-21 13:53:24.000000000 +0200
@@ -1,3 +1,8 @@
+2006-07-19  Mat Hostetter  <mat@lcs.mit.edu>
+
+	* symbols.c (report_op_error): Fix pasto.  Don't use as_bad_where
+	when file and line unknown.
+
 2006-06-07  Joseph S. Myers  <joseph@codesourcery.com>
 
 	* po/Make-in (pdf, ps): New dummy targets.
diff -uNr binutils-2.17.orig/gas/symbols.c binutils-2.17/gas/symbols.c
--- binutils-2.17.orig/gas/symbols.c	2006-01-09 18:14:40.000000000 +0100
+++ binutils-2.17/gas/symbols.c	2006-10-21 13:53:24.000000000 +0200
@@ -928,13 +928,11 @@
 	  && seg_right != undefined_section)
 	{
 	  if (right)
-	    as_bad_where (file, line,
-			  _("invalid sections for operation on `%s' and `%s' setting `%s'"),
-			  S_GET_NAME (left), S_GET_NAME (right), S_GET_NAME (symp));
+	    as_bad (_("invalid sections for operation on `%s' and `%s' setting `%s'"),
+		    S_GET_NAME (left), S_GET_NAME (right), S_GET_NAME (symp));
 	  else
-	    as_bad_where (file, line,
-			  _("invalid section for operation on `%s' setting `%s'"),
-			  S_GET_NAME (left), S_GET_NAME (symp));
+	    as_bad (_("invalid section for operation on `%s' setting `%s'"),
+		    S_GET_NAME (left), S_GET_NAME (symp));
 	}
     }
 }
diff -uNr binutils-2.17.orig/ld/ChangeLog binutils-2.17/ld/ChangeLog
--- binutils-2.17.orig/ld/ChangeLog	2006-06-12 15:07:28.000000000 +0200
+++ binutils-2.17/ld/ChangeLog	2006-10-21 13:53:24.000000000 +0200
@@ -1,3 +1,20 @@
+2006-07-19  Alan Modra  <amodra@bigpond.net.au>
+
+	* ld.h (handle_asneeded_cref): Declare.
+	* ldcref.c: Include objalloc.h.
+	(old_table, old_tab, alloc_mark): New variables.
+	(tabsize, entsize, refsize, old_symcount): Likewise.
+	(add_cref): Use bfd_hash_allocate for refs.
+	(handle_asneeded_cref): New function.
+	* ldmain.c (notice): Call handle_asneeded_cref for NULL name.
+
+2006-07-04  Daniel Jacobowitz  <dan@codesourcery.com>
+
+	Backport:
+	2006-05-19  Alan Modra  <amodra@bigpond.net.au>
+	* ldlang.c (lang_size_sections_1): Don't check mem regions for
+	os->ignored sections.
+
 2006-06-12  Fred Fish  <fnf@specifix.com>
 
 	* emulparams/elf32bmip.sh (OTHER_SECTIONS): Keep the
diff -uNr binutils-2.17.orig/ld/configure.tgt binutils-2.17/ld/configure.tgt
--- binutils-2.17.orig/ld/configure.tgt	2006-04-05 14:41:57.000000000 +0200
+++ binutils-2.17/ld/configure.tgt	2006-10-21 13:53:24.000000000 +0200
@@ -83,7 +83,8 @@
 avr-*-*)		targ_emul=avr2
 			targ_extra_emuls="avr1 avr3 avr4 avr5"
 			;;
-bfin-*-elf)		targ_emul=elf32bfin; targ_extra_emuls="elf32bfinfd" ;;
+bfin-*-elf | bfin-*-rtems*)
+			targ_emul=elf32bfin; targ_extra_emuls="elf32bfinfd" ;;
 bfin-*-uclinux*)	targ_emul=elf32bfin; targ_extra_emuls="elf32bfinfd" ;;
 cr16c-*-elf*)           targ_emul=elf32cr16c
 			;;
diff -uNr binutils-2.17.orig/ld/emulparams/h8300elf.sh binutils-2.17/ld/emulparams/h8300elf.sh
--- binutils-2.17.orig/ld/emulparams/h8300elf.sh	2005-12-22 18:43:34.000000000 +0100
+++ binutils-2.17/ld/emulparams/h8300elf.sh	2006-10-21 13:53:24.000000000 +0200
@@ -17,7 +17,7 @@
 TINY_DATA_SECTION=".tinydata	0xff8000 :
   {
 	*(.tinydata)
-	_tinydata = .;
+	${RELOCATING+ _tinydata = .; }
   }"
 TINY_BSS_SECTION=".tinybss	: AT (_tinydata)
   {
diff -uNr binutils-2.17.orig/ld/ldcref.c binutils-2.17/ld/ldcref.c
--- binutils-2.17.orig/ld/ldcref.c	2006-03-16 13:20:16.000000000 +0100
+++ binutils-2.17/ld/ldcref.c	2006-10-21 13:53:24.000000000 +0200
@@ -27,6 +27,7 @@
 #include "sysdep.h"
 #include "bfdlink.h"
 #include "libiberty.h"
+#include "objalloc.h"
 
 #include "ld.h"
 #include "ldmain.h"
@@ -101,6 +102,15 @@
 
 static size_t cref_symcount;
 
+/* Used to take a snapshot of the cref hash table when starting to
+   add syms from an as-needed library.  */
+static struct bfd_hash_entry **old_table;
+static unsigned int old_size;
+static void *old_tab;
+static void *alloc_mark;
+static size_t tabsize, entsize, refsize;
+static size_t old_symcount;
+
 /* Create an entry in a cref hash table.  */
 
 static struct bfd_hash_entry *
@@ -165,7 +175,9 @@
 
   if (r == NULL)
     {
-      r = xmalloc (sizeof *r);
+      r = bfd_hash_allocate (&cref_table.root, sizeof *r);
+      if (r == NULL)
+	einfo (_("%X%P: cref alloc failed: %E\n"));
       r->next = h->refs;
       h->refs = r;
       r->abfd = abfd;
@@ -182,6 +194,123 @@
     r->def = TRUE;
 }
 
+/* Called before loading an as-needed library to take a snapshot of
+   the cref hash table, and after we have loaded or found that the
+   library was not needed.  */
+
+bfd_boolean
+handle_asneeded_cref (bfd *abfd ATTRIBUTE_UNUSED,
+		      enum notice_asneeded_action act)
+{
+  unsigned int i;
+
+  if (!cref_initialized)
+    return TRUE;
+
+  if (act == notice_as_needed)
+    {
+      char *old_ent, *old_ref;
+
+      for (i = 0; i < cref_table.root.size; i++)
+	{
+	  struct bfd_hash_entry *p;
+	  struct cref_hash_entry *c;
+	  struct cref_ref *r;
+
+	  for (p = cref_table.root.table[i]; p != NULL; p = p->next)
+	    {
+	      entsize += cref_table.root.entsize;
+	      c = (struct cref_hash_entry *) p;
+	      for (r = c->refs; r != NULL; r = r->next)
+		refsize += sizeof (struct cref_hash_entry);
+	    }
+	}
+
+      tabsize = cref_table.root.size * sizeof (struct bfd_hash_entry *);
+      old_tab = xmalloc (tabsize + entsize + refsize);
+
+      alloc_mark = bfd_hash_allocate (&cref_table.root, 1);
+      if (alloc_mark == NULL)
+	return FALSE;
+
+      memcpy (old_tab, cref_table.root.table, tabsize);
+      old_ent = (char *) old_tab + tabsize;
+      old_ref = (char *) old_ent + entsize;
+      old_table = cref_table.root.table;
+      old_size = cref_table.root.size;
+      old_symcount = cref_symcount;
+
+      for (i = 0; i < cref_table.root.size; i++)
+	{
+	  struct bfd_hash_entry *p;
+	  struct cref_hash_entry *c;
+	  struct cref_ref *r;
+
+	  for (p = cref_table.root.table[i]; p != NULL; p = p->next)
+	    {
+	      memcpy (old_ent, p, cref_table.root.entsize);
+	      old_ent = (char *) old_ent + cref_table.root.entsize;
+	      c = (struct cref_hash_entry *) p;
+	      for (r = c->refs; r != NULL; r = r->next)
+		{
+		  memcpy (old_ref, r, sizeof (struct cref_hash_entry));
+		  old_ref = (char *) old_ref + sizeof (struct cref_hash_entry);
+		}
+	    }
+	}
+      return TRUE;
+    }
+
+  if (act == notice_not_needed)
+    {
+      char *old_ent, *old_ref;
+
+      if (old_tab == NULL)
+	{
+	  /* The only way old_tab can be NULL is if the cref hash table
+	     had not been initialised when notice_as_needed.  */
+	  bfd_hash_table_free (&cref_table.root);
+	  cref_initialized = FALSE;
+	  return TRUE;
+	}
+
+      old_ent = (char *) old_tab + tabsize;
+      old_ref = (char *) old_ent + entsize;
+      cref_table.root.table = old_table;
+      cref_table.root.size = old_size;
+      memcpy (cref_table.root.table, old_tab, tabsize);
+      cref_symcount = old_symcount;
+
+      for (i = 0; i < cref_table.root.size; i++)
+	{
+	  struct bfd_hash_entry *p;
+	  struct cref_hash_entry *c;
+	  struct cref_ref *r;
+
+	  for (p = cref_table.root.table[i]; p != NULL; p = p->next)
+	    {
+	      memcpy (p, old_ent, cref_table.root.entsize);
+	      old_ent = (char *) old_ent + cref_table.root.entsize;
+	      c = (struct cref_hash_entry *) p;
+	      for (r = c->refs; r != NULL; r = r->next)
+		{
+		  memcpy (r, old_ref, sizeof (struct cref_hash_entry));
+		  old_ref = (char *) old_ref + sizeof (struct cref_hash_entry);
+		}
+	    }
+	}
+
+      objalloc_free_block ((struct objalloc *) cref_table.root.memory,
+			   alloc_mark);
+    }
+  else if (act != notice_needed)
+    return FALSE;
+
+  free (old_tab);
+  old_tab = NULL;
+  return TRUE;
+}
+
 /* Copy the addresses of the hash table entries into an array.  This
    is called via cref_hash_traverse.  We also fill in the demangled
    name.  */
diff -uNr binutils-2.17.orig/ld/ld.h binutils-2.17/ld/ld.h
--- binutils-2.17.orig/ld/ld.h	2005-09-30 13:42:04.000000000 +0200
+++ binutils-2.17/ld/ld.h	2006-10-21 13:53:24.000000000 +0200
@@ -1,6 +1,6 @@
 /* ld.h -- general linker header file
    Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005
+   2001, 2002, 2003, 2004, 2005, 2006
    Free Software Foundation, Inc.
 
    This file is part of GLD, the Gnu Linker.
@@ -282,6 +282,7 @@
 
 extern int yyparse (void);
 extern void add_cref (const char *, bfd *, asection *, bfd_vma);
+extern bfd_boolean handle_asneeded_cref (bfd *, enum notice_asneeded_action);
 extern void output_cref (FILE *);
 extern void check_nocrossrefs (void);
 extern void ld_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
diff -uNr binutils-2.17.orig/ld/ldlang.c binutils-2.17/ld/ldlang.c
--- binutils-2.17.orig/ld/ldlang.c	2006-06-12 15:05:04.000000000 +0200
+++ binutils-2.17/ld/ldlang.c	2006-10-21 13:53:24.000000000 +0200
@@ -4207,7 +4207,8 @@
 		    /* If a loadable section is using the default memory
 		       region, and some non default memory regions were
 		       defined, issue an error message.  */
-		    if (!IGNORE_SECTION (os->bfd_section)
+		    if (!os->ignored
+			&& !IGNORE_SECTION (os->bfd_section)
 			&& ! link_info.relocatable
 			&& check_regions
 			&& strcmp (os->region->name,
diff -uNr binutils-2.17.orig/ld/ldmain.c binutils-2.17/ld/ldmain.c
--- binutils-2.17.orig/ld/ldmain.c	2006-04-06 20:52:45.000000000 +0200
+++ binutils-2.17/ld/ldmain.c	2006-10-21 13:53:24.000000000 +0200
@@ -1511,6 +1511,13 @@
 	asection *section,
 	bfd_vma value)
 {
+  if (name == NULL)
+    {
+      if (command_line.cref || nocrossref_list != NULL)
+	return handle_asneeded_cref (abfd, value);
+      return TRUE;
+    }
+
   if (! info->notice_all
       || (info->notice_hash != NULL
 	  && bfd_hash_lookup (info->notice_hash, name, FALSE, FALSE) != NULL))
diff -uNr binutils-2.17.orig/ld/testsuite/ChangeLog binutils-2.17/ld/testsuite/ChangeLog
--- binutils-2.17.orig/ld/testsuite/ChangeLog	2006-06-12 15:44:33.000000000 +0200
+++ binutils-2.17/ld/testsuite/ChangeLog	2006-10-21 13:53:24.000000000 +0200
@@ -1,3 +1,17 @@
+2006-07-12  Richard Sandiford  <richard@codesourcery.com>
+
+	* ld-m68k/merge-ok-1c.d: New test.
+	* ld-m68k/m68k.exp: Run it.
+
+2006-07-04  Daniel Jacobowitz  <dan@codesourcery.com>
+
+	Backport:
+	2006-05-19  Alan Modra  <amodra@bigpond.net.au>
+	* ld-scripts/empty-orphan.d: Update again.
+
+	* ld-scripts/empty-orphan.t: Discard .reginfo.
+	* ld-scripts/empty-orphan.d: Update.
+
 2006-06-12  Daniel Jacobowitz  <dan@codesourcery.com>
 
 	Backport:
diff -uNr binutils-2.17.orig/ld/testsuite/ld-m68k/m68k.exp binutils-2.17/ld/testsuite/ld-m68k/m68k.exp
--- binutils-2.17.orig/ld/testsuite/ld-m68k/m68k.exp	2006-03-25 11:24:27.000000000 +0100
+++ binutils-2.17/ld/testsuite/ld-m68k/m68k.exp	2006-10-21 13:53:24.000000000 +0200
@@ -53,3 +53,4 @@
 run_dump_test "merge-error-1e"
 run_dump_test "merge-ok-1a"
 run_dump_test "merge-ok-1b"
+run_dump_test "merge-ok-1c"
diff -uNr binutils-2.17.orig/ld/testsuite/ld-scripts/empty-orphan.d binutils-2.17/ld/testsuite/ld-scripts/empty-orphan.d
--- binutils-2.17.orig/ld/testsuite/ld-scripts/empty-orphan.d	2005-03-17 17:20:39.000000000 +0100
+++ binutils-2.17/ld/testsuite/ld-scripts/empty-orphan.d	2006-10-21 13:53:24.000000000 +0200
@@ -1,3 +1,6 @@
 #source: empty-orphan.s
 #ld: -T empty-orphan.t
-#error: no memory region specified for loadable section
+#readelf: -l --wide
+#...
+ +LOAD +[x0-9a-f]+ [x0]+70000000 [x0]+70000000 [x0]+(2|4|8|10|20|40|80) .*
+#pass
diff -uNr binutils-2.17.orig/ld/testsuite/ld-scripts/empty-orphan.t binutils-2.17/ld/testsuite/ld-scripts/empty-orphan.t
--- binutils-2.17.orig/ld/testsuite/ld-scripts/empty-orphan.t	2005-03-17 17:20:39.000000000 +0100
+++ binutils-2.17/ld/testsuite/ld-scripts/empty-orphan.t	2006-10-21 13:53:24.000000000 +0200
@@ -17,5 +17,6 @@
    .text : { *(.text) } > text_mem : text_phdr
    .data : { *(.data) } > data_mem : data_phdr
    .bss : { *(.bss) } > data_mem : data_phdr
+   /DISCARD/ : { *(.reginfo) }
    /* .orphan_data is an orphan */
 }