OLD | NEW |
1 /* ELF attributes support (based on ARM EABI attributes). | 1 /* ELF attributes support (based on ARM EABI attributes). |
2 Copyright 2005, 2006, 2007, 2009, 2010 | 2 Copyright 2005, 2006, 2007, 2009, 2010, 2012 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of BFD, the Binary File Descriptor library. | 5 This file is part of BFD, the Binary File Descriptor library. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 } | 421 } |
422 } | 422 } |
423 | 423 |
424 /* Parse an object attributes section. */ | 424 /* Parse an object attributes section. */ |
425 void | 425 void |
426 _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) | 426 _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr) |
427 { | 427 { |
428 bfd_byte *contents; | 428 bfd_byte *contents; |
429 bfd_byte *p; | 429 bfd_byte *p; |
430 bfd_vma len; | 430 bfd_vma len; |
431 const char *std_section; | 431 const char *std_sec; |
432 | 432 |
433 contents = (bfd_byte *) bfd_malloc (hdr->sh_size); | 433 contents = (bfd_byte *) bfd_malloc (hdr->sh_size); |
434 if (!contents) | 434 if (!contents) |
435 return; | 435 return; |
436 if (!bfd_get_section_contents (abfd, hdr->bfd_section, contents, 0, | 436 if (!bfd_get_section_contents (abfd, hdr->bfd_section, contents, 0, |
437 hdr->sh_size)) | 437 hdr->sh_size)) |
438 { | 438 { |
439 free (contents); | 439 free (contents); |
440 return; | 440 return; |
441 } | 441 } |
442 p = contents; | 442 p = contents; |
443 std_section = get_elf_backend_data (abfd)->obj_attrs_vendor; | 443 std_sec = get_elf_backend_data (abfd)->obj_attrs_vendor; |
444 if (*(p++) == 'A') | 444 if (*(p++) == 'A') |
445 { | 445 { |
446 len = hdr->sh_size - 1; | 446 len = hdr->sh_size - 1; |
447 while (len > 0) | 447 while (len > 0) |
448 { | 448 { |
449 int namelen; | 449 int namelen; |
450 bfd_vma section_len; | 450 bfd_vma section_len; |
451 int vendor; | 451 int vendor; |
452 | 452 |
453 section_len = bfd_get_32 (abfd, p); | 453 section_len = bfd_get_32 (abfd, p); |
454 p += 4; | 454 p += 4; |
455 if (section_len > len) | 455 if (section_len > len) |
456 section_len = len; | 456 section_len = len; |
457 len -= section_len; | 457 len -= section_len; |
458 » namelen = strlen ((char *)p) + 1; | 458 » namelen = strlen ((char *) p) + 1; |
459 section_len -= namelen + 4; | 459 section_len -= namelen + 4; |
460 » if (std_section && strcmp ((char *)p, std_section) == 0) | 460 » if (std_sec && strcmp ((char *) p, std_sec) == 0) |
461 vendor = OBJ_ATTR_PROC; | 461 vendor = OBJ_ATTR_PROC; |
462 » else if (strcmp ((char *)p, "gnu") == 0) | 462 » else if (strcmp ((char *) p, "gnu") == 0) |
463 vendor = OBJ_ATTR_GNU; | 463 vendor = OBJ_ATTR_GNU; |
464 else | 464 else |
465 { | 465 { |
466 /* Other vendor section. Ignore it. */ | 466 /* Other vendor section. Ignore it. */ |
467 p += namelen + section_len; | 467 p += namelen + section_len; |
468 continue; | 468 continue; |
469 } | 469 } |
470 | 470 |
471 p += namelen; | 471 p += namelen; |
472 while (section_len > 0) | 472 while (section_len > 0) |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 } | 690 } |
691 | 691 |
692 if (err_bfd) | 692 if (err_bfd) |
693 result = result | 693 result = result |
694 && get_elf_backend_data (err_bfd)->obj_attrs_handle_unknown (err_bfd, | 694 && get_elf_backend_data (err_bfd)->obj_attrs_handle_unknown (err_bfd, |
695 err_tag); | 695 err_tag); |
696 } | 696 } |
697 | 697 |
698 return result; | 698 return result; |
699 } | 699 } |
OLD | NEW |