1*3d8817e4Smiod@section Sections 2*3d8817e4SmiodThe raw data contained within a BFD is maintained through the 3*3d8817e4Smiodsection abstraction. A single BFD may have any number of 4*3d8817e4Smiodsections. It keeps hold of them by pointing to the first; 5*3d8817e4Smiodeach one points to the next in the list. 6*3d8817e4Smiod 7*3d8817e4SmiodSections are supported in BFD in @code{section.c}. 8*3d8817e4Smiod 9*3d8817e4Smiod@menu 10*3d8817e4Smiod* Section Input:: 11*3d8817e4Smiod* Section Output:: 12*3d8817e4Smiod* typedef asection:: 13*3d8817e4Smiod* section prototypes:: 14*3d8817e4Smiod@end menu 15*3d8817e4Smiod 16*3d8817e4Smiod@node Section Input, Section Output, Sections, Sections 17*3d8817e4Smiod@subsection Section input 18*3d8817e4SmiodWhen a BFD is opened for reading, the section structures are 19*3d8817e4Smiodcreated and attached to the BFD. 20*3d8817e4Smiod 21*3d8817e4SmiodEach section has a name which describes the section in the 22*3d8817e4Smiodoutside world---for example, @code{a.out} would contain at least 23*3d8817e4Smiodthree sections, called @code{.text}, @code{.data} and @code{.bss}. 24*3d8817e4Smiod 25*3d8817e4SmiodNames need not be unique; for example a COFF file may have several 26*3d8817e4Smiodsections named @code{.data}. 27*3d8817e4Smiod 28*3d8817e4SmiodSometimes a BFD will contain more than the ``natural'' number of 29*3d8817e4Smiodsections. A back end may attach other sections containing 30*3d8817e4Smiodconstructor data, or an application may add a section (using 31*3d8817e4Smiod@code{bfd_make_section}) to the sections attached to an already open 32*3d8817e4SmiodBFD. For example, the linker creates an extra section 33*3d8817e4Smiod@code{COMMON} for each input file's BFD to hold information about 34*3d8817e4Smiodcommon storage. 35*3d8817e4Smiod 36*3d8817e4SmiodThe raw data is not necessarily read in when 37*3d8817e4Smiodthe section descriptor is created. Some targets may leave the 38*3d8817e4Smioddata in place until a @code{bfd_get_section_contents} call is 39*3d8817e4Smiodmade. Other back ends may read in all the data at once. For 40*3d8817e4Smiodexample, an S-record file has to be read once to determine the 41*3d8817e4Smiodsize of the data. An IEEE-695 file doesn't contain raw data in 42*3d8817e4Smiodsections, but data and relocation expressions intermixed, so 43*3d8817e4Smiodthe data area has to be parsed to get out the data and 44*3d8817e4Smiodrelocations. 45*3d8817e4Smiod 46*3d8817e4Smiod@node Section Output, typedef asection, Section Input, Sections 47*3d8817e4Smiod@subsection Section output 48*3d8817e4SmiodTo write a new object style BFD, the various sections to be 49*3d8817e4Smiodwritten have to be created. They are attached to the BFD in 50*3d8817e4Smiodthe same way as input sections; data is written to the 51*3d8817e4Smiodsections using @code{bfd_set_section_contents}. 52*3d8817e4Smiod 53*3d8817e4SmiodAny program that creates or combines sections (e.g., the assembler 54*3d8817e4Smiodand linker) must use the @code{asection} fields @code{output_section} and 55*3d8817e4Smiod@code{output_offset} to indicate the file sections to which each 56*3d8817e4Smiodsection must be written. (If the section is being created from 57*3d8817e4Smiodscratch, @code{output_section} should probably point to the section 58*3d8817e4Smioditself and @code{output_offset} should probably be zero.) 59*3d8817e4Smiod 60*3d8817e4SmiodThe data to be written comes from input sections attached 61*3d8817e4Smiod(via @code{output_section} pointers) to 62*3d8817e4Smiodthe output sections. The output section structure can be 63*3d8817e4Smiodconsidered a filter for the input section: the output section 64*3d8817e4Smioddetermines the vma of the output data and the name, but the 65*3d8817e4Smiodinput section determines the offset into the output section of 66*3d8817e4Smiodthe data to be written. 67*3d8817e4Smiod 68*3d8817e4SmiodE.g., to create a section "O", starting at 0x100, 0x123 long, 69*3d8817e4Smiodcontaining two subsections, "A" at offset 0x0 (i.e., at vma 70*3d8817e4Smiod0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the @code{asection} 71*3d8817e4Smiodstructures would look like: 72*3d8817e4Smiod 73*3d8817e4Smiod@example 74*3d8817e4Smiod section name "A" 75*3d8817e4Smiod output_offset 0x00 76*3d8817e4Smiod size 0x20 77*3d8817e4Smiod output_section -----------> section name "O" 78*3d8817e4Smiod | vma 0x100 79*3d8817e4Smiod section name "B" | size 0x123 80*3d8817e4Smiod output_offset 0x20 | 81*3d8817e4Smiod size 0x103 | 82*3d8817e4Smiod output_section --------| 83*3d8817e4Smiod@end example 84*3d8817e4Smiod 85*3d8817e4Smiod@subsection Link orders 86*3d8817e4SmiodThe data within a section is stored in a @dfn{link_order}. 87*3d8817e4SmiodThese are much like the fixups in @code{gas}. The link_order 88*3d8817e4Smiodabstraction allows a section to grow and shrink within itself. 89*3d8817e4Smiod 90*3d8817e4SmiodA link_order knows how big it is, and which is the next 91*3d8817e4Smiodlink_order and where the raw data for it is; it also points to 92*3d8817e4Smioda list of relocations which apply to it. 93*3d8817e4Smiod 94*3d8817e4SmiodThe link_order is used by the linker to perform relaxing on 95*3d8817e4Smiodfinal code. The compiler creates code which is as big as 96*3d8817e4Smiodnecessary to make it work without relaxing, and the user can 97*3d8817e4Smiodselect whether to relax. Sometimes relaxing takes a lot of 98*3d8817e4Smiodtime. The linker runs around the relocations to see if any 99*3d8817e4Smiodare attached to data which can be shrunk, if so it does it on 100*3d8817e4Smioda link_order by link_order basis. 101*3d8817e4Smiod 102*3d8817e4Smiod 103*3d8817e4Smiod@node typedef asection, section prototypes, Section Output, Sections 104*3d8817e4Smiod@subsection typedef asection 105*3d8817e4SmiodHere is the section structure: 106*3d8817e4Smiod 107*3d8817e4Smiod 108*3d8817e4Smiod@example 109*3d8817e4Smiod 110*3d8817e4Smiodtypedef struct bfd_section 111*3d8817e4Smiod@{ 112*3d8817e4Smiod /* The name of the section; the name isn't a copy, the pointer is 113*3d8817e4Smiod the same as that passed to bfd_make_section. */ 114*3d8817e4Smiod const char *name; 115*3d8817e4Smiod 116*3d8817e4Smiod /* A unique sequence number. */ 117*3d8817e4Smiod int id; 118*3d8817e4Smiod 119*3d8817e4Smiod /* Which section in the bfd; 0..n-1 as sections are created in a bfd. */ 120*3d8817e4Smiod int index; 121*3d8817e4Smiod 122*3d8817e4Smiod /* The next section in the list belonging to the BFD, or NULL. */ 123*3d8817e4Smiod struct bfd_section *next; 124*3d8817e4Smiod 125*3d8817e4Smiod /* The previous section in the list belonging to the BFD, or NULL. */ 126*3d8817e4Smiod struct bfd_section *prev; 127*3d8817e4Smiod 128*3d8817e4Smiod /* The field flags contains attributes of the section. Some 129*3d8817e4Smiod flags are read in from the object file, and some are 130*3d8817e4Smiod synthesized from other information. */ 131*3d8817e4Smiod flagword flags; 132*3d8817e4Smiod 133*3d8817e4Smiod#define SEC_NO_FLAGS 0x000 134*3d8817e4Smiod 135*3d8817e4Smiod /* Tells the OS to allocate space for this section when loading. 136*3d8817e4Smiod This is clear for a section containing debug information only. */ 137*3d8817e4Smiod#define SEC_ALLOC 0x001 138*3d8817e4Smiod 139*3d8817e4Smiod /* Tells the OS to load the section from the file when loading. 140*3d8817e4Smiod This is clear for a .bss section. */ 141*3d8817e4Smiod#define SEC_LOAD 0x002 142*3d8817e4Smiod 143*3d8817e4Smiod /* The section contains data still to be relocated, so there is 144*3d8817e4Smiod some relocation information too. */ 145*3d8817e4Smiod#define SEC_RELOC 0x004 146*3d8817e4Smiod 147*3d8817e4Smiod /* A signal to the OS that the section contains read only data. */ 148*3d8817e4Smiod#define SEC_READONLY 0x008 149*3d8817e4Smiod 150*3d8817e4Smiod /* The section contains code only. */ 151*3d8817e4Smiod#define SEC_CODE 0x010 152*3d8817e4Smiod 153*3d8817e4Smiod /* The section contains data only. */ 154*3d8817e4Smiod#define SEC_DATA 0x020 155*3d8817e4Smiod 156*3d8817e4Smiod /* The section will reside in ROM. */ 157*3d8817e4Smiod#define SEC_ROM 0x040 158*3d8817e4Smiod 159*3d8817e4Smiod /* The section contains constructor information. This section 160*3d8817e4Smiod type is used by the linker to create lists of constructors and 161*3d8817e4Smiod destructors used by @code{g++}. When a back end sees a symbol 162*3d8817e4Smiod which should be used in a constructor list, it creates a new 163*3d8817e4Smiod section for the type of name (e.g., @code{__CTOR_LIST__}), attaches 164*3d8817e4Smiod the symbol to it, and builds a relocation. To build the lists 165*3d8817e4Smiod of constructors, all the linker has to do is catenate all the 166*3d8817e4Smiod sections called @code{__CTOR_LIST__} and relocate the data 167*3d8817e4Smiod contained within - exactly the operations it would peform on 168*3d8817e4Smiod standard data. */ 169*3d8817e4Smiod#define SEC_CONSTRUCTOR 0x080 170*3d8817e4Smiod 171*3d8817e4Smiod /* The section has contents - a data section could be 172*3d8817e4Smiod @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}; a debug section could be 173*3d8817e4Smiod @code{SEC_HAS_CONTENTS} */ 174*3d8817e4Smiod#define SEC_HAS_CONTENTS 0x100 175*3d8817e4Smiod 176*3d8817e4Smiod /* An instruction to the linker to not output the section 177*3d8817e4Smiod even if it has information which would normally be written. */ 178*3d8817e4Smiod#define SEC_NEVER_LOAD 0x200 179*3d8817e4Smiod 180*3d8817e4Smiod /* The section contains thread local data. */ 181*3d8817e4Smiod#define SEC_THREAD_LOCAL 0x400 182*3d8817e4Smiod 183*3d8817e4Smiod /* The section has GOT references. This flag is only for the 184*3d8817e4Smiod linker, and is currently only used by the elf32-hppa back end. 185*3d8817e4Smiod It will be set if global offset table references were detected 186*3d8817e4Smiod in this section, which indicate to the linker that the section 187*3d8817e4Smiod contains PIC code, and must be handled specially when doing a 188*3d8817e4Smiod static link. */ 189*3d8817e4Smiod#define SEC_HAS_GOT_REF 0x800 190*3d8817e4Smiod 191*3d8817e4Smiod /* The section contains common symbols (symbols may be defined 192*3d8817e4Smiod multiple times, the value of a symbol is the amount of 193*3d8817e4Smiod space it requires, and the largest symbol value is the one 194*3d8817e4Smiod used). Most targets have exactly one of these (which we 195*3d8817e4Smiod translate to bfd_com_section_ptr), but ECOFF has two. */ 196*3d8817e4Smiod#define SEC_IS_COMMON 0x1000 197*3d8817e4Smiod 198*3d8817e4Smiod /* The section contains only debugging information. For 199*3d8817e4Smiod example, this is set for ELF .debug and .stab sections. 200*3d8817e4Smiod strip tests this flag to see if a section can be 201*3d8817e4Smiod discarded. */ 202*3d8817e4Smiod#define SEC_DEBUGGING 0x2000 203*3d8817e4Smiod 204*3d8817e4Smiod /* The contents of this section are held in memory pointed to 205*3d8817e4Smiod by the contents field. This is checked by bfd_get_section_contents, 206*3d8817e4Smiod and the data is retrieved from memory if appropriate. */ 207*3d8817e4Smiod#define SEC_IN_MEMORY 0x4000 208*3d8817e4Smiod 209*3d8817e4Smiod /* The contents of this section are to be excluded by the 210*3d8817e4Smiod linker for executable and shared objects unless those 211*3d8817e4Smiod objects are to be further relocated. */ 212*3d8817e4Smiod#define SEC_EXCLUDE 0x8000 213*3d8817e4Smiod 214*3d8817e4Smiod /* The contents of this section are to be sorted based on the sum of 215*3d8817e4Smiod the symbol and addend values specified by the associated relocation 216*3d8817e4Smiod entries. Entries without associated relocation entries will be 217*3d8817e4Smiod appended to the end of the section in an unspecified order. */ 218*3d8817e4Smiod#define SEC_SORT_ENTRIES 0x10000 219*3d8817e4Smiod 220*3d8817e4Smiod /* When linking, duplicate sections of the same name should be 221*3d8817e4Smiod discarded, rather than being combined into a single section as 222*3d8817e4Smiod is usually done. This is similar to how common symbols are 223*3d8817e4Smiod handled. See SEC_LINK_DUPLICATES below. */ 224*3d8817e4Smiod#define SEC_LINK_ONCE 0x20000 225*3d8817e4Smiod 226*3d8817e4Smiod /* If SEC_LINK_ONCE is set, this bitfield describes how the linker 227*3d8817e4Smiod should handle duplicate sections. */ 228*3d8817e4Smiod#define SEC_LINK_DUPLICATES 0x40000 229*3d8817e4Smiod 230*3d8817e4Smiod /* This value for SEC_LINK_DUPLICATES means that duplicate 231*3d8817e4Smiod sections with the same name should simply be discarded. */ 232*3d8817e4Smiod#define SEC_LINK_DUPLICATES_DISCARD 0x0 233*3d8817e4Smiod 234*3d8817e4Smiod /* This value for SEC_LINK_DUPLICATES means that the linker 235*3d8817e4Smiod should warn if there are any duplicate sections, although 236*3d8817e4Smiod it should still only link one copy. */ 237*3d8817e4Smiod#define SEC_LINK_DUPLICATES_ONE_ONLY 0x80000 238*3d8817e4Smiod 239*3d8817e4Smiod /* This value for SEC_LINK_DUPLICATES means that the linker 240*3d8817e4Smiod should warn if any duplicate sections are a different size. */ 241*3d8817e4Smiod#define SEC_LINK_DUPLICATES_SAME_SIZE 0x100000 242*3d8817e4Smiod 243*3d8817e4Smiod /* This value for SEC_LINK_DUPLICATES means that the linker 244*3d8817e4Smiod should warn if any duplicate sections contain different 245*3d8817e4Smiod contents. */ 246*3d8817e4Smiod#define SEC_LINK_DUPLICATES_SAME_CONTENTS \ 247*3d8817e4Smiod (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE) 248*3d8817e4Smiod 249*3d8817e4Smiod /* This section was created by the linker as part of dynamic 250*3d8817e4Smiod relocation or other arcane processing. It is skipped when 251*3d8817e4Smiod going through the first-pass output, trusting that someone 252*3d8817e4Smiod else up the line will take care of it later. */ 253*3d8817e4Smiod#define SEC_LINKER_CREATED 0x200000 254*3d8817e4Smiod 255*3d8817e4Smiod /* This section should not be subject to garbage collection. */ 256*3d8817e4Smiod#define SEC_KEEP 0x400000 257*3d8817e4Smiod 258*3d8817e4Smiod /* This section contains "short" data, and should be placed 259*3d8817e4Smiod "near" the GP. */ 260*3d8817e4Smiod#define SEC_SMALL_DATA 0x800000 261*3d8817e4Smiod 262*3d8817e4Smiod /* Attempt to merge identical entities in the section. 263*3d8817e4Smiod Entity size is given in the entsize field. */ 264*3d8817e4Smiod#define SEC_MERGE 0x1000000 265*3d8817e4Smiod 266*3d8817e4Smiod /* If given with SEC_MERGE, entities to merge are zero terminated 267*3d8817e4Smiod strings where entsize specifies character size instead of fixed 268*3d8817e4Smiod size entries. */ 269*3d8817e4Smiod#define SEC_STRINGS 0x2000000 270*3d8817e4Smiod 271*3d8817e4Smiod /* This section contains data about section groups. */ 272*3d8817e4Smiod#define SEC_GROUP 0x4000000 273*3d8817e4Smiod 274*3d8817e4Smiod /* The section is a COFF shared library section. This flag is 275*3d8817e4Smiod only for the linker. If this type of section appears in 276*3d8817e4Smiod the input file, the linker must copy it to the output file 277*3d8817e4Smiod without changing the vma or size. FIXME: Although this 278*3d8817e4Smiod was originally intended to be general, it really is COFF 279*3d8817e4Smiod specific (and the flag was renamed to indicate this). It 280*3d8817e4Smiod might be cleaner to have some more general mechanism to 281*3d8817e4Smiod allow the back end to control what the linker does with 282*3d8817e4Smiod sections. */ 283*3d8817e4Smiod#define SEC_COFF_SHARED_LIBRARY 0x10000000 284*3d8817e4Smiod 285*3d8817e4Smiod /* This section contains data which may be shared with other 286*3d8817e4Smiod executables or shared objects. This is for COFF only. */ 287*3d8817e4Smiod#define SEC_COFF_SHARED 0x20000000 288*3d8817e4Smiod 289*3d8817e4Smiod /* When a section with this flag is being linked, then if the size of 290*3d8817e4Smiod the input section is less than a page, it should not cross a page 291*3d8817e4Smiod boundary. If the size of the input section is one page or more, 292*3d8817e4Smiod it should be aligned on a page boundary. This is for TI 293*3d8817e4Smiod TMS320C54X only. */ 294*3d8817e4Smiod#define SEC_TIC54X_BLOCK 0x40000000 295*3d8817e4Smiod 296*3d8817e4Smiod /* Conditionally link this section; do not link if there are no 297*3d8817e4Smiod references found to any symbol in the section. This is for TI 298*3d8817e4Smiod TMS320C54X only. */ 299*3d8817e4Smiod#define SEC_TIC54X_CLINK 0x80000000 300*3d8817e4Smiod 301*3d8817e4Smiod /* End of section flags. */ 302*3d8817e4Smiod 303*3d8817e4Smiod /* Some internal packed boolean fields. */ 304*3d8817e4Smiod 305*3d8817e4Smiod /* See the vma field. */ 306*3d8817e4Smiod unsigned int user_set_vma : 1; 307*3d8817e4Smiod 308*3d8817e4Smiod /* A mark flag used by some of the linker backends. */ 309*3d8817e4Smiod unsigned int linker_mark : 1; 310*3d8817e4Smiod 311*3d8817e4Smiod /* Another mark flag used by some of the linker backends. Set for 312*3d8817e4Smiod output sections that have an input section. */ 313*3d8817e4Smiod unsigned int linker_has_input : 1; 314*3d8817e4Smiod 315*3d8817e4Smiod /* Mark flags used by some linker backends for garbage collection. */ 316*3d8817e4Smiod unsigned int gc_mark : 1; 317*3d8817e4Smiod unsigned int gc_mark_from_eh : 1; 318*3d8817e4Smiod 319*3d8817e4Smiod /* The following flags are used by the ELF linker. */ 320*3d8817e4Smiod 321*3d8817e4Smiod /* Mark sections which have been allocated to segments. */ 322*3d8817e4Smiod unsigned int segment_mark : 1; 323*3d8817e4Smiod 324*3d8817e4Smiod /* Type of sec_info information. */ 325*3d8817e4Smiod unsigned int sec_info_type:3; 326*3d8817e4Smiod#define ELF_INFO_TYPE_NONE 0 327*3d8817e4Smiod#define ELF_INFO_TYPE_STABS 1 328*3d8817e4Smiod#define ELF_INFO_TYPE_MERGE 2 329*3d8817e4Smiod#define ELF_INFO_TYPE_EH_FRAME 3 330*3d8817e4Smiod#define ELF_INFO_TYPE_JUST_SYMS 4 331*3d8817e4Smiod 332*3d8817e4Smiod /* Nonzero if this section uses RELA relocations, rather than REL. */ 333*3d8817e4Smiod unsigned int use_rela_p:1; 334*3d8817e4Smiod 335*3d8817e4Smiod /* Bits used by various backends. The generic code doesn't touch 336*3d8817e4Smiod these fields. */ 337*3d8817e4Smiod 338*3d8817e4Smiod /* Nonzero if this section has TLS related relocations. */ 339*3d8817e4Smiod unsigned int has_tls_reloc:1; 340*3d8817e4Smiod 341*3d8817e4Smiod /* Nonzero if this section has a gp reloc. */ 342*3d8817e4Smiod unsigned int has_gp_reloc:1; 343*3d8817e4Smiod 344*3d8817e4Smiod /* Nonzero if this section needs the relax finalize pass. */ 345*3d8817e4Smiod unsigned int need_finalize_relax:1; 346*3d8817e4Smiod 347*3d8817e4Smiod /* Whether relocations have been processed. */ 348*3d8817e4Smiod unsigned int reloc_done : 1; 349*3d8817e4Smiod 350*3d8817e4Smiod /* End of internal packed boolean fields. */ 351*3d8817e4Smiod 352*3d8817e4Smiod /* The virtual memory address of the section - where it will be 353*3d8817e4Smiod at run time. The symbols are relocated against this. The 354*3d8817e4Smiod user_set_vma flag is maintained by bfd; if it's not set, the 355*3d8817e4Smiod backend can assign addresses (for example, in @code{a.out}, where 356*3d8817e4Smiod the default address for @code{.data} is dependent on the specific 357*3d8817e4Smiod target and various flags). */ 358*3d8817e4Smiod bfd_vma vma; 359*3d8817e4Smiod 360*3d8817e4Smiod /* The load address of the section - where it would be in a 361*3d8817e4Smiod rom image; really only used for writing section header 362*3d8817e4Smiod information. */ 363*3d8817e4Smiod bfd_vma lma; 364*3d8817e4Smiod 365*3d8817e4Smiod /* The size of the section in octets, as it will be output. 366*3d8817e4Smiod Contains a value even if the section has no contents (e.g., the 367*3d8817e4Smiod size of @code{.bss}). */ 368*3d8817e4Smiod bfd_size_type size; 369*3d8817e4Smiod 370*3d8817e4Smiod /* For input sections, the original size on disk of the section, in 371*3d8817e4Smiod octets. This field is used by the linker relaxation code. It is 372*3d8817e4Smiod currently only set for sections where the linker relaxation scheme 373*3d8817e4Smiod doesn't cache altered section and reloc contents (stabs, eh_frame, 374*3d8817e4Smiod SEC_MERGE, some coff relaxing targets), and thus the original size 375*3d8817e4Smiod needs to be kept to read the section multiple times. 376*3d8817e4Smiod For output sections, rawsize holds the section size calculated on 377*3d8817e4Smiod a previous linker relaxation pass. */ 378*3d8817e4Smiod bfd_size_type rawsize; 379*3d8817e4Smiod 380*3d8817e4Smiod /* If this section is going to be output, then this value is the 381*3d8817e4Smiod offset in *bytes* into the output section of the first byte in the 382*3d8817e4Smiod input section (byte ==> smallest addressable unit on the 383*3d8817e4Smiod target). In most cases, if this was going to start at the 384*3d8817e4Smiod 100th octet (8-bit quantity) in the output section, this value 385*3d8817e4Smiod would be 100. However, if the target byte size is 16 bits 386*3d8817e4Smiod (bfd_octets_per_byte is "2"), this value would be 50. */ 387*3d8817e4Smiod bfd_vma output_offset; 388*3d8817e4Smiod 389*3d8817e4Smiod /* The output section through which to map on output. */ 390*3d8817e4Smiod struct bfd_section *output_section; 391*3d8817e4Smiod 392*3d8817e4Smiod /* The alignment requirement of the section, as an exponent of 2 - 393*3d8817e4Smiod e.g., 3 aligns to 2^3 (or 8). */ 394*3d8817e4Smiod unsigned int alignment_power; 395*3d8817e4Smiod 396*3d8817e4Smiod /* If an input section, a pointer to a vector of relocation 397*3d8817e4Smiod records for the data in this section. */ 398*3d8817e4Smiod struct reloc_cache_entry *relocation; 399*3d8817e4Smiod 400*3d8817e4Smiod /* If an output section, a pointer to a vector of pointers to 401*3d8817e4Smiod relocation records for the data in this section. */ 402*3d8817e4Smiod struct reloc_cache_entry **orelocation; 403*3d8817e4Smiod 404*3d8817e4Smiod /* The number of relocation records in one of the above. */ 405*3d8817e4Smiod unsigned reloc_count; 406*3d8817e4Smiod 407*3d8817e4Smiod /* Information below is back end specific - and not always used 408*3d8817e4Smiod or updated. */ 409*3d8817e4Smiod 410*3d8817e4Smiod /* File position of section data. */ 411*3d8817e4Smiod file_ptr filepos; 412*3d8817e4Smiod 413*3d8817e4Smiod /* File position of relocation info. */ 414*3d8817e4Smiod file_ptr rel_filepos; 415*3d8817e4Smiod 416*3d8817e4Smiod /* File position of line data. */ 417*3d8817e4Smiod file_ptr line_filepos; 418*3d8817e4Smiod 419*3d8817e4Smiod /* Pointer to data for applications. */ 420*3d8817e4Smiod void *userdata; 421*3d8817e4Smiod 422*3d8817e4Smiod /* If the SEC_IN_MEMORY flag is set, this points to the actual 423*3d8817e4Smiod contents. */ 424*3d8817e4Smiod unsigned char *contents; 425*3d8817e4Smiod 426*3d8817e4Smiod /* Attached line number information. */ 427*3d8817e4Smiod alent *lineno; 428*3d8817e4Smiod 429*3d8817e4Smiod /* Number of line number records. */ 430*3d8817e4Smiod unsigned int lineno_count; 431*3d8817e4Smiod 432*3d8817e4Smiod /* Entity size for merging purposes. */ 433*3d8817e4Smiod unsigned int entsize; 434*3d8817e4Smiod 435*3d8817e4Smiod /* Points to the kept section if this section is a link-once section, 436*3d8817e4Smiod and is discarded. */ 437*3d8817e4Smiod struct bfd_section *kept_section; 438*3d8817e4Smiod 439*3d8817e4Smiod /* When a section is being output, this value changes as more 440*3d8817e4Smiod linenumbers are written out. */ 441*3d8817e4Smiod file_ptr moving_line_filepos; 442*3d8817e4Smiod 443*3d8817e4Smiod /* What the section number is in the target world. */ 444*3d8817e4Smiod int target_index; 445*3d8817e4Smiod 446*3d8817e4Smiod void *used_by_bfd; 447*3d8817e4Smiod 448*3d8817e4Smiod /* If this is a constructor section then here is a list of the 449*3d8817e4Smiod relocations created to relocate items within it. */ 450*3d8817e4Smiod struct relent_chain *constructor_chain; 451*3d8817e4Smiod 452*3d8817e4Smiod /* The BFD which owns the section. */ 453*3d8817e4Smiod bfd *owner; 454*3d8817e4Smiod 455*3d8817e4Smiod /* A symbol which points at this section only. */ 456*3d8817e4Smiod struct bfd_symbol *symbol; 457*3d8817e4Smiod struct bfd_symbol **symbol_ptr_ptr; 458*3d8817e4Smiod 459*3d8817e4Smiod /* Early in the link process, map_head and map_tail are used to build 460*3d8817e4Smiod a list of input sections attached to an output section. Later, 461*3d8817e4Smiod output sections use these fields for a list of bfd_link_order 462*3d8817e4Smiod structs. */ 463*3d8817e4Smiod union @{ 464*3d8817e4Smiod struct bfd_link_order *link_order; 465*3d8817e4Smiod struct bfd_section *s; 466*3d8817e4Smiod @} map_head, map_tail; 467*3d8817e4Smiod@} asection; 468*3d8817e4Smiod 469*3d8817e4Smiod/* These sections are global, and are managed by BFD. The application 470*3d8817e4Smiod and target back end are not permitted to change the values in 471*3d8817e4Smiod these sections. New code should use the section_ptr macros rather 472*3d8817e4Smiod than referring directly to the const sections. The const sections 473*3d8817e4Smiod may eventually vanish. */ 474*3d8817e4Smiod#define BFD_ABS_SECTION_NAME "*ABS*" 475*3d8817e4Smiod#define BFD_UND_SECTION_NAME "*UND*" 476*3d8817e4Smiod#define BFD_COM_SECTION_NAME "*COM*" 477*3d8817e4Smiod#define BFD_IND_SECTION_NAME "*IND*" 478*3d8817e4Smiod 479*3d8817e4Smiod/* The absolute section. */ 480*3d8817e4Smiodextern asection bfd_abs_section; 481*3d8817e4Smiod#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) 482*3d8817e4Smiod#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) 483*3d8817e4Smiod/* Pointer to the undefined section. */ 484*3d8817e4Smiodextern asection bfd_und_section; 485*3d8817e4Smiod#define bfd_und_section_ptr ((asection *) &bfd_und_section) 486*3d8817e4Smiod#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) 487*3d8817e4Smiod/* Pointer to the common section. */ 488*3d8817e4Smiodextern asection bfd_com_section; 489*3d8817e4Smiod#define bfd_com_section_ptr ((asection *) &bfd_com_section) 490*3d8817e4Smiod/* Pointer to the indirect section. */ 491*3d8817e4Smiodextern asection bfd_ind_section; 492*3d8817e4Smiod#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) 493*3d8817e4Smiod#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) 494*3d8817e4Smiod 495*3d8817e4Smiod#define bfd_is_const_section(SEC) \ 496*3d8817e4Smiod ( ((SEC) == bfd_abs_section_ptr) \ 497*3d8817e4Smiod || ((SEC) == bfd_und_section_ptr) \ 498*3d8817e4Smiod || ((SEC) == bfd_com_section_ptr) \ 499*3d8817e4Smiod || ((SEC) == bfd_ind_section_ptr)) 500*3d8817e4Smiod 501*3d8817e4Smiodextern const struct bfd_symbol * const bfd_abs_symbol; 502*3d8817e4Smiodextern const struct bfd_symbol * const bfd_com_symbol; 503*3d8817e4Smiodextern const struct bfd_symbol * const bfd_und_symbol; 504*3d8817e4Smiodextern const struct bfd_symbol * const bfd_ind_symbol; 505*3d8817e4Smiod 506*3d8817e4Smiod/* Macros to handle insertion and deletion of a bfd's sections. These 507*3d8817e4Smiod only handle the list pointers, ie. do not adjust section_count, 508*3d8817e4Smiod target_index etc. */ 509*3d8817e4Smiod#define bfd_section_list_remove(ABFD, S) \ 510*3d8817e4Smiod do \ 511*3d8817e4Smiod @{ \ 512*3d8817e4Smiod asection *_s = S; \ 513*3d8817e4Smiod asection *_next = _s->next; \ 514*3d8817e4Smiod asection *_prev = _s->prev; \ 515*3d8817e4Smiod if (_prev) \ 516*3d8817e4Smiod _prev->next = _next; \ 517*3d8817e4Smiod else \ 518*3d8817e4Smiod (ABFD)->sections = _next; \ 519*3d8817e4Smiod if (_next) \ 520*3d8817e4Smiod _next->prev = _prev; \ 521*3d8817e4Smiod else \ 522*3d8817e4Smiod (ABFD)->section_last = _prev; \ 523*3d8817e4Smiod @} \ 524*3d8817e4Smiod while (0) 525*3d8817e4Smiod#define bfd_section_list_append(ABFD, S) \ 526*3d8817e4Smiod do \ 527*3d8817e4Smiod @{ \ 528*3d8817e4Smiod asection *_s = S; \ 529*3d8817e4Smiod bfd *_abfd = ABFD; \ 530*3d8817e4Smiod _s->next = NULL; \ 531*3d8817e4Smiod if (_abfd->section_last) \ 532*3d8817e4Smiod @{ \ 533*3d8817e4Smiod _s->prev = _abfd->section_last; \ 534*3d8817e4Smiod _abfd->section_last->next = _s; \ 535*3d8817e4Smiod @} \ 536*3d8817e4Smiod else \ 537*3d8817e4Smiod @{ \ 538*3d8817e4Smiod _s->prev = NULL; \ 539*3d8817e4Smiod _abfd->sections = _s; \ 540*3d8817e4Smiod @} \ 541*3d8817e4Smiod _abfd->section_last = _s; \ 542*3d8817e4Smiod @} \ 543*3d8817e4Smiod while (0) 544*3d8817e4Smiod#define bfd_section_list_prepend(ABFD, S) \ 545*3d8817e4Smiod do \ 546*3d8817e4Smiod @{ \ 547*3d8817e4Smiod asection *_s = S; \ 548*3d8817e4Smiod bfd *_abfd = ABFD; \ 549*3d8817e4Smiod _s->prev = NULL; \ 550*3d8817e4Smiod if (_abfd->sections) \ 551*3d8817e4Smiod @{ \ 552*3d8817e4Smiod _s->next = _abfd->sections; \ 553*3d8817e4Smiod _abfd->sections->prev = _s; \ 554*3d8817e4Smiod @} \ 555*3d8817e4Smiod else \ 556*3d8817e4Smiod @{ \ 557*3d8817e4Smiod _s->next = NULL; \ 558*3d8817e4Smiod _abfd->section_last = _s; \ 559*3d8817e4Smiod @} \ 560*3d8817e4Smiod _abfd->sections = _s; \ 561*3d8817e4Smiod @} \ 562*3d8817e4Smiod while (0) 563*3d8817e4Smiod#define bfd_section_list_insert_after(ABFD, A, S) \ 564*3d8817e4Smiod do \ 565*3d8817e4Smiod @{ \ 566*3d8817e4Smiod asection *_a = A; \ 567*3d8817e4Smiod asection *_s = S; \ 568*3d8817e4Smiod asection *_next = _a->next; \ 569*3d8817e4Smiod _s->next = _next; \ 570*3d8817e4Smiod _s->prev = _a; \ 571*3d8817e4Smiod _a->next = _s; \ 572*3d8817e4Smiod if (_next) \ 573*3d8817e4Smiod _next->prev = _s; \ 574*3d8817e4Smiod else \ 575*3d8817e4Smiod (ABFD)->section_last = _s; \ 576*3d8817e4Smiod @} \ 577*3d8817e4Smiod while (0) 578*3d8817e4Smiod#define bfd_section_list_insert_before(ABFD, B, S) \ 579*3d8817e4Smiod do \ 580*3d8817e4Smiod @{ \ 581*3d8817e4Smiod asection *_b = B; \ 582*3d8817e4Smiod asection *_s = S; \ 583*3d8817e4Smiod asection *_prev = _b->prev; \ 584*3d8817e4Smiod _s->prev = _prev; \ 585*3d8817e4Smiod _s->next = _b; \ 586*3d8817e4Smiod _b->prev = _s; \ 587*3d8817e4Smiod if (_prev) \ 588*3d8817e4Smiod _prev->next = _s; \ 589*3d8817e4Smiod else \ 590*3d8817e4Smiod (ABFD)->sections = _s; \ 591*3d8817e4Smiod @} \ 592*3d8817e4Smiod while (0) 593*3d8817e4Smiod#define bfd_section_removed_from_list(ABFD, S) \ 594*3d8817e4Smiod ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S)) 595*3d8817e4Smiod 596*3d8817e4Smiod#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, SYM_PTR, NAME, IDX) \ 597*3d8817e4Smiod /* name, id, index, next, prev, flags, user_set_vma, */ \ 598*3d8817e4Smiod @{ NAME, IDX, 0, NULL, NULL, FLAGS, 0, \ 599*3d8817e4Smiod \ 600*3d8817e4Smiod /* linker_mark, linker_has_input, gc_mark, gc_mark_from_eh, */ \ 601*3d8817e4Smiod 0, 0, 1, 0, \ 602*3d8817e4Smiod \ 603*3d8817e4Smiod /* segment_mark, sec_info_type, use_rela_p, has_tls_reloc, */ \ 604*3d8817e4Smiod 0, 0, 0, 0, \ 605*3d8817e4Smiod \ 606*3d8817e4Smiod /* has_gp_reloc, need_finalize_relax, reloc_done, */ \ 607*3d8817e4Smiod 0, 0, 0, \ 608*3d8817e4Smiod \ 609*3d8817e4Smiod /* vma, lma, size, rawsize */ \ 610*3d8817e4Smiod 0, 0, 0, 0, \ 611*3d8817e4Smiod \ 612*3d8817e4Smiod /* output_offset, output_section, alignment_power, */ \ 613*3d8817e4Smiod 0, (struct bfd_section *) &SEC, 0, \ 614*3d8817e4Smiod \ 615*3d8817e4Smiod /* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \ 616*3d8817e4Smiod NULL, NULL, 0, 0, 0, \ 617*3d8817e4Smiod \ 618*3d8817e4Smiod /* line_filepos, userdata, contents, lineno, lineno_count, */ \ 619*3d8817e4Smiod 0, NULL, NULL, NULL, 0, \ 620*3d8817e4Smiod \ 621*3d8817e4Smiod /* entsize, kept_section, moving_line_filepos, */ \ 622*3d8817e4Smiod 0, NULL, 0, \ 623*3d8817e4Smiod \ 624*3d8817e4Smiod /* target_index, used_by_bfd, constructor_chain, owner, */ \ 625*3d8817e4Smiod 0, NULL, NULL, NULL, \ 626*3d8817e4Smiod \ 627*3d8817e4Smiod /* symbol, */ \ 628*3d8817e4Smiod (struct bfd_symbol *) SYM, \ 629*3d8817e4Smiod \ 630*3d8817e4Smiod /* symbol_ptr_ptr, */ \ 631*3d8817e4Smiod (struct bfd_symbol **) SYM_PTR, \ 632*3d8817e4Smiod \ 633*3d8817e4Smiod /* map_head, map_tail */ \ 634*3d8817e4Smiod @{ NULL @}, @{ NULL @} \ 635*3d8817e4Smiod @} 636*3d8817e4Smiod 637*3d8817e4Smiod@end example 638*3d8817e4Smiod 639*3d8817e4Smiod@node section prototypes, , typedef asection, Sections 640*3d8817e4Smiod@subsection Section prototypes 641*3d8817e4SmiodThese are the functions exported by the section handling part of BFD. 642*3d8817e4Smiod 643*3d8817e4Smiod@findex bfd_section_list_clear 644*3d8817e4Smiod@subsubsection @code{bfd_section_list_clear} 645*3d8817e4Smiod@strong{Synopsis} 646*3d8817e4Smiod@example 647*3d8817e4Smiodvoid bfd_section_list_clear (bfd *); 648*3d8817e4Smiod@end example 649*3d8817e4Smiod@strong{Description}@* 650*3d8817e4SmiodClears the section list, and also resets the section count and 651*3d8817e4Smiodhash table entries. 652*3d8817e4Smiod 653*3d8817e4Smiod@findex bfd_get_section_by_name 654*3d8817e4Smiod@subsubsection @code{bfd_get_section_by_name} 655*3d8817e4Smiod@strong{Synopsis} 656*3d8817e4Smiod@example 657*3d8817e4Smiodasection *bfd_get_section_by_name (bfd *abfd, const char *name); 658*3d8817e4Smiod@end example 659*3d8817e4Smiod@strong{Description}@* 660*3d8817e4SmiodRun through @var{abfd} and return the one of the 661*3d8817e4Smiod@code{asection}s whose name matches @var{name}, otherwise @code{NULL}. 662*3d8817e4Smiod@xref{Sections}, for more information. 663*3d8817e4Smiod 664*3d8817e4SmiodThis should only be used in special cases; the normal way to process 665*3d8817e4Smiodall sections of a given name is to use @code{bfd_map_over_sections} and 666*3d8817e4Smiod@code{strcmp} on the name (or better yet, base it on the section flags 667*3d8817e4Smiodor something else) for each section. 668*3d8817e4Smiod 669*3d8817e4Smiod@findex bfd_get_section_by_name_if 670*3d8817e4Smiod@subsubsection @code{bfd_get_section_by_name_if} 671*3d8817e4Smiod@strong{Synopsis} 672*3d8817e4Smiod@example 673*3d8817e4Smiodasection *bfd_get_section_by_name_if 674*3d8817e4Smiod (bfd *abfd, 675*3d8817e4Smiod const char *name, 676*3d8817e4Smiod bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj), 677*3d8817e4Smiod void *obj); 678*3d8817e4Smiod@end example 679*3d8817e4Smiod@strong{Description}@* 680*3d8817e4SmiodCall the provided function @var{func} for each section 681*3d8817e4Smiodattached to the BFD @var{abfd} whose name matches @var{name}, 682*3d8817e4Smiodpassing @var{obj} as an argument. The function will be called 683*3d8817e4Smiodas if by 684*3d8817e4Smiod 685*3d8817e4Smiod@example 686*3d8817e4Smiod func (abfd, the_section, obj); 687*3d8817e4Smiod@end example 688*3d8817e4Smiod 689*3d8817e4SmiodIt returns the first section for which @var{func} returns true, 690*3d8817e4Smiodotherwise @code{NULL}. 691*3d8817e4Smiod 692*3d8817e4Smiod@findex bfd_get_unique_section_name 693*3d8817e4Smiod@subsubsection @code{bfd_get_unique_section_name} 694*3d8817e4Smiod@strong{Synopsis} 695*3d8817e4Smiod@example 696*3d8817e4Smiodchar *bfd_get_unique_section_name 697*3d8817e4Smiod (bfd *abfd, const char *templat, int *count); 698*3d8817e4Smiod@end example 699*3d8817e4Smiod@strong{Description}@* 700*3d8817e4SmiodInvent a section name that is unique in @var{abfd} by tacking 701*3d8817e4Smioda dot and a digit suffix onto the original @var{templat}. If 702*3d8817e4Smiod@var{count} is non-NULL, then it specifies the first number 703*3d8817e4Smiodtried as a suffix to generate a unique name. The value 704*3d8817e4Smiodpointed to by @var{count} will be incremented in this case. 705*3d8817e4Smiod 706*3d8817e4Smiod@findex bfd_make_section_old_way 707*3d8817e4Smiod@subsubsection @code{bfd_make_section_old_way} 708*3d8817e4Smiod@strong{Synopsis} 709*3d8817e4Smiod@example 710*3d8817e4Smiodasection *bfd_make_section_old_way (bfd *abfd, const char *name); 711*3d8817e4Smiod@end example 712*3d8817e4Smiod@strong{Description}@* 713*3d8817e4SmiodCreate a new empty section called @var{name} 714*3d8817e4Smiodand attach it to the end of the chain of sections for the 715*3d8817e4SmiodBFD @var{abfd}. An attempt to create a section with a name which 716*3d8817e4Smiodis already in use returns its pointer without changing the 717*3d8817e4Smiodsection chain. 718*3d8817e4Smiod 719*3d8817e4SmiodIt has the funny name since this is the way it used to be 720*3d8817e4Smiodbefore it was rewritten.... 721*3d8817e4Smiod 722*3d8817e4SmiodPossible errors are: 723*3d8817e4Smiod@itemize @bullet 724*3d8817e4Smiod 725*3d8817e4Smiod@item 726*3d8817e4Smiod@code{bfd_error_invalid_operation} - 727*3d8817e4SmiodIf output has already started for this BFD. 728*3d8817e4Smiod@item 729*3d8817e4Smiod@code{bfd_error_no_memory} - 730*3d8817e4SmiodIf memory allocation fails. 731*3d8817e4Smiod@end itemize 732*3d8817e4Smiod 733*3d8817e4Smiod@findex bfd_make_section_anyway_with_flags 734*3d8817e4Smiod@subsubsection @code{bfd_make_section_anyway_with_flags} 735*3d8817e4Smiod@strong{Synopsis} 736*3d8817e4Smiod@example 737*3d8817e4Smiodasection *bfd_make_section_anyway_with_flags 738*3d8817e4Smiod (bfd *abfd, const char *name, flagword flags); 739*3d8817e4Smiod@end example 740*3d8817e4Smiod@strong{Description}@* 741*3d8817e4SmiodCreate a new empty section called @var{name} and attach it to the end of 742*3d8817e4Smiodthe chain of sections for @var{abfd}. Create a new section even if there 743*3d8817e4Smiodis already a section with that name. Also set the attributes of the 744*3d8817e4Smiodnew section to the value @var{flags}. 745*3d8817e4Smiod 746*3d8817e4SmiodReturn @code{NULL} and set @code{bfd_error} on error; possible errors are: 747*3d8817e4Smiod@itemize @bullet 748*3d8817e4Smiod 749*3d8817e4Smiod@item 750*3d8817e4Smiod@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}. 751*3d8817e4Smiod@item 752*3d8817e4Smiod@code{bfd_error_no_memory} - If memory allocation fails. 753*3d8817e4Smiod@end itemize 754*3d8817e4Smiod 755*3d8817e4Smiod@findex bfd_make_section_anyway 756*3d8817e4Smiod@subsubsection @code{bfd_make_section_anyway} 757*3d8817e4Smiod@strong{Synopsis} 758*3d8817e4Smiod@example 759*3d8817e4Smiodasection *bfd_make_section_anyway (bfd *abfd, const char *name); 760*3d8817e4Smiod@end example 761*3d8817e4Smiod@strong{Description}@* 762*3d8817e4SmiodCreate a new empty section called @var{name} and attach it to the end of 763*3d8817e4Smiodthe chain of sections for @var{abfd}. Create a new section even if there 764*3d8817e4Smiodis already a section with that name. 765*3d8817e4Smiod 766*3d8817e4SmiodReturn @code{NULL} and set @code{bfd_error} on error; possible errors are: 767*3d8817e4Smiod@itemize @bullet 768*3d8817e4Smiod 769*3d8817e4Smiod@item 770*3d8817e4Smiod@code{bfd_error_invalid_operation} - If output has already started for @var{abfd}. 771*3d8817e4Smiod@item 772*3d8817e4Smiod@code{bfd_error_no_memory} - If memory allocation fails. 773*3d8817e4Smiod@end itemize 774*3d8817e4Smiod 775*3d8817e4Smiod@findex bfd_make_section_with_flags 776*3d8817e4Smiod@subsubsection @code{bfd_make_section_with_flags} 777*3d8817e4Smiod@strong{Synopsis} 778*3d8817e4Smiod@example 779*3d8817e4Smiodasection *bfd_make_section_with_flags 780*3d8817e4Smiod (bfd *, const char *name, flagword flags); 781*3d8817e4Smiod@end example 782*3d8817e4Smiod@strong{Description}@* 783*3d8817e4SmiodLike @code{bfd_make_section_anyway}, but return @code{NULL} (without calling 784*3d8817e4Smiodbfd_set_error ()) without changing the section chain if there is already a 785*3d8817e4Smiodsection named @var{name}. Also set the attributes of the new section to 786*3d8817e4Smiodthe value @var{flags}. If there is an error, return @code{NULL} and set 787*3d8817e4Smiod@code{bfd_error}. 788*3d8817e4Smiod 789*3d8817e4Smiod@findex bfd_make_section 790*3d8817e4Smiod@subsubsection @code{bfd_make_section} 791*3d8817e4Smiod@strong{Synopsis} 792*3d8817e4Smiod@example 793*3d8817e4Smiodasection *bfd_make_section (bfd *, const char *name); 794*3d8817e4Smiod@end example 795*3d8817e4Smiod@strong{Description}@* 796*3d8817e4SmiodLike @code{bfd_make_section_anyway}, but return @code{NULL} (without calling 797*3d8817e4Smiodbfd_set_error ()) without changing the section chain if there is already a 798*3d8817e4Smiodsection named @var{name}. If there is an error, return @code{NULL} and set 799*3d8817e4Smiod@code{bfd_error}. 800*3d8817e4Smiod 801*3d8817e4Smiod@findex bfd_set_section_flags 802*3d8817e4Smiod@subsubsection @code{bfd_set_section_flags} 803*3d8817e4Smiod@strong{Synopsis} 804*3d8817e4Smiod@example 805*3d8817e4Smiodbfd_boolean bfd_set_section_flags 806*3d8817e4Smiod (bfd *abfd, asection *sec, flagword flags); 807*3d8817e4Smiod@end example 808*3d8817e4Smiod@strong{Description}@* 809*3d8817e4SmiodSet the attributes of the section @var{sec} in the BFD 810*3d8817e4Smiod@var{abfd} to the value @var{flags}. Return @code{TRUE} on success, 811*3d8817e4Smiod@code{FALSE} on error. Possible error returns are: 812*3d8817e4Smiod 813*3d8817e4Smiod@itemize @bullet 814*3d8817e4Smiod 815*3d8817e4Smiod@item 816*3d8817e4Smiod@code{bfd_error_invalid_operation} - 817*3d8817e4SmiodThe section cannot have one or more of the attributes 818*3d8817e4Smiodrequested. For example, a .bss section in @code{a.out} may not 819*3d8817e4Smiodhave the @code{SEC_HAS_CONTENTS} field set. 820*3d8817e4Smiod@end itemize 821*3d8817e4Smiod 822*3d8817e4Smiod@findex bfd_map_over_sections 823*3d8817e4Smiod@subsubsection @code{bfd_map_over_sections} 824*3d8817e4Smiod@strong{Synopsis} 825*3d8817e4Smiod@example 826*3d8817e4Smiodvoid bfd_map_over_sections 827*3d8817e4Smiod (bfd *abfd, 828*3d8817e4Smiod void (*func) (bfd *abfd, asection *sect, void *obj), 829*3d8817e4Smiod void *obj); 830*3d8817e4Smiod@end example 831*3d8817e4Smiod@strong{Description}@* 832*3d8817e4SmiodCall the provided function @var{func} for each section 833*3d8817e4Smiodattached to the BFD @var{abfd}, passing @var{obj} as an 834*3d8817e4Smiodargument. The function will be called as if by 835*3d8817e4Smiod 836*3d8817e4Smiod@example 837*3d8817e4Smiod func (abfd, the_section, obj); 838*3d8817e4Smiod@end example 839*3d8817e4Smiod 840*3d8817e4SmiodThis is the preferred method for iterating over sections; an 841*3d8817e4Smiodalternative would be to use a loop: 842*3d8817e4Smiod 843*3d8817e4Smiod@example 844*3d8817e4Smiod section *p; 845*3d8817e4Smiod for (p = abfd->sections; p != NULL; p = p->next) 846*3d8817e4Smiod func (abfd, p, ...) 847*3d8817e4Smiod@end example 848*3d8817e4Smiod 849*3d8817e4Smiod@findex bfd_sections_find_if 850*3d8817e4Smiod@subsubsection @code{bfd_sections_find_if} 851*3d8817e4Smiod@strong{Synopsis} 852*3d8817e4Smiod@example 853*3d8817e4Smiodasection *bfd_sections_find_if 854*3d8817e4Smiod (bfd *abfd, 855*3d8817e4Smiod bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj), 856*3d8817e4Smiod void *obj); 857*3d8817e4Smiod@end example 858*3d8817e4Smiod@strong{Description}@* 859*3d8817e4SmiodCall the provided function @var{operation} for each section 860*3d8817e4Smiodattached to the BFD @var{abfd}, passing @var{obj} as an 861*3d8817e4Smiodargument. The function will be called as if by 862*3d8817e4Smiod 863*3d8817e4Smiod@example 864*3d8817e4Smiod operation (abfd, the_section, obj); 865*3d8817e4Smiod@end example 866*3d8817e4Smiod 867*3d8817e4SmiodIt returns the first section for which @var{operation} returns true. 868*3d8817e4Smiod 869*3d8817e4Smiod@findex bfd_set_section_size 870*3d8817e4Smiod@subsubsection @code{bfd_set_section_size} 871*3d8817e4Smiod@strong{Synopsis} 872*3d8817e4Smiod@example 873*3d8817e4Smiodbfd_boolean bfd_set_section_size 874*3d8817e4Smiod (bfd *abfd, asection *sec, bfd_size_type val); 875*3d8817e4Smiod@end example 876*3d8817e4Smiod@strong{Description}@* 877*3d8817e4SmiodSet @var{sec} to the size @var{val}. If the operation is 878*3d8817e4Smiodok, then @code{TRUE} is returned, else @code{FALSE}. 879*3d8817e4Smiod 880*3d8817e4SmiodPossible error returns: 881*3d8817e4Smiod@itemize @bullet 882*3d8817e4Smiod 883*3d8817e4Smiod@item 884*3d8817e4Smiod@code{bfd_error_invalid_operation} - 885*3d8817e4SmiodWriting has started to the BFD, so setting the size is invalid. 886*3d8817e4Smiod@end itemize 887*3d8817e4Smiod 888*3d8817e4Smiod@findex bfd_set_section_contents 889*3d8817e4Smiod@subsubsection @code{bfd_set_section_contents} 890*3d8817e4Smiod@strong{Synopsis} 891*3d8817e4Smiod@example 892*3d8817e4Smiodbfd_boolean bfd_set_section_contents 893*3d8817e4Smiod (bfd *abfd, asection *section, const void *data, 894*3d8817e4Smiod file_ptr offset, bfd_size_type count); 895*3d8817e4Smiod@end example 896*3d8817e4Smiod@strong{Description}@* 897*3d8817e4SmiodSets the contents of the section @var{section} in BFD 898*3d8817e4Smiod@var{abfd} to the data starting in memory at @var{data}. The 899*3d8817e4Smioddata is written to the output section starting at offset 900*3d8817e4Smiod@var{offset} for @var{count} octets. 901*3d8817e4Smiod 902*3d8817e4SmiodNormally @code{TRUE} is returned, else @code{FALSE}. Possible error 903*3d8817e4Smiodreturns are: 904*3d8817e4Smiod@itemize @bullet 905*3d8817e4Smiod 906*3d8817e4Smiod@item 907*3d8817e4Smiod@code{bfd_error_no_contents} - 908*3d8817e4SmiodThe output section does not have the @code{SEC_HAS_CONTENTS} 909*3d8817e4Smiodattribute, so nothing can be written to it. 910*3d8817e4Smiod@item 911*3d8817e4Smiodand some more too 912*3d8817e4Smiod@end itemize 913*3d8817e4SmiodThis routine is front end to the back end function 914*3d8817e4Smiod@code{_bfd_set_section_contents}. 915*3d8817e4Smiod 916*3d8817e4Smiod@findex bfd_get_section_contents 917*3d8817e4Smiod@subsubsection @code{bfd_get_section_contents} 918*3d8817e4Smiod@strong{Synopsis} 919*3d8817e4Smiod@example 920*3d8817e4Smiodbfd_boolean bfd_get_section_contents 921*3d8817e4Smiod (bfd *abfd, asection *section, void *location, file_ptr offset, 922*3d8817e4Smiod bfd_size_type count); 923*3d8817e4Smiod@end example 924*3d8817e4Smiod@strong{Description}@* 925*3d8817e4SmiodRead data from @var{section} in BFD @var{abfd} 926*3d8817e4Smiodinto memory starting at @var{location}. The data is read at an 927*3d8817e4Smiodoffset of @var{offset} from the start of the input section, 928*3d8817e4Smiodand is read for @var{count} bytes. 929*3d8817e4Smiod 930*3d8817e4SmiodIf the contents of a constructor with the @code{SEC_CONSTRUCTOR} 931*3d8817e4Smiodflag set are requested or if the section does not have the 932*3d8817e4Smiod@code{SEC_HAS_CONTENTS} flag set, then the @var{location} is filled 933*3d8817e4Smiodwith zeroes. If no errors occur, @code{TRUE} is returned, else 934*3d8817e4Smiod@code{FALSE}. 935*3d8817e4Smiod 936*3d8817e4Smiod@findex bfd_malloc_and_get_section 937*3d8817e4Smiod@subsubsection @code{bfd_malloc_and_get_section} 938*3d8817e4Smiod@strong{Synopsis} 939*3d8817e4Smiod@example 940*3d8817e4Smiodbfd_boolean bfd_malloc_and_get_section 941*3d8817e4Smiod (bfd *abfd, asection *section, bfd_byte **buf); 942*3d8817e4Smiod@end example 943*3d8817e4Smiod@strong{Description}@* 944*3d8817e4SmiodRead all data from @var{section} in BFD @var{abfd} 945*3d8817e4Smiodinto a buffer, *@var{buf}, malloc'd by this function. 946*3d8817e4Smiod 947*3d8817e4Smiod@findex bfd_copy_private_section_data 948*3d8817e4Smiod@subsubsection @code{bfd_copy_private_section_data} 949*3d8817e4Smiod@strong{Synopsis} 950*3d8817e4Smiod@example 951*3d8817e4Smiodbfd_boolean bfd_copy_private_section_data 952*3d8817e4Smiod (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); 953*3d8817e4Smiod@end example 954*3d8817e4Smiod@strong{Description}@* 955*3d8817e4SmiodCopy private section information from @var{isec} in the BFD 956*3d8817e4Smiod@var{ibfd} to the section @var{osec} in the BFD @var{obfd}. 957*3d8817e4SmiodReturn @code{TRUE} on success, @code{FALSE} on error. Possible error 958*3d8817e4Smiodreturns are: 959*3d8817e4Smiod 960*3d8817e4Smiod@itemize @bullet 961*3d8817e4Smiod 962*3d8817e4Smiod@item 963*3d8817e4Smiod@code{bfd_error_no_memory} - 964*3d8817e4SmiodNot enough memory exists to create private data for @var{osec}. 965*3d8817e4Smiod@end itemize 966*3d8817e4Smiod@example 967*3d8817e4Smiod#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ 968*3d8817e4Smiod BFD_SEND (obfd, _bfd_copy_private_section_data, \ 969*3d8817e4Smiod (ibfd, isection, obfd, osection)) 970*3d8817e4Smiod@end example 971*3d8817e4Smiod 972*3d8817e4Smiod@findex bfd_generic_is_group_section 973*3d8817e4Smiod@subsubsection @code{bfd_generic_is_group_section} 974*3d8817e4Smiod@strong{Synopsis} 975*3d8817e4Smiod@example 976*3d8817e4Smiodbfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec); 977*3d8817e4Smiod@end example 978*3d8817e4Smiod@strong{Description}@* 979*3d8817e4SmiodReturns TRUE if @var{sec} is a member of a group. 980*3d8817e4Smiod 981*3d8817e4Smiod@findex bfd_generic_discard_group 982*3d8817e4Smiod@subsubsection @code{bfd_generic_discard_group} 983*3d8817e4Smiod@strong{Synopsis} 984*3d8817e4Smiod@example 985*3d8817e4Smiodbfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group); 986*3d8817e4Smiod@end example 987*3d8817e4Smiod@strong{Description}@* 988*3d8817e4SmiodRemove all members of @var{group} from the output. 989*3d8817e4Smiod 990