⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 section.texi

📁 gdb-6.0 linux 下的调试工具
💻 TEXI
📖 第 1 页 / 共 2 页
字号:
@section SectionsThe raw data contained within a BFD is maintained through thesection abstraction.  A single BFD may have any number ofsections.  It keeps hold of them by pointing to the first;each one points to the next in the list.Sections are supported in BFD in @code{section.c}.@menu* Section Input::* Section Output::* typedef asection::* section prototypes::@end menu@node Section Input, Section Output, Sections, Sections@subsection Section inputWhen a BFD is opened for reading, the section structures arecreated and attached to the BFD.Each section has a name which describes the section in theoutside world---for example, @code{a.out} would contain at leastthree sections, called @code{.text}, @code{.data} and @code{.bss}.Names need not be unique; for example a COFF file may have severalsections named @code{.data}.Sometimes a BFD will contain more than the ``natural'' number ofsections. A back end may attach other sections containingconstructor data, or an application may add a section (using@code{bfd_make_section}) to the sections attached to an already openBFD. For example, the linker creates an extra section@code{COMMON} for each input file's BFD to hold information aboutcommon storage.The raw data is not necessarily read in whenthe section descriptor is created. Some targets may leave thedata in place until a @code{bfd_get_section_contents} call ismade. Other back ends may read in all the data at once.  Forexample, an S-record file has to be read once to determine thesize of the data. An IEEE-695 file doesn't contain raw data insections, but data and relocation expressions intermixed, sothe data area has to be parsed to get out the data andrelocations.@node Section Output, typedef asection, Section Input, Sections@subsection Section outputTo write a new object style BFD, the various sections to bewritten have to be created. They are attached to the BFD inthe same way as input sections; data is written to thesections using @code{bfd_set_section_contents}.Any program that creates or combines sections (e.g., the assemblerand linker) must use the @code{asection} fields @code{output_section} and@code{output_offset} to indicate the file sections to which eachsection must be written.  (If the section is being created fromscratch, @code{output_section} should probably point to the sectionitself and @code{output_offset} should probably be zero.)The data to be written comes from input sections attached(via @code{output_section} pointers) tothe output sections.  The output section structure can beconsidered a filter for the input section: the output sectiondetermines the vma of the output data and the name, but theinput section determines the offset into the output section ofthe data to be written.E.g., to create a section "O", starting at 0x100, 0x123 long,containing two subsections, "A" at offset 0x0 (i.e., at vma0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the @code{asection}structures would look like:@example   section name          "A"     output_offset   0x00     size            0x20     output_section ----------->  section name    "O"                             |    vma             0x100   section name          "B" |    size            0x123     output_offset   0x20    |     size            0x103   |     output_section  --------|@end example@subsection Link ordersThe data within a section is stored in a @dfn{link_order}.These are much like the fixups in @code{gas}.  The link_orderabstraction allows a section to grow and shrink within itself.A link_order knows how big it is, and which is the nextlink_order and where the raw data for it is; it also points toa list of relocations which apply to it.The link_order is used by the linker to perform relaxing onfinal code.  The compiler creates code which is as big asnecessary to make it work without relaxing, and the user canselect whether to relax.  Sometimes relaxing takes a lot oftime.  The linker runs around the relocations to see if anyare attached to data which can be shrunk, if so it does it ona link_order by link_order basis.@node typedef asection, section prototypes, Section Output, Sections@subsection typedef asectionHere is the section structure:@example/* This structure is used for a comdat section, as in PE.  A comdat   section is associated with a particular symbol.  When the linker   sees a comdat section, it keeps only one of the sections with a   given name and associated with a given symbol.  */struct bfd_comdat_info@{  /* The name of the symbol associated with a comdat section.  */  const char *name;  /* The local symbol table index of the symbol associated with a     comdat section.  This is only meaningful to the object file format     specific code; it is not an index into the list returned by     bfd_canonicalize_symtab.  */  long symbol;@};typedef struct sec@{  /* The name of the section; the name isn't a copy, the pointer is     the same as that passed to bfd_make_section.  */  const char *name;  /* A unique sequence number.  */  int id;  /* Which section in the bfd; 0..n-1 as sections are created in a bfd.  */  int index;  /* The next section in the list belonging to the BFD, or NULL.  */  struct sec *next;  /* The field flags contains attributes of the section. Some     flags are read in from the object file, and some are     synthesized from other information.  */  flagword flags;#define SEC_NO_FLAGS   0x000  /* Tells the OS to allocate space for this section when loading.     This is clear for a section containing debug information only.  */#define SEC_ALLOC      0x001  /* Tells the OS to load the section from the file when loading.     This is clear for a .bss section.  */#define SEC_LOAD       0x002  /* The section contains data still to be relocated, so there is     some relocation information too.  */#define SEC_RELOC      0x004  /* ELF reserves 4 processor specific bits and 8 operating system     specific bits in sh_flags; at present we can get away with just     one in communicating between the assembler and BFD, but this     isn't a good long-term solution.  */#define SEC_ARCH_BIT_0 0x008  /* A signal to the OS that the section contains read only data.  */#define SEC_READONLY   0x010  /* The section contains code only.  */#define SEC_CODE       0x020  /* The section contains data only.  */#define SEC_DATA       0x040  /* The section will reside in ROM.  */#define SEC_ROM        0x080  /* The section contains constructor information. This section     type is used by the linker to create lists of constructors and     destructors used by @code{g++}. When a back end sees a symbol     which should be used in a constructor list, it creates a new     section for the type of name (e.g., @code{__CTOR_LIST__}), attaches     the symbol to it, and builds a relocation. To build the lists     of constructors, all the linker has to do is catenate all the     sections called @code{__CTOR_LIST__} and relocate the data     contained within - exactly the operations it would peform on     standard data.  */#define SEC_CONSTRUCTOR 0x100  /* The section has contents - a data section could be     @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be     @code{SEC_HAS_CONTENTS}  */#define SEC_HAS_CONTENTS 0x200  /* An instruction to the linker to not output the section     even if it has information which would normally be written.  */#define SEC_NEVER_LOAD 0x400  /* The section is a COFF shared library section.  This flag is     only for the linker.  If this type of section appears in     the input file, the linker must copy it to the output file     without changing the vma or size.  FIXME: Although this     was originally intended to be general, it really is COFF     specific (and the flag was renamed to indicate this).  It     might be cleaner to have some more general mechanism to     allow the back end to control what the linker does with     sections.  */#define SEC_COFF_SHARED_LIBRARY 0x800  /* The section contains thread local data.  */#define SEC_THREAD_LOCAL 0x1000  /* The section has GOT references.  This flag is only for the     linker, and is currently only used by the elf32-hppa back end.     It will be set if global offset table references were detected     in this section, which indicate to the linker that the section     contains PIC code, and must be handled specially when doing a     static link.  */#define SEC_HAS_GOT_REF 0x4000  /* The section contains common symbols (symbols may be defined     multiple times, the value of a symbol is the amount of     space it requires, and the largest symbol value is the one     used).  Most targets have exactly one of these (which we     translate to bfd_com_section_ptr), but ECOFF has two.  */#define SEC_IS_COMMON 0x8000  /* The section contains only debugging information.  For     example, this is set for ELF .debug and .stab sections.     strip tests this flag to see if a section can be     discarded.  */#define SEC_DEBUGGING 0x10000  /* The contents of this section are held in memory pointed to     by the contents field.  This is checked by bfd_get_section_contents,     and the data is retrieved from memory if appropriate.  */#define SEC_IN_MEMORY 0x20000  /* The contents of this section are to be excluded by the     linker for executable and shared objects unless those     objects are to be further relocated.  */#define SEC_EXCLUDE 0x40000  /* The contents of this section are to be sorted based on the sum of     the symbol and addend values specified by the associated relocation     entries.  Entries without associated relocation entries will be     appended to the end of the section in an unspecified order.  */#define SEC_SORT_ENTRIES 0x80000  /* When linking, duplicate sections of the same name should be     discarded, rather than being combined into a single section as     is usually done.  This is similar to how common symbols are     handled.  See SEC_LINK_DUPLICATES below.  */#define SEC_LINK_ONCE 0x100000  /* If SEC_LINK_ONCE is set, this bitfield describes how the linker     should handle duplicate sections.  */#define SEC_LINK_DUPLICATES 0x600000  /* This value for SEC_LINK_DUPLICATES means that duplicate     sections with the same name should simply be discarded.  */#define SEC_LINK_DUPLICATES_DISCARD 0x0  /* This value for SEC_LINK_DUPLICATES means that the linker     should warn if there are any duplicate sections, although     it should still only link one copy.  */#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000  /* This value for SEC_LINK_DUPLICATES means that the linker     should warn if any duplicate sections are a different size.  */#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000  /* This value for SEC_LINK_DUPLICATES means that the linker     should warn if any duplicate sections contain different     contents.  */#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000  /* This section was created by the linker as part of dynamic     relocation or other arcane processing.  It is skipped when     going through the first-pass output, trusting that someone     else up the line will take care of it later.  */#define SEC_LINKER_CREATED 0x800000  /* This section should not be subject to garbage collection.  */#define SEC_KEEP 0x1000000  /* This section contains "short" data, and should be placed     "near" the GP.  */#define SEC_SMALL_DATA 0x2000000  /* This section contains data which may be shared with other     executables or shared objects.  */#define SEC_SHARED 0x4000000  /* When a section with this flag is being linked, then if the size of     the input section is less than a page, it should not cross a page     boundary.  If the size of the input section is one page or more, it     should be aligned on a page boundary.  */#define SEC_BLOCK 0x8000000  /* Conditionally link this section; do not link if there are no     references found to any symbol in the section.  */#define SEC_CLINK 0x10000000  /* Attempt to merge identical entities in the section.     Entity size is given in the entsize field.  */#define SEC_MERGE 0x20000000  /* If given with SEC_MERGE, entities to merge are zero terminated     strings where entsize specifies character size instead of fixed     size entries.  */#define SEC_STRINGS 0x40000000  /* This section contains data about section groups.  */#define SEC_GROUP 0x80000000  /*  End of section flags.  */  /* Some internal packed boolean fields.  */  /* See the vma field.  */  unsigned int user_set_vma : 1;  /* Whether relocations have been processed.  */  unsigned int reloc_done : 1;  /* A mark flag used by some of the linker backends.  */  unsigned int linker_mark : 1;  /* Another mark flag used by some of the linker backends.  Set for     output sections that have an input section.  */  unsigned int linker_has_input : 1;  /* A mark flag used by some linker backends for garbage collection.  */  unsigned int gc_mark : 1;  /* The following flags are used by the ELF linker. */  /* Mark sections which have been allocated to segments.  */  unsigned int segment_mark : 1;  /* Type of sec_info information.  */  unsigned int sec_info_type:3;#define ELF_INFO_TYPE_NONE      0#define ELF_INFO_TYPE_STABS     1#define ELF_INFO_TYPE_MERGE     2#define ELF_INFO_TYPE_EH_FRAME  3#define ELF_INFO_TYPE_JUST_SYMS 4  /* Nonzero if this section uses RELA relocations, rather than REL.  */  unsigned int use_rela_p:1;  /* Bits used by various backends.  */  unsigned int has_tls_reloc:1;  /* Nonzero if this section needs the relax finalize pass.  */  unsigned int need_finalize_relax:1;  /* Nonzero if this section has a gp reloc.  */  unsigned int has_gp_reloc:1;  /* Usused bits.  */  unsigned int flag13:1;  unsigned int flag14:1;  unsigned int flag15:1;  unsigned int flag16:4;  unsigned int flag20:4;  unsigned int flag24:8;  /* End of internal packed boolean fields.  */  /*  The virtual memory address of the section - where it will be      at run time.  The symbols are relocated against this.  The      user_set_vma flag is maintained by bfd; if it's not set, the      backend can assign addresses (for example, in @code{a.out}, where      the default address for @code{.data} is dependent on the specific      target and various flags).  */  bfd_vma vma;  /*  The load address of the section - where it would be in a      rom image; really only used for writing section header      information.  */  bfd_vma lma;  /* The size of the section in octets, as it will be output.     Contains a value even if the section has no contents (e.g., the     size of @code{.bss}).  This will be filled in after relocation.  */  bfd_size_type _cooked_size;  /* The original size on disk of the section, in octets.  Normally this     value is the same as the size, but if some relaxing has     been done, then this value will be bigger.  */  bfd_size_type _raw_size;  /* If this section is going to be output, then this value is the     offset in *bytes* into the output section of the first byte in the     input section (byte ==> smallest addressable unit on the     target).  In most cases, if this was going to start at the     100th octet (8-bit quantity) in the output section, this value     would be 100.  However, if the target byte size is 16 bits     (bfd_octets_per_byte is "2"), this value would be 50.  */  bfd_vma output_offset;  /* The output section through which to map on output.  */  struct sec *output_section;  /* The alignment requirement of the section, as an exponent of 2 -     e.g., 3 aligns to 2^3 (or 8).  */  unsigned int alignment_power;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -