Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: bfd/elf-strtab.c

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bfd/elf-nacl.c ('k') | bfd/elf-vxworks.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* ELF strtab with GC and suffix merging support. 1 /* ELF strtab with GC and suffix merging support.
2 Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008 2 Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Written by Jakub Jelinek <jakub@redhat.com>. 4 Written by Jakub Jelinek <jakub@redhat.com>.
5 5
6 This file is part of BFD, the Binary File Descriptor library. 6 This file is part of BFD, the Binary File Descriptor library.
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or 10 the Free Software Foundation; either version 3 of the License, or
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 _bfd_elf_strtab_delref (struct elf_strtab_hash *tab, bfd_size_type idx) 194 _bfd_elf_strtab_delref (struct elf_strtab_hash *tab, bfd_size_type idx)
195 { 195 {
196 if (idx == 0 || idx == (bfd_size_type) -1) 196 if (idx == 0 || idx == (bfd_size_type) -1)
197 return; 197 return;
198 BFD_ASSERT (tab->sec_size == 0); 198 BFD_ASSERT (tab->sec_size == 0);
199 BFD_ASSERT (idx < tab->size); 199 BFD_ASSERT (idx < tab->size);
200 BFD_ASSERT (tab->array[idx]->refcount > 0); 200 BFD_ASSERT (tab->array[idx]->refcount > 0);
201 --tab->array[idx]->refcount; 201 --tab->array[idx]->refcount;
202 } 202 }
203 203
204 unsigned int
205 _bfd_elf_strtab_refcount (struct elf_strtab_hash *tab, bfd_size_type idx)
206 {
207 return tab->array[idx]->refcount;
208 }
209
204 void 210 void
205 _bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *tab) 211 _bfd_elf_strtab_clear_all_refs (struct elf_strtab_hash *tab)
206 { 212 {
207 bfd_size_type idx; 213 bfd_size_type idx;
208 214
209 for (idx = 1; idx < tab->size; ++idx) 215 for (idx = 1; idx < tab->size; idx++)
210 tab->array[idx]->refcount = 0; 216 tab->array[idx]->refcount = 0;
211 } 217 }
212 218
219 /* Downsizes strtab. Entries from IDX up to the current size are
220 removed from the array. */
221 void
222 _bfd_elf_strtab_restore_size (struct elf_strtab_hash *tab, bfd_size_type idx)
223 {
224 bfd_size_type curr_size = tab->size;
225
226 BFD_ASSERT (tab->sec_size == 0);
227 BFD_ASSERT (idx <= curr_size);
228 tab->size = idx;
229 for (; idx < curr_size; ++idx)
230 {
231 /* We don't remove entries from the hash table, just set their
232 REFCOUNT to zero. Setting LEN zero will result in the size
233 growing if the entry is added again. See _bfd_elf_strtab_add. */
234 tab->array[idx]->refcount = 0;
235 tab->array[idx]->len = 0;
236 }
237 }
238
213 bfd_size_type 239 bfd_size_type
214 _bfd_elf_strtab_size (struct elf_strtab_hash *tab) 240 _bfd_elf_strtab_size (struct elf_strtab_hash *tab)
215 { 241 {
216 return tab->sec_size ? tab->sec_size : tab->size; 242 return tab->sec_size ? tab->sec_size : tab->size;
217 } 243 }
218 244
219 bfd_size_type 245 bfd_size_type
220 _bfd_elf_strtab_offset (struct elf_strtab_hash *tab, bfd_size_type idx) 246 _bfd_elf_strtab_offset (struct elf_strtab_hash *tab, bfd_size_type idx)
221 { 247 {
222 struct elf_strtab_hash_entry *entry; 248 struct elf_strtab_hash_entry *entry;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 tab->sec_size = size; 412 tab->sec_size = size;
387 413
388 /* Adjust the rest. */ 414 /* Adjust the rest. */
389 for (i = 1; i < tab->size; ++i) 415 for (i = 1; i < tab->size; ++i)
390 { 416 {
391 e = tab->array[i]; 417 e = tab->array[i];
392 if (e->refcount && e->len < 0) 418 if (e->refcount && e->len < 0)
393 e->u.index = e->u.suffix->u.index + (e->u.suffix->len + e->len); 419 e->u.index = e->u.suffix->u.index + (e->u.suffix->len + e->len);
394 } 420 }
395 } 421 }
OLDNEW
« no previous file with comments | « bfd/elf-nacl.c ('k') | bfd/elf-vxworks.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698