?? section.c
字號:
.. {* If an input section, a pointer to a vector of relocation. records for the data in this section. *}.. struct reloc_cache_entry *relocation;.. {* If an output section, a pointer to a vector of pointers to. relocation records for the data in this section. *}.. struct reloc_cache_entry **orelocation;.. {* The number of relocation records in one of the above *}.. unsigned reloc_count;.. {* Information below is back end specific - and not always used. or updated. *}.. {* File position of section data. *}.. file_ptr filepos;.. {* File position of relocation info. *}.. file_ptr rel_filepos;.. {* File position of line data. *}.. file_ptr line_filepos;.. {* Pointer to data for applications. *}.. PTR userdata;.. {* If the SEC_IN_MEMORY flag is set, this points to the actual. contents. *}. unsigned char *contents;.. {* Attached line number information. *}.. alent *lineno;.. {* Number of line number records. *}.. unsigned int lineno_count;.. {* Optional information about a COMDAT entry; NULL if not COMDAT. *}.. struct bfd_comdat_info *comdat;.. {* Points to the kept section if this section is a link-once section,. and is discarded. *}. struct sec *kept_section;.. {* When a section is being output, this value changes as more. linenumbers are written out. *}.. file_ptr moving_line_filepos;.. {* What the section number is in the target world. *}.. int target_index;.. PTR used_by_bfd;.. {* If this is a constructor section then here is a list of the. relocations created to relocate items within it. *}.. struct relent_chain *constructor_chain;.. {* The BFD which owns the section. *}.. bfd *owner;.. {* A symbol which points at this section only *}. struct symbol_cache_entry *symbol;. struct symbol_cache_entry **symbol_ptr_ptr;.. struct bfd_link_order *link_order_head;. struct bfd_link_order *link_order_tail;.} asection ;..{* These sections are global, and are managed by BFD. The application. and target back end are not permitted to change the values in. these sections. New code should use the section_ptr macros rather. than referring directly to the const sections. The const sections. may eventually vanish. *}.#define BFD_ABS_SECTION_NAME "*ABS*".#define BFD_UND_SECTION_NAME "*UND*".#define BFD_COM_SECTION_NAME "*COM*".#define BFD_IND_SECTION_NAME "*IND*"..{* the absolute section *}.extern const asection bfd_abs_section;.#define bfd_abs_section_ptr ((asection *) &bfd_abs_section).#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr).{* Pointer to the undefined section *}.extern const asection bfd_und_section;.#define bfd_und_section_ptr ((asection *) &bfd_und_section).#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr).{* Pointer to the common section *}.extern const asection bfd_com_section;.#define bfd_com_section_ptr ((asection *) &bfd_com_section).{* Pointer to the indirect section *}.extern const asection bfd_ind_section;.#define bfd_ind_section_ptr ((asection *) &bfd_ind_section).#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)..extern const struct symbol_cache_entry * const bfd_abs_symbol;.extern const struct symbol_cache_entry * const bfd_com_symbol;.extern const struct symbol_cache_entry * const bfd_und_symbol;.extern const struct symbol_cache_entry * const bfd_ind_symbol;.#define bfd_get_section_size_before_reloc(section) \. ((section)->reloc_done ? (abort (), (bfd_size_type) 1) \. : (section)->_raw_size).#define bfd_get_section_size_after_reloc(section) \. ((section)->reloc_done ? (section)->_cooked_size \. : (abort (), (bfd_size_type) 1))*//* We use a macro to initialize the static asymbol structures because traditional C does not permit us to initialize a union member while gcc warns if we don't initialize it. */ /* the_bfd, name, value, attr, section [, udata] */#ifdef __STDC__#define GLOBAL_SYM_INIT(NAME, SECTION) \ { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION, { 0 }}#else#define GLOBAL_SYM_INIT(NAME, SECTION) \ { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION }#endif/* These symbols are global, not specific to any BFD. Therefore, anything that tries to change them is broken, and should be repaired. */static const asymbol global_syms[] ={ GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, &bfd_com_section), GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, &bfd_und_section), GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, &bfd_abs_section), GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section)};#define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \ const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \ const asection SEC = \ /* name, id, index, next, flags, user_set_vma, reloc_done, */ \ { NAME, IDX, 0, NULL, FLAGS, 0, 0, \ \ /* linker_mark, linker_has_input, gc_mark, segment_mark, */ \ 0, 0, 1, 0, \ \ /* vma, lma, _cooked_size, _raw_size, */ \ 0, 0, 0, 0, \ \ /* output_offset, output_section, alignment_power, */ \ 0, (struct sec *) &SEC, 0, \ \ /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ NULL, NULL, 0, 0, 0, \ \ /* line_filepos, userdata, contents, lineno, lineno_count, */ \ 0, NULL, NULL, NULL, 0, \ \ /* comdat, kept_section, moving_line_filepos, target_index, */ \ NULL, NULL, 0, 0, \ \ /* used_by_bfd, constructor_chain, owner, */ \ NULL, NULL, NULL, \ \ /* symbol, */ \ (struct symbol_cache_entry *) &global_syms[IDX], \ \ /* symbol_ptr_ptr, */ \ (struct symbol_cache_entry **) &SYM, \ \ /* link_order_head, link_order_tail */ \ NULL, NULL \ }STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol, BFD_COM_SECTION_NAME, 0);STD_SECTION (bfd_und_section, 0, bfd_und_symbol, BFD_UND_SECTION_NAME, 1);STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2);STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3);#undef STD_SECTION/*DOCDDINODEsection prototypes, , typedef asection, SectionsSUBSECTION Section prototypesThese are the functions exported by the section handling part of BFD.*//*FUNCTION bfd_get_section_by_nameSYNOPSIS asection *bfd_get_section_by_name(bfd *abfd, const char *name);DESCRIPTION Run through @var{abfd} and return the one of the <<asection>>s whose name matches @var{name}, otherwise <<NULL>>. @xref{Sections}, for more information. This should only be used in special cases; the normal way to process all sections of a given name is to use <<bfd_map_over_sections>> and <<strcmp>> on the name (or better yet, base it on the section flags or something else) for each section.*/asection *bfd_get_section_by_name (abfd, name) bfd *abfd; const char *name;{ asection *sect; for (sect = abfd->sections; sect != NULL; sect = sect->next) if (!strcmp (sect->name, name)) return sect; return NULL;}/*FUNCTION bfd_get_unique_section_nameSYNOPSIS char *bfd_get_unique_section_name(bfd *abfd, const char *templat, int *count);DESCRIPTION Invent a section name that is unique in @var{abfd} by tacking a dot and a digit suffix onto the original @var{templat}. If @var{count} is non-NULL, then it specifies the first number tried as a suffix to generate a unique name. The value pointed to by @var{count} will be incremented in this case.*/char *bfd_get_unique_section_name (abfd, templat, count) bfd *abfd; const char *templat; int *count;{ int num; unsigned int len; char *sname; len = strlen (templat); sname = bfd_malloc (len + 8); if (sname == NULL) return NULL; strcpy (sname, templat); num = 1; if (count != NULL) num = *count; do { /* If we have a million sections, something is badly wrong. */ if (num > 999999) abort (); sprintf (sname + len, ".%d", num++); } while (bfd_get_section_by_name (abfd, sname) != NULL); if (count != NULL) *count = num; return sname;}/*FUNCTION bfd_make_section_old_waySYNOPSIS asection *bfd_make_section_old_way(bfd *abfd, const char *name);DESCRIPTION Create a new empty section called @var{name} and attach it to the end of the chain of sections for the BFD @var{abfd}. An attempt to create a section with a name which is already in use returns its pointer without changing the section chain. It has the funny name since this is the way it used to be before it was rewritten.... Possible errors are: o <<bfd_error_invalid_operation>> - If output has already started for this BFD. o <<bfd_error_no_memory>> - If memory allocation fails.*/asection *bfd_make_section_old_way (abfd, name) bfd *abfd; const char *name;{ asection *sec = bfd_get_section_by_name (abfd, name); if (sec == (asection *) NULL) { sec = bfd_make_section (abfd, name); } return sec;}/*FUNCTION bfd_make_section_anywaySYNOPSIS asection *bfd_make_section_anyway(bfd *abfd, const char *name);DESCRIPTION Create a new empty section called @var{name} and attach it to the end of the chain of sections for @var{abfd}. Create a new section even if there is already a section with that name. Return <<NULL>> and set <<bfd_error>> on error; possible errors are: o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}. o <<bfd_error_no_memory>> - If memory allocation fails.*/sec_ptrbfd_make_section_anyway (abfd, name) bfd *abfd; const char *name;{ static int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */ asection *newsect; asection **prev = &abfd->sections; asection *sect = abfd->sections; if (abfd->output_has_begun) { bfd_set_error (bfd_error_invalid_operation); return NULL; } while (sect) { prev = §->next; sect = sect->next; } newsect = (asection *) bfd_zalloc (abfd, sizeof (asection)); if (newsect == NULL) return NULL; newsect->name = name; newsect->id = section_id++; newsect->index = abfd->section_count++; newsect->flags = SEC_NO_FLAGS; newsect->userdata = NULL; newsect->contents = NULL; newsect->next = (asection *) NULL; newsect->relocation = (arelent *) NULL; newsect->reloc_count = 0; newsect->line_filepos = 0; newsect->owner = abfd; newsect->comdat = NULL; newsect->kept_section = NULL; /* Create a symbol whos only job is to point to this section. This is useful for things like relocs which are relative to the base of a section. */ newsect->symbol = bfd_make_empty_symbol (abfd); if (newsect->symbol == NULL) { bfd_release (abfd, newsect); return NULL; } newsect->symbol->name = name; newsect->symbol->value = 0; newsect->symbol->section = newsect; newsect->symbol->flags = BSF_SECTION_SYM; newsect->symbol_ptr_ptr = &newsect->symbol; if (BFD_SEND (abfd, _new_section_hook, (abfd, newsect)) != true) { bfd_release (abfd, newsect); return NULL; } *prev = newsect; return newsect;}/*FUNCTION bfd_make_sectionSYNOPSIS asection *bfd_make_section(bfd *, const char *name);DESCRIPTION Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling bfd_set_error ()) without changing the section chain if there is already a section named @var{name}. If there is an error, return <<NULL>> and set <<bfd_error>>.*/asection *bfd_make_section (abfd, name) bfd *abfd; const char *name;{ asection *sect = abfd->sections; if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -