]> git.pld-linux.org Git - packages/binutils.git/blob - pr-17467.patch
- x32 rebuild
[packages/binutils.git] / pr-17467.patch
1 From 5b69e3572d1ee8e8e6e1991fd07f87a96c48746d Mon Sep 17 00:00:00 2001
2 From: Alan Modra <amodra@gmail.com>
3 Date: Mon, 13 Oct 2014 15:18:21 +1030
4 Subject: [PATCH] Run eh_frame optimisation for relocatable link
5
6 The idea here is to drop .eh_frame FDEs corresponding to dropped
7 comdat group sections or linkonce sections, but not perform changes in
8 encoding.
9
10 bfd/
11         PR 17467
12         * elf-eh-frame.c (ENSURE_NO_RELOCS): Don't stop at first NONE reloc.
13         (_bfd_elf_parse_eh_frame): When relocatable output, don't set
14         flags enabling conversion of CIEs and FDEs to use relative encoding.
15         (find_merged_cie): Similarly.
16         (_bfd_elf_write_section_eh_frame): Don't edit FDEs when
17         relocatable, except for CIE pointer.
18         * elflink.c (bfd_elf_reloc_symbol_deleted_p): Return true for
19         relocs against symbols in dropped comdat group sections.
20         (bfd_elf_discard_info): Do some eh_frame optimisation when
21         relocatable.
22 ld/
23         * ldlang.c (lang_add_section): Set up map_head.s and map_tail.s when
24         relocatable.
25 ---
26  bfd/ChangeLog      |   14 ++++++++++++++
27  bfd/elf-eh-frame.c |   25 +++++++++++++++++--------
28  bfd/elflink.c      |   14 +++++++-------
29  ld/ChangeLog       |    5 +++++
30  ld/ldlang.c        |    3 +--
31  5 files changed, 44 insertions(+), 17 deletions(-)
32
33 diff --git a/bfd/ChangeLog b/bfd/ChangeLog
34 index aa2f3ef..be3ae38 100644
35 --- a/bfd/ChangeLog
36 +++ b/bfd/ChangeLog
37 @@ -1,3 +1,17 @@
38 +2014-10-13  Alan Modra  <amodra@gmail.com>
39 +
40 +       PR 17467
41 +       * elf-eh-frame.c (ENSURE_NO_RELOCS): Don't stop at first NONE reloc.
42 +       (_bfd_elf_parse_eh_frame): When relocatable output, don't set
43 +       flags enabling conversion of CIEs and FDEs to use relative encoding.
44 +       (find_merged_cie): Similarly.
45 +       (_bfd_elf_write_section_eh_frame): Don't edit FDEs when
46 +       relocatable, except for CIE pointer.
47 +       * elflink.c (bfd_elf_reloc_symbol_deleted_p): Return true for
48 +       relocs against symbols in dropped comdat group sections.
49 +       (bfd_elf_discard_info): Do some eh_frame optimisation when
50 +       relocatable.
51 +
52  2014-10-04  Alan Modra  <amodra@gmail.com>
53  
54         PR 17447
55 diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
56 index 331570a..e481f34 100644
57 --- a/bfd/elf-eh-frame.c
58 +++ b/bfd/elf-eh-frame.c
59 @@ -556,10 +556,13 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
60  
61    /* FIXME: octets_per_byte.  */
62  #define ENSURE_NO_RELOCS(buf)                          \
63 -  REQUIRE (!(cookie->rel < cookie->relend              \
64 -            && (cookie->rel->r_offset                  \
65 -                < (bfd_size_type) ((buf) - ehbuf))     \
66 -            && cookie->rel->r_info != 0))
67 +  while (cookie->rel < cookie->relend                  \
68 +        && (cookie->rel->r_offset                      \
69 +            < (bfd_size_type) ((buf) - ehbuf)))        \
70 +    {                                                  \
71 +      REQUIRE (cookie->rel->r_info == 0);              \
72 +      cookie->rel++;                                   \
73 +    }
74  
75    /* FIXME: octets_per_byte.  */
76  #define SKIP_RELOCS(buf)                               \
77 @@ -726,6 +729,7 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
78           /* For shared libraries, try to get rid of as many RELATIVE relocs
79              as possible.  */
80           if (info->shared
81 +             && !info->relocatable
82               && (get_elf_backend_data (abfd)
83                   ->elf_backend_can_make_relative_eh_frame
84                   (abfd, info, sec)))
85 @@ -763,10 +767,12 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info,
86           ENSURE_NO_RELOCS (buf);
87  
88           if (!info->relocatable)
89 -           /* Keep info for merging cies.  */
90 -           this_inf->u.cie.u.full_cie = cie;
91 -         this_inf->u.cie.per_encoding_relative
92 -           = (cie->per_encoding & 0x70) == DW_EH_PE_pcrel;
93 +           {
94 +             /* Keep info for merging cies.  */
95 +             this_inf->u.cie.u.full_cie = cie;
96 +             this_inf->u.cie.per_encoding_relative
97 +               = (cie->per_encoding & 0x70) == DW_EH_PE_pcrel;
98 +           }
99         }
100        else
101         {
102 @@ -1071,6 +1077,7 @@ find_merged_cie (bfd *abfd, struct bfd_link_info *info, asection *sec,
103  
104        if (per_binds_local
105           && info->shared
106 +         && !info->relocatable
107           && (cie->per_encoding & 0x70) == DW_EH_PE_absptr
108           && (get_elf_backend_data (abfd)
109               ->elf_backend_can_make_relative_eh_frame (abfd, info, sec)))
110 @@ -1577,6 +1584,8 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
111           value = ((ent->new_offset + sec->output_offset + 4)
112                    - (cie->new_offset + cie->u.cie.u.sec->output_offset));
113           bfd_put_32 (abfd, value, buf);
114 +         if (info->relocatable)
115 +           continue;
116           buf += 4;
117           width = get_DW_EH_PE_width (ent->fde_encoding, ptr_size);
118           value = read_value (abfd, buf, width,
119 diff --git a/bfd/elflink.c b/bfd/elflink.c
120 index d33efe0..c8068c0 100644
121 --- a/bfd/elflink.c
122 +++ b/bfd/elflink.c
123 @@ -12602,10 +12602,10 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
124  
125           if ((h->root.type == bfd_link_hash_defined
126                || h->root.type == bfd_link_hash_defweak)
127 -             && discarded_section (h->root.u.def.section))
128 +             && (h->root.u.def.section->owner != rcookie->abfd
129 +                 || h->root.u.def.section->kept_section != NULL
130 +                 || discarded_section (h->root.u.def.section)))
131             return TRUE;
132 -         else
133 -           return FALSE;
134         }
135        else
136         {
137 @@ -12618,7 +12618,9 @@ bfd_elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie)
138           /* Need to: get the symbol; get the section.  */
139           isym = &rcookie->locsyms[r_symndx];
140           isec = bfd_section_from_elf_index (rcookie->abfd, isym->st_shndx);
141 -         if (isec != NULL && discarded_section (isec))
142 +         if (isec != NULL
143 +             && (isec->kept_section != NULL
144 +                 || discarded_section (isec)))
145             return TRUE;
146         }
147        return FALSE;
148 @@ -12672,9 +12674,7 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
149         }
150      }
151  
152 -  o = NULL;
153 -  if (!info->relocatable)
154 -    o = bfd_get_section_by_name (output_bfd, ".eh_frame");
155 +  o = bfd_get_section_by_name (output_bfd, ".eh_frame");
156    if (o != NULL)
157      {
158        asection *i;
159 diff --git a/ld/ChangeLog b/ld/ChangeLog
160 index ca27cc2..effacb0 100644
161 --- a/ld/ChangeLog
162 +++ b/ld/ChangeLog
163 @@ -1,3 +1,8 @@
164 +2014-10-13  Alan Modra  <amodra@gmail.com>
165 +
166 +       * ldlang.c (lang_add_section): Set up map_head.s and map_tail.s when
167 +       relocatable.
168 +
169  2014-09-16  Kuan-Lin Chen  <kuanlinchentw@gmail.com>
170  
171         * emultempl/nds32elf.em (nds32_elf_after_open): Do not keep
172 diff --git a/ld/ldlang.c b/ld/ldlang.c
173 index 899f710..5960e5c 100644
174 --- a/ld/ldlang.c
175 +++ b/ld/ldlang.c
176 @@ -2411,8 +2411,7 @@ lang_add_section (lang_statement_list_type *ptr,
177  
178    section->output_section = output->bfd_section;
179  
180 -  if (!link_info.relocatable
181 -      && !map_head_is_link_order)
182 +  if (!map_head_is_link_order)
183      {
184        asection *s = output->bfd_section->map_tail.s;
185        output->bfd_section->map_tail.s = section;
186 -- 
187 1.7.1
188
This page took 0.047181 seconds and 3 git commands to generate.