View | Details | Raw Unified | Return to bug 14052 | Differences between
and this patch

Collapse All | Expand All

(-)a/bfd/bfd-in.h (+3 lines)
Lines 703-708 _bfd_nearby_section (bfd *, struct bfd_section *, bfd_vma); Link Here
703
extern void _bfd_fix_excluded_sec_syms
703
extern void _bfd_fix_excluded_sec_syms
704
  (bfd *, struct bfd_link_info *);
704
  (bfd *, struct bfd_link_info *);
705
705
706
extern void _bfd_keep_sections_with_sym
707
  (bfd *, struct bfd_link_info *);
708
706
extern unsigned bfd_m68k_mach_to_features (int);
709
extern unsigned bfd_m68k_mach_to_features (int);
707
710
708
extern int bfd_m68k_features_to_mach (unsigned);
711
extern int bfd_m68k_features_to_mach (unsigned);
(-)a/bfd/bfd-in2.h (+3 lines)
Lines 710-715 _bfd_nearby_section (bfd *, struct bfd_section *, bfd_vma); Link Here
710
extern void _bfd_fix_excluded_sec_syms
710
extern void _bfd_fix_excluded_sec_syms
711
  (bfd *, struct bfd_link_info *);
711
  (bfd *, struct bfd_link_info *);
712
712
713
extern void _bfd_keep_sections_with_sym
714
  (bfd *, struct bfd_link_info *);
715
713
extern unsigned bfd_m68k_mach_to_features (int);
716
extern unsigned bfd_m68k_mach_to_features (int);
714
717
715
extern int bfd_m68k_features_to_mach (unsigned);
718
extern int bfd_m68k_features_to_mach (unsigned);
(-)a/bfd/linker.c (-5 / +30 lines)
Lines 3198-3208 _bfd_nearby_section (bfd *obfd, asection *s, bfd_vma addr) Link Here
3198
	best = prev;
3198
	best = prev;
3199
    }
3199
    }
3200
3200
3201
  /* Refuse to choose a section for which we are out of bounds.  */
3202
  /* ??? This may make most of the above moot.  */
3203
  if (addr < best->vma || addr > best->vma + best->size)
3204
    best = bfd_abs_section_ptr;
3205
3206
  return best;
3201
  return best;
3207
}
3202
}
3208
3203
Lines 3240-3245 _bfd_fix_excluded_sec_syms (bfd *obfd, struct bfd_link_info *info) Link Here
3240
  bfd_link_hash_traverse (info->hash, fix_syms, obfd);
3235
  bfd_link_hash_traverse (info->hash, fix_syms, obfd);
3241
}
3236
}
3242
3237
3238
/* Keep sections with symbols.  */
3239
3240
static bfd_boolean
3241
keep_sections_with_sym (struct bfd_link_hash_entry *h, void *data)
3242
{
3243
  bfd *obfd = (bfd *) data;
3244
3245
  if (h->type == bfd_link_hash_defined
3246
      || h->type == bfd_link_hash_defweak)
3247
    {
3248
      asection *s = h->u.def.section;
3249
      if (s != NULL
3250
	  && (s->flags
3251
	      & (SEC_LINKER_CREATED | SEC_EXCLUDE | SEC_KEEP)) == 0
3252
	  && s->output_section != NULL
3253
	  && (s->output_section->flags
3254
	      & (SEC_LINKER_CREATED | SEC_EXCLUDE | SEC_KEEP)) == 0
3255
	  && !bfd_section_removed_from_list (obfd, s->output_section))
3256
	s->output_section->flags |= SEC_KEEP;
3257
    }
3258
3259
  return TRUE;
3260
}
3261
3262
void
3263
_bfd_keep_sections_with_sym (bfd *obfd, struct bfd_link_info *info)
3264
{
3265
  bfd_link_hash_traverse (info->hash, keep_sections_with_sym, obfd);
3266
}
3267
3243
/*
3268
/*
3244
FUNCTION
3269
FUNCTION
3245
	bfd_generic_define_common_symbol
3270
	bfd_generic_define_common_symbol
(-)a/ld/ldlang.c (+3 lines)
Lines 3858-3863 strip_excluded_output_sections (void) Link Here
3858
      lang_reset_memory_regions ();
3858
      lang_reset_memory_regions ();
3859
    }
3859
    }
3860
3860
3861
  if (!link_info.relocatable)
3862
    _bfd_keep_sections_with_sym (link_info.output_bfd, &link_info);
3863
3861
  for (os = &lang_output_section_statement.head->output_section_statement;
3864
  for (os = &lang_output_section_statement.head->output_section_statement;
3862
       os != NULL;
3865
       os != NULL;
3863
       os = os->next)
3866
       os = os->next)
(-)a/ld/testsuite/ld-elf/pr14052.d (+8 lines)
Line 0 Link Here
1
#source: start.s
2
#ld: -T pr14052.t
3
#readelf: -s
4
5
#failif
6
#...
7
 +[0-9]+: +[0-9a-f]+ +0 +(OBJECT|NOTYPE) +GLOBAL +DEFAULT +ABS _data_start
8
#...
(-)a/ld/testsuite/ld-elf/pr14052.t (+11 lines)
Line 0 Link Here
1
SECTIONS {
2
	.text : {
3
		*(.text)
4
	}
5
	. = ALIGN (0x1000);
6
	.data : {
7
		_data_start = .;
8
		*(.data)
9
	}
10
	/DISCARD/ : { *(.*) }
11
}
(-)a/ld/testsuite/ld-elf/warn2.d (-1 / +1 lines)
Lines 13-17 Link Here
13
# construct and that the symbol still appears as expected.
13
# construct and that the symbol still appears as expected.
14
14
15
#...
15
#...
16
 +[0-9]+: +[0-9a-f]+ +20 +OBJECT +GLOBAL +DEFAULT +ABS Foo
16
 +[0-9]+: +[0-9a-f]+ +20 +OBJECT +GLOBAL +DEFAULT +[1-9] Foo
17
#pass
17
#pass
(-)a/ld/testsuite/ld-elf/zerosize1.d (-3 / +5 lines)
Lines 1-10 Link Here
1
#source: start.s
1
#source: start.s
2
#source: zerosize1.s
2
#source: zerosize1.s
3
#ld:
3
#ld: -T zerosize1.t
4
#readelf: -s
4
#readelf: -sS --wide
5
5
6
# Check that xyzzy is not placed in the .text section.
6
# Check that xyzzy is not placed in the .text section.
7
7
8
#...
8
#...
9
 +[0-9]+: +[0-9a-f]+ +0 +(OBJECT|NOTYPE) +GLOBAL +DEFAULT +ABS xyzzy
9
  \[[ 2]+\] zerosize[ \t]+PROGBITS[ \t0-9a-f]+WA.*
10
#...
11
 +[0-9]+: +[0-9a-f]+ +0 +(OBJECT|NOTYPE) +GLOBAL +DEFAULT +2 xyzzy
10
#pass
12
#pass
(-)a/ld/testsuite/ld-elf/zerosize1.t (+5 lines)
Line 0 Link Here
1
SECTIONS {
2
	.text : { *(.text) }
3
	.zerosize : { *(.zerosize) }
4
	/DISCARD/ : { *(.*) }
5
}

Return to bug 14052