?? section.c
字號:
{ return bfd_abs_section_ptr; } if (strcmp (name, BFD_COM_SECTION_NAME) == 0) { return bfd_com_section_ptr; } if (strcmp (name, BFD_UND_SECTION_NAME) == 0) { return bfd_und_section_ptr; } if (strcmp (name, BFD_IND_SECTION_NAME) == 0) { return bfd_ind_section_ptr; } while (sect) { if (!strcmp (sect->name, name)) return NULL; sect = sect->next; } /* The name is not already used; go ahead and make a new section. */ return bfd_make_section_anyway (abfd, name);}/*FUNCTION bfd_set_section_flagsSYNOPSIS boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);DESCRIPTION Set the attributes of the section @var{sec} in the BFD @var{abfd} to the value @var{flags}. Return <<true>> on success, <<false>> on error. Possible error returns are: o <<bfd_error_invalid_operation>> - The section cannot have one or more of the attributes requested. For example, a .bss section in <<a.out>> may not have the <<SEC_HAS_CONTENTS>> field set.*//*ARGSUSED*/booleanbfd_set_section_flags (abfd, section, flags) bfd *abfd ATTRIBUTE_UNUSED; sec_ptr section; flagword flags;{#if 0 /* If you try to copy a text section from an input file (where it has the SEC_CODE flag set) to an output file, this loses big if the bfd_applicable_section_flags (abfd) doesn't have the SEC_CODE set - which it doesn't, at least not for a.out. FIXME */ if ((flags & bfd_applicable_section_flags (abfd)) != flags) { bfd_set_error (bfd_error_invalid_operation); return false; }#endif section->flags = flags; return true;}/*FUNCTION bfd_map_over_sectionsSYNOPSIS void bfd_map_over_sections(bfd *abfd, void (*func) (bfd *abfd, asection *sect, PTR obj), PTR obj);DESCRIPTION Call the provided function @var{func} for each section attached to the BFD @var{abfd}, passing @var{obj} as an argument. The function will be called as if by| func(abfd, the_section, obj); This is the prefered method for iterating over sections; an alternative would be to use a loop:| section *p;| for (p = abfd->sections; p != NULL; p = p->next)| func(abfd, p, ...)*//*VARARGS2*/voidbfd_map_over_sections (abfd, operation, user_storage) bfd *abfd; void (*operation) PARAMS ((bfd * abfd, asection * sect, PTR obj)); PTR user_storage;{ asection *sect; unsigned int i = 0; for (sect = abfd->sections; sect != NULL; i++, sect = sect->next) (*operation) (abfd, sect, user_storage); if (i != abfd->section_count) /* Debugging */ abort ();}/*FUNCTION bfd_set_section_sizeSYNOPSIS boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);DESCRIPTION Set @var{sec} to the size @var{val}. If the operation is ok, then <<true>> is returned, else <<false>>. Possible error returns: o <<bfd_error_invalid_operation>> - Writing has started to the BFD, so setting the size is invalid.*/booleanbfd_set_section_size (abfd, ptr, val) bfd *abfd; sec_ptr ptr; bfd_size_type val;{ /* Once you've started writing to any section you cannot create or change the size of any others. */ if (abfd->output_has_begun) { bfd_set_error (bfd_error_invalid_operation); return false; } ptr->_cooked_size = val; ptr->_raw_size = val; return true;}/*FUNCTION bfd_set_section_contentsSYNOPSIS boolean bfd_set_section_contents (bfd *abfd, asection *section, PTR data, file_ptr offset, bfd_size_type count);DESCRIPTION Sets the contents of the section @var{section} in BFD @var{abfd} to the data starting in memory at @var{data}. The data is written to the output section starting at offset @var{offset} for @var{count} octets. Normally <<true>> is returned, else <<false>>. Possible error returns are: o <<bfd_error_no_contents>> - The output section does not have the <<SEC_HAS_CONTENTS>> attribute, so nothing can be written to it. o and some more too This routine is front end to the back end function <<_bfd_set_section_contents>>.*/#define bfd_get_section_size_now(abfd,sec) \(sec->reloc_done \ ? bfd_get_section_size_after_reloc (sec) \ : bfd_get_section_size_before_reloc (sec))booleanbfd_set_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; PTR location; file_ptr offset; bfd_size_type count;{ bfd_size_type sz; if (!(bfd_get_section_flags (abfd, section) & SEC_HAS_CONTENTS)) { bfd_set_error (bfd_error_no_contents); return (false); } if (offset < 0) { bad_val: bfd_set_error (bfd_error_bad_value); return false; } sz = bfd_get_section_size_now (abfd, section); if ((bfd_size_type) offset > sz || count > sz || offset + count > sz) goto bad_val; switch (abfd->direction) { case read_direction: case no_direction: bfd_set_error (bfd_error_invalid_operation); return false; case write_direction: break; case both_direction: /* File is opened for update. `output_has_begun' some time ago when the file was created. Do not recompute sections sizes or alignments in _bfd_set_section_content. */ abfd->output_has_begun = true; break; } /* Record a copy of the data in memory if desired. */ if (section->contents && location != section->contents + offset) memcpy (section->contents + offset, location, count); if (BFD_SEND (abfd, _bfd_set_section_contents, (abfd, section, location, offset, count))) { abfd->output_has_begun = true; return true; } return false;}/*FUNCTION bfd_get_section_contentsSYNOPSIS boolean bfd_get_section_contents (bfd *abfd, asection *section, PTR location, file_ptr offset, bfd_size_type count);DESCRIPTION Read data from @var{section} in BFD @var{abfd} into memory starting at @var{location}. The data is read at an offset of @var{offset} from the start of the input section, and is read for @var{count} bytes. If the contents of a constructor with the <<SEC_CONSTRUCTOR>> flag set are requested or if the section does not have the <<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled with zeroes. If no errors occur, <<true>> is returned, else <<false>>.*/booleanbfd_get_section_contents (abfd, section, location, offset, count) bfd *abfd; sec_ptr section; PTR location; file_ptr offset; bfd_size_type count;{ bfd_size_type sz; if (section->flags & SEC_CONSTRUCTOR) { memset (location, 0, (unsigned) count); return true; } if (offset < 0) { bad_val: bfd_set_error (bfd_error_bad_value); return false; } /* Even if reloc_done is true, this function reads unrelocated contents, so we want the raw size. */ sz = section->_raw_size; if ((bfd_size_type) offset > sz || count > sz || offset + count > sz) goto bad_val; if (count == 0) /* Don't bother. */ return true; if ((section->flags & SEC_HAS_CONTENTS) == 0) { memset (location, 0, (unsigned) count); return true; } if ((section->flags & SEC_IN_MEMORY) != 0) { memcpy (location, section->contents + offset, (size_t) count); return true; } return BFD_SEND (abfd, _bfd_get_section_contents, (abfd, section, location, offset, count));}/*FUNCTION bfd_copy_private_section_dataSYNOPSIS boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);DESCRIPTION Copy private section information from @var{isec} in the BFD @var{ibfd} to the section @var{osec} in the BFD @var{obfd}. Return <<true>> on success, <<false>> on error. Possible error returns are: o <<bfd_error_no_memory>> - Not enough memory exists to create private data for @var{osec}..#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \. BFD_SEND (obfd, _bfd_copy_private_section_data, \. (ibfd, isection, obfd, osection))*//*FUNCTION _bfd_strip_section_from_outputSYNOPSIS void _bfd_strip_section_from_output (struct bfd_link_info *info, asection *section);DESCRIPTION Remove @var{section} from the output. If the output section becomes empty, remove it from the output bfd. @var{info} may be NULL; if it is not, it is used to decide whether the output section is empty.*/void_bfd_strip_section_from_output (info, s) struct bfd_link_info *info; asection *s;{ asection **spp, *os; struct bfd_link_order *p, *pp; boolean keep_os; /* Excise the input section from the link order. FIXME: For all calls that I can see to this function, the link orders have not yet been set up. So why are we checking them? -- Ian */ os = s->output_section; /* Handle a section that wasn't output. */ if (os == NULL) return; for (p = os->link_order_head, pp = NULL; p != NULL; pp = p, p = p->next) if (p->type == bfd_indirect_link_order && p->u.indirect.section == s) { if (pp) pp->next = p->next; else os->link_order_head = p->next; if (!p->next) os->link_order_tail = pp; break; } keep_os = os->link_order_head != NULL; if (! keep_os && info != NULL) { bfd *abfd; for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next) { asection *is; for (is = abfd->sections; is != NULL; is = is->next) { if (is != s && is->output_section == os) break; } if (is != NULL) break; } if (abfd != NULL) keep_os = true; } /* If the output section is empty, remove it too. Careful about sections that have been discarded in the link script -- they are mapped to bfd_abs_section, which has no owner. */ if (!keep_os && os->owner != NULL) { for (spp = &os->owner->sections; *spp; spp = &(*spp)->next) if (*spp == os) { *spp = os->next; os->owner->section_count--; break; } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -