Rev 5197 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5197 | Rev 6324 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* Object file "section" support for the BFD library. |
1 | /* Object file "section" support for the BFD library. |
2 | Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
- | |
3 | 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, |
- | |
4 | 2012, 2013 |
- | |
5 | Free Software Foundation, Inc. |
2 | Copyright (C) 1990-2015 Free Software Foundation, Inc. |
6 | Written by Cygnus Support. |
3 | Written by Cygnus Support. |
Line 7... | Line 4... | ||
7 | 4 | ||
Line 8... | Line 5... | ||
8 | This file is part of BFD, the Binary File Descriptor library. |
5 | This file is part of BFD, the Binary File Descriptor library. |
Line 156... | Line 153... | ||
156 | . {* The name of the section; the name isn't a copy, the pointer is |
153 | . {* The name of the section; the name isn't a copy, the pointer is |
157 | . the same as that passed to bfd_make_section. *} |
154 | . the same as that passed to bfd_make_section. *} |
158 | . const char *name; |
155 | . const char *name; |
159 | . |
156 | . |
160 | . {* A unique sequence number. *} |
157 | . {* A unique sequence number. *} |
161 | . int id; |
158 | . unsigned int id; |
162 | . |
159 | . |
163 | . {* Which section in the bfd; 0..n-1 as sections are created in a bfd. *} |
160 | . {* Which section in the bfd; 0..n-1 as sections are created in a bfd. *} |
164 | . int index; |
161 | . unsigned int index; |
165 | . |
162 | . |
166 | . {* The next section in the list belonging to the BFD, or NULL. *} |
163 | . {* The next section in the list belonging to the BFD, or NULL. *} |
167 | . struct bfd_section *next; |
164 | . struct bfd_section *next; |
168 | . |
165 | . |
169 | . {* The previous section in the list belonging to the BFD, or NULL. *} |
166 | . {* The previous section in the list belonging to the BFD, or NULL. *} |
Line 335... | Line 332... | ||
335 | . |
332 | . |
336 | . {* This section contains data which may be shared with other |
333 | . {* This section contains data which may be shared with other |
337 | . executables or shared objects. This is for COFF only. *} |
334 | . executables or shared objects. This is for COFF only. *} |
338 | .#define SEC_COFF_SHARED 0x8000000 |
335 | .#define SEC_COFF_SHARED 0x8000000 |
339 | . |
336 | . |
- | 337 | . {* This section should be compressed. This is for ELF linker |
|
- | 338 | . internal use only. *} |
|
- | 339 | .#define SEC_ELF_COMPRESS 0x8000000 |
|
- | 340 | . |
|
340 | . {* When a section with this flag is being linked, then if the size of |
341 | . {* When a section with this flag is being linked, then if the size of |
341 | . the input section is less than a page, it should not cross a page |
342 | . the input section is less than a page, it should not cross a page |
342 | . boundary. If the size of the input section is one page or more, |
343 | . boundary. If the size of the input section is one page or more, |
343 | . it should be aligned on a page boundary. This is for TI |
344 | . it should be aligned on a page boundary. This is for TI |
344 | . TMS320C54X only. *} |
345 | . TMS320C54X only. *} |
345 | .#define SEC_TIC54X_BLOCK 0x10000000 |
346 | .#define SEC_TIC54X_BLOCK 0x10000000 |
346 | . |
347 | . |
- | 348 | . {* This section should be renamed. This is for ELF linker |
|
- | 349 | . internal use only. *} |
|
- | 350 | .#define SEC_ELF_RENAME 0x10000000 |
|
- | 351 | . |
|
347 | . {* Conditionally link this section; do not link if there are no |
352 | . {* Conditionally link this section; do not link if there are no |
348 | . references found to any symbol in the section. This is for TI |
353 | . references found to any symbol in the section. This is for TI |
349 | . TMS320C54X only. *} |
354 | . TMS320C54X only. *} |
350 | .#define SEC_TIC54X_CLINK 0x20000000 |
355 | .#define SEC_TIC54X_CLINK 0x20000000 |
351 | . |
356 | . |
- | 357 | . {* This section contains vliw code. This is for Toshiba MeP only. *} |
|
- | 358 | .#define SEC_MEP_VLIW 0x20000000 |
|
- | 359 | . |
|
352 | . {* Indicate that section has the no read flag set. This happens |
360 | . {* Indicate that section has the no read flag set. This happens |
353 | . when memory read flag isn't set. *} |
361 | . when memory read flag isn't set. *} |
354 | .#define SEC_COFF_NOREAD 0x40000000 |
362 | .#define SEC_COFF_NOREAD 0x40000000 |
355 | . |
363 | . |
356 | . {* End of section flags. *} |
364 | . {* End of section flags. *} |
Line 386... | Line 394... | ||
386 | .#define SEC_INFO_TYPE_NONE 0 |
394 | .#define SEC_INFO_TYPE_NONE 0 |
387 | .#define SEC_INFO_TYPE_STABS 1 |
395 | .#define SEC_INFO_TYPE_STABS 1 |
388 | .#define SEC_INFO_TYPE_MERGE 2 |
396 | .#define SEC_INFO_TYPE_MERGE 2 |
389 | .#define SEC_INFO_TYPE_EH_FRAME 3 |
397 | .#define SEC_INFO_TYPE_EH_FRAME 3 |
390 | .#define SEC_INFO_TYPE_JUST_SYMS 4 |
398 | .#define SEC_INFO_TYPE_JUST_SYMS 4 |
- | 399 | .#define SEC_INFO_TYPE_TARGET 5 |
|
- | 400 | .#define SEC_INFO_TYPE_EH_FRAME_ENTRY 6 |
|
391 | . |
401 | . |
392 | . {* Nonzero if this section uses RELA relocations, rather than REL. *} |
402 | . {* Nonzero if this section uses RELA relocations, rather than REL. *} |
393 | . unsigned int use_rela_p:1; |
403 | . unsigned int use_rela_p:1; |
394 | . |
404 | . |
395 | . {* Bits used by various backends. The generic code doesn't touch |
405 | . {* Bits used by various backends. The generic code doesn't touch |
Line 540... | Line 550... | ||
540 | . |
550 | . |
541 | . {* Number of bytes to be deleted. *} |
551 | . {* Number of bytes to be deleted. *} |
542 | . int size; |
552 | . int size; |
543 | .}; |
553 | .}; |
544 | . |
554 | . |
- | 555 | .{* Note: the following are provided as inline functions rather than macros |
|
- | 556 | . because not all callers use the return value. A macro implementation |
|
- | 557 | . would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some |
|
- | 558 | . compilers will complain about comma expressions that have no effect. *} |
|
- | 559 | .static inline bfd_boolean |
|
- | 560 | .bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val) |
|
- | 561 | .{ |
|
- | 562 | . ptr->userdata = val; |
|
- | 563 | . return TRUE; |
|
- | 564 | .} |
|
- | 565 | . |
|
- | 566 | .static inline bfd_boolean |
|
- | 567 | .bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val) |
|
- | 568 | .{ |
|
- | 569 | . ptr->vma = ptr->lma = val; |
|
- | 570 | . ptr->user_set_vma = TRUE; |
|
- | 571 | . return TRUE; |
|
- | 572 | .} |
|
- | 573 | . |
|
- | 574 | .static inline bfd_boolean |
|
- | 575 | .bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val) |
|
- | 576 | .{ |
|
- | 577 | . ptr->alignment_power = val; |
|
- | 578 | . return TRUE; |
|
- | 579 | .} |
|
- | 580 | . |
|
545 | .{* These sections are global, and are managed by BFD. The application |
581 | .{* These sections are global, and are managed by BFD. The application |
546 | . and target back end are not permitted to change the values in |
582 | . and target back end are not permitted to change the values in |
547 | . these sections. *} |
583 | . these sections. *} |
548 | .extern asection _bfd_std_section[4]; |
584 | .extern asection _bfd_std_section[4]; |
549 | . |
585 | . |
Line 783... | Line 819... | ||
783 | 819 | ||
784 | newsect->symbol_ptr_ptr = &newsect->symbol; |
820 | newsect->symbol_ptr_ptr = &newsect->symbol; |
785 | return TRUE; |
821 | return TRUE; |
Line -... | Line 822... | ||
- | 822 | } |
|
- | 823 | ||
786 | } |
824 | static unsigned int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */ |
Line 787... | Line 825... | ||
787 | 825 | ||
788 | /* Initializes a new section. NEWSECT->NAME is already set. */ |
826 | /* Initializes a new section. NEWSECT->NAME is already set. */ |
789 | 827 | ||
790 | static asection * |
- | |
791 | bfd_section_init (bfd *abfd, asection *newsect) |
- | |
792 | { |
828 | static asection * |
793 | static int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */ |
829 | bfd_section_init (bfd *abfd, asection *newsect) |
794 | 830 | { |
|
Line 795... | Line 831... | ||
795 | newsect->id = section_id; |
831 | newsect->id = section_id; |
Line 865... | Line 901... | ||
865 | /* |
901 | /* |
866 | FUNCTION |
902 | FUNCTION |
867 | bfd_get_next_section_by_name |
903 | bfd_get_next_section_by_name |
Line 868... | Line 904... | ||
868 | 904 | ||
869 | SYNOPSIS |
905 | SYNOPSIS |
Line 870... | Line 906... | ||
870 | asection *bfd_get_next_section_by_name (asection *sec); |
906 | asection *bfd_get_next_section_by_name (bfd *ibfd, asection *sec); |
871 | 907 | ||
872 | DESCRIPTION |
908 | DESCRIPTION |
873 | Given @var{sec} is a section returned by @code{bfd_get_section_by_name}, |
909 | Given @var{sec} is a section returned by @code{bfd_get_section_by_name}, |
- | 910 | return the next most recently created section attached to the same |
|
- | 911 | BFD with the same name, or if no such section exists in the same BFD and |
|
874 | return the next most recently created section attached to the same |
912 | IBFD is non-NULL, the next section with the same name in any input |
Line 875... | Line 913... | ||
875 | BFD with the same name. Return NULL if no such section exists. |
913 | BFD following IBFD. Return NULL on finding no section. |
876 | */ |
914 | */ |
877 | 915 | ||
878 | asection * |
916 | asection * |
879 | bfd_get_next_section_by_name (asection *sec) |
917 | bfd_get_next_section_by_name (bfd *ibfd, asection *sec) |
880 | { |
918 | { |
Line 892... | Line 930... | ||
892 | sh = (struct section_hash_entry *) sh->root.next) |
930 | sh = (struct section_hash_entry *) sh->root.next) |
893 | if (sh->root.hash == hash |
931 | if (sh->root.hash == hash |
894 | && strcmp (sh->root.string, name) == 0) |
932 | && strcmp (sh->root.string, name) == 0) |
895 | return &sh->section; |
933 | return &sh->section; |
Line -... | Line 934... | ||
- | 934 | ||
- | 935 | if (ibfd != NULL) |
|
- | 936 | { |
|
- | 937 | while ((ibfd = ibfd->link.next) != NULL) |
|
- | 938 | { |
|
- | 939 | asection *s = bfd_get_section_by_name (ibfd, name); |
|
- | 940 | if (s != NULL) |
|
- | 941 | return s; |
|
- | 942 | } |
|
- | 943 | } |
|
896 | 944 | ||
897 | return NULL; |
945 | return NULL; |
Line 898... | Line 946... | ||
898 | } |
946 | } |
899 | 947 | ||
Line 913... | Line 961... | ||
913 | bfd_get_linker_section (bfd *abfd, const char *name) |
961 | bfd_get_linker_section (bfd *abfd, const char *name) |
914 | { |
962 | { |
915 | asection *sec = bfd_get_section_by_name (abfd, name); |
963 | asection *sec = bfd_get_section_by_name (abfd, name); |
Line 916... | Line 964... | ||
916 | 964 | ||
917 | while (sec != NULL && (sec->flags & SEC_LINKER_CREATED) == 0) |
965 | while (sec != NULL && (sec->flags & SEC_LINKER_CREATED) == 0) |
918 | sec = bfd_get_next_section_by_name (sec); |
966 | sec = bfd_get_next_section_by_name (NULL, sec); |
919 | return sec; |
967 | return sec; |
Line 920... | Line 968... | ||
920 | } |
968 | } |
921 | 969 | ||
Line 956... | Line 1004... | ||
956 | sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE); |
1004 | sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE); |
957 | if (sh == NULL) |
1005 | if (sh == NULL) |
958 | return NULL; |
1006 | return NULL; |
Line 959... | Line 1007... | ||
959 | 1007 | ||
- | 1008 | hash = sh->root.hash; |
|
960 | hash = sh->root.hash; |
1009 | for (; sh != NULL; sh = (struct section_hash_entry *) sh->root.next) |
961 | do |
1010 | if (sh->root.hash == hash |
962 | { |
1011 | && strcmp (sh->root.string, name) == 0 |
963 | if ((*operation) (abfd, &sh->section, user_storage)) |
1012 | && (*operation) (abfd, &sh->section, user_storage)) |
964 | return &sh->section; |
- | |
965 | sh = (struct section_hash_entry *) sh->root.next; |
- | |
966 | } |
- | |
967 | while (sh != NULL && sh->root.hash == hash |
- | |
Line 968... | Line 1013... | ||
968 | && strcmp (sh->root.string, name) == 0); |
1013 | return &sh->section; |
969 | 1014 | ||
Line 970... | Line 1015... | ||
970 | return NULL; |
1015 | return NULL; |
Line 1240... | Line 1285... | ||
1240 | return bfd_make_section_with_flags (abfd, name, 0); |
1285 | return bfd_make_section_with_flags (abfd, name, 0); |
1241 | } |
1286 | } |
Line 1242... | Line 1287... | ||
1242 | 1287 | ||
1243 | /* |
1288 | /* |
- | 1289 | FUNCTION |
|
- | 1290 | bfd_get_next_section_id |
|
- | 1291 | ||
- | 1292 | SYNOPSIS |
|
- | 1293 | int bfd_get_next_section_id (void); |
|
- | 1294 | ||
- | 1295 | DESCRIPTION |
|
- | 1296 | Returns the id that the next section created will have. |
|
- | 1297 | */ |
|
- | 1298 | ||
- | 1299 | int |
|
- | 1300 | bfd_get_next_section_id (void) |
|
- | 1301 | { |
|
- | 1302 | return section_id; |
|
- | 1303 | } |
|
- | 1304 | ||
- | 1305 | /* |
|
1244 | FUNCTION |
1306 | FUNCTION |
Line 1245... | Line 1307... | ||
1245 | bfd_set_section_flags |
1307 | bfd_set_section_flags |
1246 | 1308 | ||
1247 | SYNOPSIS |
1309 | SYNOPSIS |