OLD | NEW |
1 @section Sections | 1 @section Sections |
2 The raw data contained within a BFD is maintained through the | 2 The raw data contained within a BFD is maintained through the |
3 section abstraction. A single BFD may have any number of | 3 section abstraction. A single BFD may have any number of |
4 sections. It keeps hold of them by pointing to the first; | 4 sections. It keeps hold of them by pointing to the first; |
5 each one points to the next in the list. | 5 each one points to the next in the list. |
6 | 6 |
7 Sections are supported in BFD in @code{section.c}. | 7 Sections are supported in BFD in @code{section.c}. |
8 | 8 |
9 @menu | 9 @menu |
10 * Section Input:: | 10 * Section Input:: |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 #define COMPRESS_SECTION_DONE 1 | 332 #define COMPRESS_SECTION_DONE 1 |
333 #define DECOMPRESS_SECTION_SIZED 2 | 333 #define DECOMPRESS_SECTION_SIZED 2 |
334 | 334 |
335 /* The following flags are used by the ELF linker. */ | 335 /* The following flags are used by the ELF linker. */ |
336 | 336 |
337 /* Mark sections which have been allocated to segments. */ | 337 /* Mark sections which have been allocated to segments. */ |
338 unsigned int segment_mark : 1; | 338 unsigned int segment_mark : 1; |
339 | 339 |
340 /* Type of sec_info information. */ | 340 /* Type of sec_info information. */ |
341 unsigned int sec_info_type:3; | 341 unsigned int sec_info_type:3; |
342 #define ELF_INFO_TYPE_NONE 0 | 342 #define SEC_INFO_TYPE_NONE 0 |
343 #define ELF_INFO_TYPE_STABS 1 | 343 #define SEC_INFO_TYPE_STABS 1 |
344 #define ELF_INFO_TYPE_MERGE 2 | 344 #define SEC_INFO_TYPE_MERGE 2 |
345 #define ELF_INFO_TYPE_EH_FRAME 3 | 345 #define SEC_INFO_TYPE_EH_FRAME 3 |
346 #define ELF_INFO_TYPE_JUST_SYMS 4 | 346 #define SEC_INFO_TYPE_JUST_SYMS 4 |
347 | 347 |
348 /* Nonzero if this section uses RELA relocations, rather than REL. */ | 348 /* Nonzero if this section uses RELA relocations, rather than REL. */ |
349 unsigned int use_rela_p:1; | 349 unsigned int use_rela_p:1; |
350 | 350 |
351 /* Bits used by various backends. The generic code doesn't touch | 351 /* Bits used by various backends. The generic code doesn't touch |
352 these fields. */ | 352 these fields. */ |
353 | 353 |
354 unsigned int sec_flg0:1; | 354 unsigned int sec_flg0:1; |
355 unsigned int sec_flg1:1; | 355 unsigned int sec_flg1:1; |
356 unsigned int sec_flg2:1; | 356 unsigned int sec_flg2:1; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 | 466 |
467 void *used_by_bfd; | 467 void *used_by_bfd; |
468 | 468 |
469 /* If this is a constructor section then here is a list of the | 469 /* If this is a constructor section then here is a list of the |
470 relocations created to relocate items within it. */ | 470 relocations created to relocate items within it. */ |
471 struct relent_chain *constructor_chain; | 471 struct relent_chain *constructor_chain; |
472 | 472 |
473 /* The BFD which owns the section. */ | 473 /* The BFD which owns the section. */ |
474 bfd *owner; | 474 bfd *owner; |
475 | 475 |
476 /* INPUT_SECTION_FLAGS if specified in the linker script. */ | |
477 struct flag_info *section_flag_info; | |
478 | |
479 /* A symbol which points at this section only. */ | 476 /* A symbol which points at this section only. */ |
480 struct bfd_symbol *symbol; | 477 struct bfd_symbol *symbol; |
481 struct bfd_symbol **symbol_ptr_ptr; | 478 struct bfd_symbol **symbol_ptr_ptr; |
482 | 479 |
483 /* Early in the link process, map_head and map_tail are used to build | 480 /* Early in the link process, map_head and map_tail are used to build |
484 a list of input sections attached to an output section. Later, | 481 a list of input sections attached to an output section. Later, |
485 output sections use these fields for a list of bfd_link_order | 482 output sections use these fields for a list of bfd_link_order |
486 structs. */ | 483 structs. */ |
487 union @{ | 484 union @{ |
488 struct bfd_link_order *link_order; | 485 struct bfd_link_order *link_order; |
489 struct bfd_section *s; | 486 struct bfd_section *s; |
490 @} map_head, map_tail; | 487 @} map_head, map_tail; |
491 @} asection; | 488 @} asection; |
492 | 489 |
493 /* Relax table contains information about instructions which can | 490 /* Relax table contains information about instructions which can |
494 be removed by relaxation -- replacing a long address with a | 491 be removed by relaxation -- replacing a long address with a |
495 short address. */ | 492 short address. */ |
496 struct relax_table @{ | 493 struct relax_table @{ |
497 /* Address where bytes may be deleted. */ | 494 /* Address where bytes may be deleted. */ |
498 bfd_vma addr; | 495 bfd_vma addr; |
499 | 496 |
500 /* Number of bytes to be deleted. */ | 497 /* Number of bytes to be deleted. */ |
501 int size; | 498 int size; |
502 @}; | 499 @}; |
503 | 500 |
504 /* These sections are global, and are managed by BFD. The application | 501 /* These sections are global, and are managed by BFD. The application |
505 and target back end are not permitted to change the values in | 502 and target back end are not permitted to change the values in |
506 these sections. New code should use the section_ptr macros rather | 503 these sections. */ |
507 than referring directly to the const sections. The const sections | 504 extern asection std_section[4]; |
508 may eventually vanish. */ | 505 |
509 #define BFD_ABS_SECTION_NAME "*ABS*" | 506 #define BFD_ABS_SECTION_NAME "*ABS*" |
510 #define BFD_UND_SECTION_NAME "*UND*" | 507 #define BFD_UND_SECTION_NAME "*UND*" |
511 #define BFD_COM_SECTION_NAME "*COM*" | 508 #define BFD_COM_SECTION_NAME "*COM*" |
512 #define BFD_IND_SECTION_NAME "*IND*" | 509 #define BFD_IND_SECTION_NAME "*IND*" |
513 | 510 |
514 /* The absolute section. */ | 511 /* Pointer to the common section. */ |
515 extern asection bfd_abs_section; | 512 #define bfd_com_section_ptr (&std_section[0]) |
516 #define bfd_abs_section_ptr ((asection *) &bfd_abs_section) | 513 /* Pointer to the undefined section. */ |
| 514 #define bfd_und_section_ptr (&std_section[1]) |
| 515 /* Pointer to the absolute section. */ |
| 516 #define bfd_abs_section_ptr (&std_section[2]) |
| 517 /* Pointer to the indirect section. */ |
| 518 #define bfd_ind_section_ptr (&std_section[3]) |
| 519 |
| 520 #define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) |
517 #define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) | 521 #define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) |
518 /* Pointer to the undefined section. */ | |
519 extern asection bfd_und_section; | |
520 #define bfd_und_section_ptr ((asection *) &bfd_und_section) | |
521 #define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) | |
522 /* Pointer to the common section. */ | |
523 extern asection bfd_com_section; | |
524 #define bfd_com_section_ptr ((asection *) &bfd_com_section) | |
525 /* Pointer to the indirect section. */ | |
526 extern asection bfd_ind_section; | |
527 #define bfd_ind_section_ptr ((asection *) &bfd_ind_section) | |
528 #define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) | 522 #define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) |
529 | 523 |
530 #define bfd_is_const_section(SEC) \ | 524 #define bfd_is_const_section(SEC) \ |
531 ( ((SEC) == bfd_abs_section_ptr) \ | 525 ( ((SEC) == bfd_abs_section_ptr) \ |
532 || ((SEC) == bfd_und_section_ptr) \ | 526 || ((SEC) == bfd_und_section_ptr) \ |
533 || ((SEC) == bfd_com_section_ptr) \ | 527 || ((SEC) == bfd_com_section_ptr) \ |
534 || ((SEC) == bfd_ind_section_ptr)) | 528 || ((SEC) == bfd_ind_section_ptr)) |
535 | 529 |
536 /* Macros to handle insertion and deletion of a bfd's sections. These | 530 /* Macros to handle insertion and deletion of a bfd's sections. These |
537 only handle the list pointers, ie. do not adjust section_count, | 531 only handle the list pointers, ie. do not adjust section_count, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 \ | 626 \ |
633 /* segment_mark, sec_info_type, use_rela_p, */ \ | 627 /* segment_mark, sec_info_type, use_rela_p, */ \ |
634 0, 0, 0, \ | 628 0, 0, 0, \ |
635 \ | 629 \ |
636 /* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, */ \ | 630 /* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, */ \ |
637 0, 0, 0, 0, 0, 0, \ | 631 0, 0, 0, 0, 0, 0, \ |
638 \ | 632 \ |
639 /* vma, lma, size, rawsize, compressed_size, relax, relax_count, */ \ | 633 /* vma, lma, size, rawsize, compressed_size, relax, relax_count, */ \ |
640 0, 0, 0, 0, 0, 0, 0, \ | 634 0, 0, 0, 0, 0, 0, 0, \ |
641 \ | 635 \ |
642 /* output_offset, output_section, alignment_power, */ \ | 636 /* output_offset, output_section, alignment_power, */ \ |
643 0, (struct bfd_section *) &SEC, 0, \ | 637 0, &SEC, 0, \ |
644 \ | 638 \ |
645 /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ | 639 /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ |
646 NULL, NULL, 0, 0, 0, \ | 640 NULL, NULL, 0, 0, 0, \ |
647 \ | 641 \ |
648 /* line_filepos, userdata, contents, lineno, lineno_count, */ \ | 642 /* line_filepos, userdata, contents, lineno, lineno_count, */ \ |
649 0, NULL, NULL, NULL, 0, \ | 643 0, NULL, NULL, NULL, 0, \ |
650 \ | 644 \ |
651 /* entsize, kept_section, moving_line_filepos, */ \ | 645 /* entsize, kept_section, moving_line_filepos, */ \ |
652 0, NULL, 0, \ | 646 0, NULL, 0, \ |
653 \ | 647 \ |
654 /* target_index, used_by_bfd, constructor_chain, owner, */ \ | 648 /* target_index, used_by_bfd, constructor_chain, owner, */ \ |
655 0, NULL, NULL, NULL, \ | 649 0, NULL, NULL, NULL, \ |
656 \ | 650 \ |
657 /* flag_info, */ \ | |
658 NULL, \ | |
659 \ | |
660 /* symbol, symbol_ptr_ptr, */ \ | 651 /* symbol, symbol_ptr_ptr, */ \ |
661 (struct bfd_symbol *) SYM, &SEC.symbol, \ | 652 (struct bfd_symbol *) SYM, &SEC.symbol, \ |
662 \ | 653 \ |
663 /* map_head, map_tail */ \ | 654 /* map_head, map_tail */ \ |
664 @{ NULL @}, @{ NULL @} \ | 655 @{ NULL @}, @{ NULL @} \ |
665 @} | 656 @} |
666 | 657 |
667 @end example | 658 @end example |
668 | 659 |
669 @node section prototypes, , typedef asection, Sections | 660 @node section prototypes, , typedef asection, Sections |
(...skipping 10 matching lines...) Expand all Loading... |
680 Clears the section list, and also resets the section count and | 671 Clears the section list, and also resets the section count and |
681 hash table entries. | 672 hash table entries. |
682 | 673 |
683 @findex bfd_get_section_by_name | 674 @findex bfd_get_section_by_name |
684 @subsubsection @code{bfd_get_section_by_name} | 675 @subsubsection @code{bfd_get_section_by_name} |
685 @strong{Synopsis} | 676 @strong{Synopsis} |
686 @example | 677 @example |
687 asection *bfd_get_section_by_name (bfd *abfd, const char *name); | 678 asection *bfd_get_section_by_name (bfd *abfd, const char *name); |
688 @end example | 679 @end example |
689 @strong{Description}@* | 680 @strong{Description}@* |
690 Run through @var{abfd} and return the one of the | 681 Return the most recently created section attached to @var{abfd} |
691 @code{asection}s whose name matches @var{name}, otherwise @code{NULL}. | 682 named @var{name}. Return NULL if no such section exists. |
692 @xref{Sections}, for more information. | |
693 | 683 |
694 This should only be used in special cases; the normal way to process | 684 @findex bfd_get_next_section_by_name |
695 all sections of a given name is to use @code{bfd_map_over_sections} and | 685 @subsubsection @code{bfd_get_next_section_by_name} |
696 @code{strcmp} on the name (or better yet, base it on the section flags | 686 @strong{Synopsis} |
697 or something else) for each section. | 687 @example |
| 688 asection *bfd_get_next_section_by_name (asection *sec); |
| 689 @end example |
| 690 @strong{Description}@* |
| 691 Given @var{sec} is a section returned by @code{bfd_get_section_by_name}, |
| 692 return the next most recently created section attached to the same |
| 693 BFD with the same name. Return NULL if no such section exists. |
| 694 |
| 695 @findex bfd_get_linker_section |
| 696 @subsubsection @code{bfd_get_linker_section} |
| 697 @strong{Synopsis} |
| 698 @example |
| 699 asection *bfd_get_linker_section (bfd *abfd, const char *name); |
| 700 @end example |
| 701 @strong{Description}@* |
| 702 Return the linker created section attached to @var{abfd} |
| 703 named @var{name}. Return NULL if no such section exists. |
698 | 704 |
699 @findex bfd_get_section_by_name_if | 705 @findex bfd_get_section_by_name_if |
700 @subsubsection @code{bfd_get_section_by_name_if} | 706 @subsubsection @code{bfd_get_section_by_name_if} |
701 @strong{Synopsis} | 707 @strong{Synopsis} |
702 @example | 708 @example |
703 asection *bfd_get_section_by_name_if | 709 asection *bfd_get_section_by_name_if |
704 (bfd *abfd, | 710 (bfd *abfd, |
705 const char *name, | 711 const char *name, |
706 bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj), | 712 bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj), |
707 void *obj); | 713 void *obj); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 | 1026 |
1021 @findex bfd_generic_discard_group | 1027 @findex bfd_generic_discard_group |
1022 @subsubsection @code{bfd_generic_discard_group} | 1028 @subsubsection @code{bfd_generic_discard_group} |
1023 @strong{Synopsis} | 1029 @strong{Synopsis} |
1024 @example | 1030 @example |
1025 bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group); | 1031 bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group); |
1026 @end example | 1032 @end example |
1027 @strong{Description}@* | 1033 @strong{Description}@* |
1028 Remove all members of @var{group} from the output. | 1034 Remove all members of @var{group} from the output. |
1029 | 1035 |
OLD | NEW |