tizen 2.3 release
[external/binutils.git] / packaging / pr_13177.patch
1 diff --git a/bfd/elflink.c b/bfd/elflink.c
2 index 1f6c1a0..8daebe5 100644
3 --- a/bfd/elflink.c
4 +++ b/bfd/elflink.c
5 @@ -11721,10 +11721,15 @@
6  static bfd_boolean
7  elf_gc_sweep_symbol (struct elf_link_hash_entry *h, void *data)
8  {
9 -  if ((h->root.type == bfd_link_hash_defined
10 -       || h->root.type == bfd_link_hash_defweak)
11 -      && !h->root.u.def.section->gc_mark
12 -      && !(h->root.u.def.section->owner->flags & DYNAMIC))
13 +  if (((h->root.type == bfd_link_hash_defined 
14 +       || h->root.type == bfd_link_hash_defweak) 
15 +       && !h->root.u.def.section->gc_mark 
16 +       && (!(h->root.u.def.section->owner->flags & DYNAMIC) 
17 +          || (h->plt.refcount <= 0 
18 +              && h->got.refcount <= 0))) 
19 +      || (h->root.type == bfd_link_hash_undefined 
20 +         && h->plt.refcount <= 0 
21 +         && h->got.refcount <= 0)) 
22      {
23        struct elf_gc_sweep_symbol_info *inf =
24            (struct elf_gc_sweep_symbol_info *) data;
25
26 diff --git a/ld/testsuite/ld-elf/pr13177.d b/ld/testsuite/ld-elf/pr13177.d
27 new file mode 100644
28 index 0000000..b58623a
29 --- /dev/null
30 +++ b/ld/testsuite/ld-elf/pr13177.d
31 @@ -0,0 +1,11 @@
32 +#source: pr13177.s 
33 +#ld: --gc-sections -shared 
34 +#readelf: -s -D --wide 
35 +#notarget: arc-*-* d30v-*-* dlx-*-* i960-*-* or32-*-* pj*-*-* 
36 +#notarget: hppa64-*-* i370-*-* i860-*-* ia64-*-* mep-*-* mn10200-*-* 
37 +# generic linker targets don't support --gc-sections, nor do a bunch of others 
38
39 +#failif 
40 +#... 
41 +.*: 0+0 +0 +NOTYPE +GLOBAL +DEFAULT +UND bar 
42 +#... 
43 diff --git a/ld/testsuite/ld-elf/pr13177.s b/ld/testsuite/ld-elf/pr13177.s
44 new file mode 100644
45 index 0000000..acc36ab
46 --- /dev/null
47 +++ b/ld/testsuite/ld-elf/pr13177.s
48 @@ -0,0 +1,9 @@
49 +       .section .text.foo,"ax",%progbits 
50 +       .globl  foo 
51 +       .type   foo, %function 
52 +foo: 
53 +       .byte 0 
54 +       .section .text.opt_out,"ax",%progbits 
55 +       .type   opt_out, %function 
56 +opt_out: 
57 +       .dc.a bar