15796c8dcSSimon Schubert /* Object file "section" support for the BFD library. 25796c8dcSSimon Schubert Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3*cf7f2e2dSJohn Marino 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 45796c8dcSSimon Schubert Free Software Foundation, Inc. 55796c8dcSSimon Schubert Written by Cygnus Support. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This file is part of BFD, the Binary File Descriptor library. 85796c8dcSSimon Schubert 95796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 105796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 115796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 125796c8dcSSimon Schubert (at your option) any later version. 135796c8dcSSimon Schubert 145796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 155796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 165796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 175796c8dcSSimon Schubert GNU General Public License for more details. 185796c8dcSSimon Schubert 195796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 205796c8dcSSimon Schubert along with this program; if not, write to the Free Software 215796c8dcSSimon Schubert Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 225796c8dcSSimon Schubert MA 02110-1301, USA. */ 235796c8dcSSimon Schubert 245796c8dcSSimon Schubert /* 255796c8dcSSimon Schubert SECTION 265796c8dcSSimon Schubert Sections 275796c8dcSSimon Schubert 285796c8dcSSimon Schubert The raw data contained within a BFD is maintained through the 295796c8dcSSimon Schubert section abstraction. A single BFD may have any number of 305796c8dcSSimon Schubert sections. It keeps hold of them by pointing to the first; 315796c8dcSSimon Schubert each one points to the next in the list. 325796c8dcSSimon Schubert 335796c8dcSSimon Schubert Sections are supported in BFD in <<section.c>>. 345796c8dcSSimon Schubert 355796c8dcSSimon Schubert @menu 365796c8dcSSimon Schubert @* Section Input:: 375796c8dcSSimon Schubert @* Section Output:: 385796c8dcSSimon Schubert @* typedef asection:: 395796c8dcSSimon Schubert @* section prototypes:: 405796c8dcSSimon Schubert @end menu 415796c8dcSSimon Schubert 425796c8dcSSimon Schubert INODE 435796c8dcSSimon Schubert Section Input, Section Output, Sections, Sections 445796c8dcSSimon Schubert SUBSECTION 455796c8dcSSimon Schubert Section input 465796c8dcSSimon Schubert 475796c8dcSSimon Schubert When a BFD is opened for reading, the section structures are 485796c8dcSSimon Schubert created and attached to the BFD. 495796c8dcSSimon Schubert 505796c8dcSSimon Schubert Each section has a name which describes the section in the 515796c8dcSSimon Schubert outside world---for example, <<a.out>> would contain at least 525796c8dcSSimon Schubert three sections, called <<.text>>, <<.data>> and <<.bss>>. 535796c8dcSSimon Schubert 545796c8dcSSimon Schubert Names need not be unique; for example a COFF file may have several 555796c8dcSSimon Schubert sections named <<.data>>. 565796c8dcSSimon Schubert 575796c8dcSSimon Schubert Sometimes a BFD will contain more than the ``natural'' number of 585796c8dcSSimon Schubert sections. A back end may attach other sections containing 595796c8dcSSimon Schubert constructor data, or an application may add a section (using 605796c8dcSSimon Schubert <<bfd_make_section>>) to the sections attached to an already open 615796c8dcSSimon Schubert BFD. For example, the linker creates an extra section 625796c8dcSSimon Schubert <<COMMON>> for each input file's BFD to hold information about 635796c8dcSSimon Schubert common storage. 645796c8dcSSimon Schubert 655796c8dcSSimon Schubert The raw data is not necessarily read in when 665796c8dcSSimon Schubert the section descriptor is created. Some targets may leave the 675796c8dcSSimon Schubert data in place until a <<bfd_get_section_contents>> call is 685796c8dcSSimon Schubert made. Other back ends may read in all the data at once. For 695796c8dcSSimon Schubert example, an S-record file has to be read once to determine the 705796c8dcSSimon Schubert size of the data. An IEEE-695 file doesn't contain raw data in 715796c8dcSSimon Schubert sections, but data and relocation expressions intermixed, so 725796c8dcSSimon Schubert the data area has to be parsed to get out the data and 735796c8dcSSimon Schubert relocations. 745796c8dcSSimon Schubert 755796c8dcSSimon Schubert INODE 765796c8dcSSimon Schubert Section Output, typedef asection, Section Input, Sections 775796c8dcSSimon Schubert 785796c8dcSSimon Schubert SUBSECTION 795796c8dcSSimon Schubert Section output 805796c8dcSSimon Schubert 815796c8dcSSimon Schubert To write a new object style BFD, the various sections to be 825796c8dcSSimon Schubert written have to be created. They are attached to the BFD in 835796c8dcSSimon Schubert the same way as input sections; data is written to the 845796c8dcSSimon Schubert sections using <<bfd_set_section_contents>>. 855796c8dcSSimon Schubert 865796c8dcSSimon Schubert Any program that creates or combines sections (e.g., the assembler 875796c8dcSSimon Schubert and linker) must use the <<asection>> fields <<output_section>> and 885796c8dcSSimon Schubert <<output_offset>> to indicate the file sections to which each 895796c8dcSSimon Schubert section must be written. (If the section is being created from 905796c8dcSSimon Schubert scratch, <<output_section>> should probably point to the section 915796c8dcSSimon Schubert itself and <<output_offset>> should probably be zero.) 925796c8dcSSimon Schubert 935796c8dcSSimon Schubert The data to be written comes from input sections attached 945796c8dcSSimon Schubert (via <<output_section>> pointers) to 955796c8dcSSimon Schubert the output sections. The output section structure can be 965796c8dcSSimon Schubert considered a filter for the input section: the output section 975796c8dcSSimon Schubert determines the vma of the output data and the name, but the 985796c8dcSSimon Schubert input section determines the offset into the output section of 995796c8dcSSimon Schubert the data to be written. 1005796c8dcSSimon Schubert 1015796c8dcSSimon Schubert E.g., to create a section "O", starting at 0x100, 0x123 long, 1025796c8dcSSimon Schubert containing two subsections, "A" at offset 0x0 (i.e., at vma 1035796c8dcSSimon Schubert 0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the <<asection>> 1045796c8dcSSimon Schubert structures would look like: 1055796c8dcSSimon Schubert 1065796c8dcSSimon Schubert | section name "A" 1075796c8dcSSimon Schubert | output_offset 0x00 1085796c8dcSSimon Schubert | size 0x20 1095796c8dcSSimon Schubert | output_section -----------> section name "O" 1105796c8dcSSimon Schubert | | vma 0x100 1115796c8dcSSimon Schubert | section name "B" | size 0x123 1125796c8dcSSimon Schubert | output_offset 0x20 | 1135796c8dcSSimon Schubert | size 0x103 | 1145796c8dcSSimon Schubert | output_section --------| 1155796c8dcSSimon Schubert 1165796c8dcSSimon Schubert SUBSECTION 1175796c8dcSSimon Schubert Link orders 1185796c8dcSSimon Schubert 1195796c8dcSSimon Schubert The data within a section is stored in a @dfn{link_order}. 1205796c8dcSSimon Schubert These are much like the fixups in <<gas>>. The link_order 1215796c8dcSSimon Schubert abstraction allows a section to grow and shrink within itself. 1225796c8dcSSimon Schubert 1235796c8dcSSimon Schubert A link_order knows how big it is, and which is the next 1245796c8dcSSimon Schubert link_order and where the raw data for it is; it also points to 1255796c8dcSSimon Schubert a list of relocations which apply to it. 1265796c8dcSSimon Schubert 1275796c8dcSSimon Schubert The link_order is used by the linker to perform relaxing on 1285796c8dcSSimon Schubert final code. The compiler creates code which is as big as 1295796c8dcSSimon Schubert necessary to make it work without relaxing, and the user can 1305796c8dcSSimon Schubert select whether to relax. Sometimes relaxing takes a lot of 1315796c8dcSSimon Schubert time. The linker runs around the relocations to see if any 1325796c8dcSSimon Schubert are attached to data which can be shrunk, if so it does it on 1335796c8dcSSimon Schubert a link_order by link_order basis. 1345796c8dcSSimon Schubert 1355796c8dcSSimon Schubert */ 1365796c8dcSSimon Schubert 1375796c8dcSSimon Schubert #include "sysdep.h" 1385796c8dcSSimon Schubert #include "bfd.h" 1395796c8dcSSimon Schubert #include "libbfd.h" 1405796c8dcSSimon Schubert #include "bfdlink.h" 1415796c8dcSSimon Schubert 1425796c8dcSSimon Schubert /* 1435796c8dcSSimon Schubert DOCDD 1445796c8dcSSimon Schubert INODE 1455796c8dcSSimon Schubert typedef asection, section prototypes, Section Output, Sections 1465796c8dcSSimon Schubert SUBSECTION 1475796c8dcSSimon Schubert typedef asection 1485796c8dcSSimon Schubert 1495796c8dcSSimon Schubert Here is the section structure: 1505796c8dcSSimon Schubert 1515796c8dcSSimon Schubert CODE_FRAGMENT 1525796c8dcSSimon Schubert . 1535796c8dcSSimon Schubert .typedef struct bfd_section 1545796c8dcSSimon Schubert .{ 1555796c8dcSSimon Schubert . {* The name of the section; the name isn't a copy, the pointer is 1565796c8dcSSimon Schubert . the same as that passed to bfd_make_section. *} 1575796c8dcSSimon Schubert . const char *name; 1585796c8dcSSimon Schubert . 1595796c8dcSSimon Schubert . {* A unique sequence number. *} 1605796c8dcSSimon Schubert . int id; 1615796c8dcSSimon Schubert . 1625796c8dcSSimon Schubert . {* Which section in the bfd; 0..n-1 as sections are created in a bfd. *} 1635796c8dcSSimon Schubert . int index; 1645796c8dcSSimon Schubert . 1655796c8dcSSimon Schubert . {* The next section in the list belonging to the BFD, or NULL. *} 1665796c8dcSSimon Schubert . struct bfd_section *next; 1675796c8dcSSimon Schubert . 1685796c8dcSSimon Schubert . {* The previous section in the list belonging to the BFD, or NULL. *} 1695796c8dcSSimon Schubert . struct bfd_section *prev; 1705796c8dcSSimon Schubert . 1715796c8dcSSimon Schubert . {* The field flags contains attributes of the section. Some 1725796c8dcSSimon Schubert . flags are read in from the object file, and some are 1735796c8dcSSimon Schubert . synthesized from other information. *} 1745796c8dcSSimon Schubert . flagword flags; 1755796c8dcSSimon Schubert . 1765796c8dcSSimon Schubert .#define SEC_NO_FLAGS 0x000 1775796c8dcSSimon Schubert . 1785796c8dcSSimon Schubert . {* Tells the OS to allocate space for this section when loading. 1795796c8dcSSimon Schubert . This is clear for a section containing debug information only. *} 1805796c8dcSSimon Schubert .#define SEC_ALLOC 0x001 1815796c8dcSSimon Schubert . 1825796c8dcSSimon Schubert . {* Tells the OS to load the section from the file when loading. 1835796c8dcSSimon Schubert . This is clear for a .bss section. *} 1845796c8dcSSimon Schubert .#define SEC_LOAD 0x002 1855796c8dcSSimon Schubert . 1865796c8dcSSimon Schubert . {* The section contains data still to be relocated, so there is 1875796c8dcSSimon Schubert . some relocation information too. *} 1885796c8dcSSimon Schubert .#define SEC_RELOC 0x004 1895796c8dcSSimon Schubert . 1905796c8dcSSimon Schubert . {* A signal to the OS that the section contains read only data. *} 1915796c8dcSSimon Schubert .#define SEC_READONLY 0x008 1925796c8dcSSimon Schubert . 1935796c8dcSSimon Schubert . {* The section contains code only. *} 1945796c8dcSSimon Schubert .#define SEC_CODE 0x010 1955796c8dcSSimon Schubert . 1965796c8dcSSimon Schubert . {* The section contains data only. *} 1975796c8dcSSimon Schubert .#define SEC_DATA 0x020 1985796c8dcSSimon Schubert . 1995796c8dcSSimon Schubert . {* The section will reside in ROM. *} 2005796c8dcSSimon Schubert .#define SEC_ROM 0x040 2015796c8dcSSimon Schubert . 2025796c8dcSSimon Schubert . {* The section contains constructor information. This section 2035796c8dcSSimon Schubert . type is used by the linker to create lists of constructors and 2045796c8dcSSimon Schubert . destructors used by <<g++>>. When a back end sees a symbol 2055796c8dcSSimon Schubert . which should be used in a constructor list, it creates a new 2065796c8dcSSimon Schubert . section for the type of name (e.g., <<__CTOR_LIST__>>), attaches 2075796c8dcSSimon Schubert . the symbol to it, and builds a relocation. To build the lists 2085796c8dcSSimon Schubert . of constructors, all the linker has to do is catenate all the 2095796c8dcSSimon Schubert . sections called <<__CTOR_LIST__>> and relocate the data 2105796c8dcSSimon Schubert . contained within - exactly the operations it would peform on 2115796c8dcSSimon Schubert . standard data. *} 2125796c8dcSSimon Schubert .#define SEC_CONSTRUCTOR 0x080 2135796c8dcSSimon Schubert . 2145796c8dcSSimon Schubert . {* The section has contents - a data section could be 2155796c8dcSSimon Schubert . <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be 2165796c8dcSSimon Schubert . <<SEC_HAS_CONTENTS>> *} 2175796c8dcSSimon Schubert .#define SEC_HAS_CONTENTS 0x100 2185796c8dcSSimon Schubert . 2195796c8dcSSimon Schubert . {* An instruction to the linker to not output the section 2205796c8dcSSimon Schubert . even if it has information which would normally be written. *} 2215796c8dcSSimon Schubert .#define SEC_NEVER_LOAD 0x200 2225796c8dcSSimon Schubert . 2235796c8dcSSimon Schubert . {* The section contains thread local data. *} 2245796c8dcSSimon Schubert .#define SEC_THREAD_LOCAL 0x400 2255796c8dcSSimon Schubert . 2265796c8dcSSimon Schubert . {* The section has GOT references. This flag is only for the 2275796c8dcSSimon Schubert . linker, and is currently only used by the elf32-hppa back end. 2285796c8dcSSimon Schubert . It will be set if global offset table references were detected 2295796c8dcSSimon Schubert . in this section, which indicate to the linker that the section 2305796c8dcSSimon Schubert . contains PIC code, and must be handled specially when doing a 2315796c8dcSSimon Schubert . static link. *} 2325796c8dcSSimon Schubert .#define SEC_HAS_GOT_REF 0x800 2335796c8dcSSimon Schubert . 2345796c8dcSSimon Schubert . {* The section contains common symbols (symbols may be defined 2355796c8dcSSimon Schubert . multiple times, the value of a symbol is the amount of 2365796c8dcSSimon Schubert . space it requires, and the largest symbol value is the one 2375796c8dcSSimon Schubert . used). Most targets have exactly one of these (which we 2385796c8dcSSimon Schubert . translate to bfd_com_section_ptr), but ECOFF has two. *} 2395796c8dcSSimon Schubert .#define SEC_IS_COMMON 0x1000 2405796c8dcSSimon Schubert . 2415796c8dcSSimon Schubert . {* The section contains only debugging information. For 2425796c8dcSSimon Schubert . example, this is set for ELF .debug and .stab sections. 2435796c8dcSSimon Schubert . strip tests this flag to see if a section can be 2445796c8dcSSimon Schubert . discarded. *} 2455796c8dcSSimon Schubert .#define SEC_DEBUGGING 0x2000 2465796c8dcSSimon Schubert . 2475796c8dcSSimon Schubert . {* The contents of this section are held in memory pointed to 2485796c8dcSSimon Schubert . by the contents field. This is checked by bfd_get_section_contents, 2495796c8dcSSimon Schubert . and the data is retrieved from memory if appropriate. *} 2505796c8dcSSimon Schubert .#define SEC_IN_MEMORY 0x4000 2515796c8dcSSimon Schubert . 2525796c8dcSSimon Schubert . {* The contents of this section are to be excluded by the 2535796c8dcSSimon Schubert . linker for executable and shared objects unless those 2545796c8dcSSimon Schubert . objects are to be further relocated. *} 2555796c8dcSSimon Schubert .#define SEC_EXCLUDE 0x8000 2565796c8dcSSimon Schubert . 2575796c8dcSSimon Schubert . {* The contents of this section are to be sorted based on the sum of 2585796c8dcSSimon Schubert . the symbol and addend values specified by the associated relocation 2595796c8dcSSimon Schubert . entries. Entries without associated relocation entries will be 2605796c8dcSSimon Schubert . appended to the end of the section in an unspecified order. *} 2615796c8dcSSimon Schubert .#define SEC_SORT_ENTRIES 0x10000 2625796c8dcSSimon Schubert . 2635796c8dcSSimon Schubert . {* When linking, duplicate sections of the same name should be 2645796c8dcSSimon Schubert . discarded, rather than being combined into a single section as 2655796c8dcSSimon Schubert . is usually done. This is similar to how common symbols are 2665796c8dcSSimon Schubert . handled. See SEC_LINK_DUPLICATES below. *} 2675796c8dcSSimon Schubert .#define SEC_LINK_ONCE 0x20000 2685796c8dcSSimon Schubert . 2695796c8dcSSimon Schubert . {* If SEC_LINK_ONCE is set, this bitfield describes how the linker 2705796c8dcSSimon Schubert . should handle duplicate sections. *} 2715796c8dcSSimon Schubert .#define SEC_LINK_DUPLICATES 0xc0000 2725796c8dcSSimon Schubert . 2735796c8dcSSimon Schubert . {* This value for SEC_LINK_DUPLICATES means that duplicate 2745796c8dcSSimon Schubert . sections with the same name should simply be discarded. *} 2755796c8dcSSimon Schubert .#define SEC_LINK_DUPLICATES_DISCARD 0x0 2765796c8dcSSimon Schubert . 2775796c8dcSSimon Schubert . {* This value for SEC_LINK_DUPLICATES means that the linker 2785796c8dcSSimon Schubert . should warn if there are any duplicate sections, although 2795796c8dcSSimon Schubert . it should still only link one copy. *} 2805796c8dcSSimon Schubert .#define SEC_LINK_DUPLICATES_ONE_ONLY 0x40000 2815796c8dcSSimon Schubert . 2825796c8dcSSimon Schubert . {* This value for SEC_LINK_DUPLICATES means that the linker 2835796c8dcSSimon Schubert . should warn if any duplicate sections are a different size. *} 2845796c8dcSSimon Schubert .#define SEC_LINK_DUPLICATES_SAME_SIZE 0x80000 2855796c8dcSSimon Schubert . 2865796c8dcSSimon Schubert . {* This value for SEC_LINK_DUPLICATES means that the linker 2875796c8dcSSimon Schubert . should warn if any duplicate sections contain different 2885796c8dcSSimon Schubert . contents. *} 2895796c8dcSSimon Schubert .#define SEC_LINK_DUPLICATES_SAME_CONTENTS \ 2905796c8dcSSimon Schubert . (SEC_LINK_DUPLICATES_ONE_ONLY | SEC_LINK_DUPLICATES_SAME_SIZE) 2915796c8dcSSimon Schubert . 2925796c8dcSSimon Schubert . {* This section was created by the linker as part of dynamic 2935796c8dcSSimon Schubert . relocation or other arcane processing. It is skipped when 2945796c8dcSSimon Schubert . going through the first-pass output, trusting that someone 2955796c8dcSSimon Schubert . else up the line will take care of it later. *} 2965796c8dcSSimon Schubert .#define SEC_LINKER_CREATED 0x100000 2975796c8dcSSimon Schubert . 2985796c8dcSSimon Schubert . {* This section should not be subject to garbage collection. 2995796c8dcSSimon Schubert . Also set to inform the linker that this section should not be 3005796c8dcSSimon Schubert . listed in the link map as discarded. *} 3015796c8dcSSimon Schubert .#define SEC_KEEP 0x200000 3025796c8dcSSimon Schubert . 3035796c8dcSSimon Schubert . {* This section contains "short" data, and should be placed 3045796c8dcSSimon Schubert . "near" the GP. *} 3055796c8dcSSimon Schubert .#define SEC_SMALL_DATA 0x400000 3065796c8dcSSimon Schubert . 3075796c8dcSSimon Schubert . {* Attempt to merge identical entities in the section. 3085796c8dcSSimon Schubert . Entity size is given in the entsize field. *} 3095796c8dcSSimon Schubert .#define SEC_MERGE 0x800000 3105796c8dcSSimon Schubert . 3115796c8dcSSimon Schubert . {* If given with SEC_MERGE, entities to merge are zero terminated 3125796c8dcSSimon Schubert . strings where entsize specifies character size instead of fixed 3135796c8dcSSimon Schubert . size entries. *} 3145796c8dcSSimon Schubert .#define SEC_STRINGS 0x1000000 3155796c8dcSSimon Schubert . 3165796c8dcSSimon Schubert . {* This section contains data about section groups. *} 3175796c8dcSSimon Schubert .#define SEC_GROUP 0x2000000 3185796c8dcSSimon Schubert . 3195796c8dcSSimon Schubert . {* The section is a COFF shared library section. This flag is 3205796c8dcSSimon Schubert . only for the linker. If this type of section appears in 3215796c8dcSSimon Schubert . the input file, the linker must copy it to the output file 3225796c8dcSSimon Schubert . without changing the vma or size. FIXME: Although this 3235796c8dcSSimon Schubert . was originally intended to be general, it really is COFF 3245796c8dcSSimon Schubert . specific (and the flag was renamed to indicate this). It 3255796c8dcSSimon Schubert . might be cleaner to have some more general mechanism to 3265796c8dcSSimon Schubert . allow the back end to control what the linker does with 3275796c8dcSSimon Schubert . sections. *} 3285796c8dcSSimon Schubert .#define SEC_COFF_SHARED_LIBRARY 0x4000000 3295796c8dcSSimon Schubert . 3305796c8dcSSimon Schubert . {* This section contains data which may be shared with other 3315796c8dcSSimon Schubert . executables or shared objects. This is for COFF only. *} 3325796c8dcSSimon Schubert .#define SEC_COFF_SHARED 0x8000000 3335796c8dcSSimon Schubert . 3345796c8dcSSimon Schubert . {* When a section with this flag is being linked, then if the size of 3355796c8dcSSimon Schubert . the input section is less than a page, it should not cross a page 3365796c8dcSSimon Schubert . boundary. If the size of the input section is one page or more, 3375796c8dcSSimon Schubert . it should be aligned on a page boundary. This is for TI 3385796c8dcSSimon Schubert . TMS320C54X only. *} 3395796c8dcSSimon Schubert .#define SEC_TIC54X_BLOCK 0x10000000 3405796c8dcSSimon Schubert . 3415796c8dcSSimon Schubert . {* Conditionally link this section; do not link if there are no 3425796c8dcSSimon Schubert . references found to any symbol in the section. This is for TI 3435796c8dcSSimon Schubert . TMS320C54X only. *} 3445796c8dcSSimon Schubert .#define SEC_TIC54X_CLINK 0x20000000 3455796c8dcSSimon Schubert . 3465796c8dcSSimon Schubert . {* Indicate that section has the no read flag set. This happens 3475796c8dcSSimon Schubert . when memory read flag isn't set. *} 3485796c8dcSSimon Schubert .#define SEC_COFF_NOREAD 0x40000000 3495796c8dcSSimon Schubert . 3505796c8dcSSimon Schubert . {* End of section flags. *} 3515796c8dcSSimon Schubert . 3525796c8dcSSimon Schubert . {* Some internal packed boolean fields. *} 3535796c8dcSSimon Schubert . 3545796c8dcSSimon Schubert . {* See the vma field. *} 3555796c8dcSSimon Schubert . unsigned int user_set_vma : 1; 3565796c8dcSSimon Schubert . 3575796c8dcSSimon Schubert . {* A mark flag used by some of the linker backends. *} 3585796c8dcSSimon Schubert . unsigned int linker_mark : 1; 3595796c8dcSSimon Schubert . 3605796c8dcSSimon Schubert . {* Another mark flag used by some of the linker backends. Set for 3615796c8dcSSimon Schubert . output sections that have an input section. *} 3625796c8dcSSimon Schubert . unsigned int linker_has_input : 1; 3635796c8dcSSimon Schubert . 3645796c8dcSSimon Schubert . {* Mark flag used by some linker backends for garbage collection. *} 3655796c8dcSSimon Schubert . unsigned int gc_mark : 1; 3665796c8dcSSimon Schubert . 3675796c8dcSSimon Schubert . {* The following flags are used by the ELF linker. *} 3685796c8dcSSimon Schubert . 3695796c8dcSSimon Schubert . {* Mark sections which have been allocated to segments. *} 3705796c8dcSSimon Schubert . unsigned int segment_mark : 1; 3715796c8dcSSimon Schubert . 3725796c8dcSSimon Schubert . {* Type of sec_info information. *} 3735796c8dcSSimon Schubert . unsigned int sec_info_type:3; 3745796c8dcSSimon Schubert .#define ELF_INFO_TYPE_NONE 0 3755796c8dcSSimon Schubert .#define ELF_INFO_TYPE_STABS 1 3765796c8dcSSimon Schubert .#define ELF_INFO_TYPE_MERGE 2 3775796c8dcSSimon Schubert .#define ELF_INFO_TYPE_EH_FRAME 3 3785796c8dcSSimon Schubert .#define ELF_INFO_TYPE_JUST_SYMS 4 3795796c8dcSSimon Schubert . 3805796c8dcSSimon Schubert . {* Nonzero if this section uses RELA relocations, rather than REL. *} 3815796c8dcSSimon Schubert . unsigned int use_rela_p:1; 3825796c8dcSSimon Schubert . 3835796c8dcSSimon Schubert . {* Bits used by various backends. The generic code doesn't touch 3845796c8dcSSimon Schubert . these fields. *} 3855796c8dcSSimon Schubert . 386*cf7f2e2dSJohn Marino . unsigned int sec_flg0:1; 387*cf7f2e2dSJohn Marino . unsigned int sec_flg1:1; 388*cf7f2e2dSJohn Marino . unsigned int sec_flg2:1; 389*cf7f2e2dSJohn Marino . unsigned int sec_flg3:1; 390*cf7f2e2dSJohn Marino . unsigned int sec_flg4:1; 391*cf7f2e2dSJohn Marino . unsigned int sec_flg5:1; 3925796c8dcSSimon Schubert . 3935796c8dcSSimon Schubert . {* End of internal packed boolean fields. *} 3945796c8dcSSimon Schubert . 3955796c8dcSSimon Schubert . {* The virtual memory address of the section - where it will be 3965796c8dcSSimon Schubert . at run time. The symbols are relocated against this. The 3975796c8dcSSimon Schubert . user_set_vma flag is maintained by bfd; if it's not set, the 3985796c8dcSSimon Schubert . backend can assign addresses (for example, in <<a.out>>, where 3995796c8dcSSimon Schubert . the default address for <<.data>> is dependent on the specific 4005796c8dcSSimon Schubert . target and various flags). *} 4015796c8dcSSimon Schubert . bfd_vma vma; 4025796c8dcSSimon Schubert . 4035796c8dcSSimon Schubert . {* The load address of the section - where it would be in a 4045796c8dcSSimon Schubert . rom image; really only used for writing section header 4055796c8dcSSimon Schubert . information. *} 4065796c8dcSSimon Schubert . bfd_vma lma; 4075796c8dcSSimon Schubert . 4085796c8dcSSimon Schubert . {* The size of the section in octets, as it will be output. 4095796c8dcSSimon Schubert . Contains a value even if the section has no contents (e.g., the 4105796c8dcSSimon Schubert . size of <<.bss>>). *} 4115796c8dcSSimon Schubert . bfd_size_type size; 4125796c8dcSSimon Schubert . 4135796c8dcSSimon Schubert . {* For input sections, the original size on disk of the section, in 4145796c8dcSSimon Schubert . octets. This field should be set for any section whose size is 4155796c8dcSSimon Schubert . changed by linker relaxation. It is required for sections where 4165796c8dcSSimon Schubert . the linker relaxation scheme doesn't cache altered section and 4175796c8dcSSimon Schubert . reloc contents (stabs, eh_frame, SEC_MERGE, some coff relaxing 4185796c8dcSSimon Schubert . targets), and thus the original size needs to be kept to read the 4195796c8dcSSimon Schubert . section multiple times. For output sections, rawsize holds the 4205796c8dcSSimon Schubert . section size calculated on a previous linker relaxation pass. *} 4215796c8dcSSimon Schubert . bfd_size_type rawsize; 4225796c8dcSSimon Schubert . 4235796c8dcSSimon Schubert . {* Relaxation table. *} 4245796c8dcSSimon Schubert . struct relax_table *relax; 4255796c8dcSSimon Schubert . 4265796c8dcSSimon Schubert . {* Count of used relaxation table entries. *} 4275796c8dcSSimon Schubert . int relax_count; 4285796c8dcSSimon Schubert . 4295796c8dcSSimon Schubert . 4305796c8dcSSimon Schubert . {* If this section is going to be output, then this value is the 4315796c8dcSSimon Schubert . offset in *bytes* into the output section of the first byte in the 4325796c8dcSSimon Schubert . input section (byte ==> smallest addressable unit on the 4335796c8dcSSimon Schubert . target). In most cases, if this was going to start at the 4345796c8dcSSimon Schubert . 100th octet (8-bit quantity) in the output section, this value 4355796c8dcSSimon Schubert . would be 100. However, if the target byte size is 16 bits 4365796c8dcSSimon Schubert . (bfd_octets_per_byte is "2"), this value would be 50. *} 4375796c8dcSSimon Schubert . bfd_vma output_offset; 4385796c8dcSSimon Schubert . 4395796c8dcSSimon Schubert . {* The output section through which to map on output. *} 4405796c8dcSSimon Schubert . struct bfd_section *output_section; 4415796c8dcSSimon Schubert . 4425796c8dcSSimon Schubert . {* The alignment requirement of the section, as an exponent of 2 - 4435796c8dcSSimon Schubert . e.g., 3 aligns to 2^3 (or 8). *} 4445796c8dcSSimon Schubert . unsigned int alignment_power; 4455796c8dcSSimon Schubert . 4465796c8dcSSimon Schubert . {* If an input section, a pointer to a vector of relocation 4475796c8dcSSimon Schubert . records for the data in this section. *} 4485796c8dcSSimon Schubert . struct reloc_cache_entry *relocation; 4495796c8dcSSimon Schubert . 4505796c8dcSSimon Schubert . {* If an output section, a pointer to a vector of pointers to 4515796c8dcSSimon Schubert . relocation records for the data in this section. *} 4525796c8dcSSimon Schubert . struct reloc_cache_entry **orelocation; 4535796c8dcSSimon Schubert . 4545796c8dcSSimon Schubert . {* The number of relocation records in one of the above. *} 4555796c8dcSSimon Schubert . unsigned reloc_count; 4565796c8dcSSimon Schubert . 4575796c8dcSSimon Schubert . {* Information below is back end specific - and not always used 4585796c8dcSSimon Schubert . or updated. *} 4595796c8dcSSimon Schubert . 4605796c8dcSSimon Schubert . {* File position of section data. *} 4615796c8dcSSimon Schubert . file_ptr filepos; 4625796c8dcSSimon Schubert . 4635796c8dcSSimon Schubert . {* File position of relocation info. *} 4645796c8dcSSimon Schubert . file_ptr rel_filepos; 4655796c8dcSSimon Schubert . 4665796c8dcSSimon Schubert . {* File position of line data. *} 4675796c8dcSSimon Schubert . file_ptr line_filepos; 4685796c8dcSSimon Schubert . 4695796c8dcSSimon Schubert . {* Pointer to data for applications. *} 4705796c8dcSSimon Schubert . void *userdata; 4715796c8dcSSimon Schubert . 4725796c8dcSSimon Schubert . {* If the SEC_IN_MEMORY flag is set, this points to the actual 4735796c8dcSSimon Schubert . contents. *} 4745796c8dcSSimon Schubert . unsigned char *contents; 4755796c8dcSSimon Schubert . 4765796c8dcSSimon Schubert . {* Attached line number information. *} 4775796c8dcSSimon Schubert . alent *lineno; 4785796c8dcSSimon Schubert . 4795796c8dcSSimon Schubert . {* Number of line number records. *} 4805796c8dcSSimon Schubert . unsigned int lineno_count; 4815796c8dcSSimon Schubert . 4825796c8dcSSimon Schubert . {* Entity size for merging purposes. *} 4835796c8dcSSimon Schubert . unsigned int entsize; 4845796c8dcSSimon Schubert . 4855796c8dcSSimon Schubert . {* Points to the kept section if this section is a link-once section, 4865796c8dcSSimon Schubert . and is discarded. *} 4875796c8dcSSimon Schubert . struct bfd_section *kept_section; 4885796c8dcSSimon Schubert . 4895796c8dcSSimon Schubert . {* When a section is being output, this value changes as more 4905796c8dcSSimon Schubert . linenumbers are written out. *} 4915796c8dcSSimon Schubert . file_ptr moving_line_filepos; 4925796c8dcSSimon Schubert . 4935796c8dcSSimon Schubert . {* What the section number is in the target world. *} 4945796c8dcSSimon Schubert . int target_index; 4955796c8dcSSimon Schubert . 4965796c8dcSSimon Schubert . void *used_by_bfd; 4975796c8dcSSimon Schubert . 4985796c8dcSSimon Schubert . {* If this is a constructor section then here is a list of the 4995796c8dcSSimon Schubert . relocations created to relocate items within it. *} 5005796c8dcSSimon Schubert . struct relent_chain *constructor_chain; 5015796c8dcSSimon Schubert . 5025796c8dcSSimon Schubert . {* The BFD which owns the section. *} 5035796c8dcSSimon Schubert . bfd *owner; 5045796c8dcSSimon Schubert . 5055796c8dcSSimon Schubert . {* A symbol which points at this section only. *} 5065796c8dcSSimon Schubert . struct bfd_symbol *symbol; 5075796c8dcSSimon Schubert . struct bfd_symbol **symbol_ptr_ptr; 5085796c8dcSSimon Schubert . 5095796c8dcSSimon Schubert . {* Early in the link process, map_head and map_tail are used to build 5105796c8dcSSimon Schubert . a list of input sections attached to an output section. Later, 5115796c8dcSSimon Schubert . output sections use these fields for a list of bfd_link_order 5125796c8dcSSimon Schubert . structs. *} 5135796c8dcSSimon Schubert . union { 5145796c8dcSSimon Schubert . struct bfd_link_order *link_order; 5155796c8dcSSimon Schubert . struct bfd_section *s; 5165796c8dcSSimon Schubert . } map_head, map_tail; 5175796c8dcSSimon Schubert .} asection; 5185796c8dcSSimon Schubert . 5195796c8dcSSimon Schubert .{* Relax table contains information about instructions which can 5205796c8dcSSimon Schubert . be removed by relaxation -- replacing a long address with a 5215796c8dcSSimon Schubert . short address. *} 5225796c8dcSSimon Schubert .struct relax_table { 5235796c8dcSSimon Schubert . {* Address where bytes may be deleted. *} 5245796c8dcSSimon Schubert . bfd_vma addr; 5255796c8dcSSimon Schubert . 5265796c8dcSSimon Schubert . {* Number of bytes to be deleted. *} 5275796c8dcSSimon Schubert . int size; 5285796c8dcSSimon Schubert .}; 5295796c8dcSSimon Schubert . 5305796c8dcSSimon Schubert .{* These sections are global, and are managed by BFD. The application 5315796c8dcSSimon Schubert . and target back end are not permitted to change the values in 5325796c8dcSSimon Schubert . these sections. New code should use the section_ptr macros rather 5335796c8dcSSimon Schubert . than referring directly to the const sections. The const sections 5345796c8dcSSimon Schubert . may eventually vanish. *} 5355796c8dcSSimon Schubert .#define BFD_ABS_SECTION_NAME "*ABS*" 5365796c8dcSSimon Schubert .#define BFD_UND_SECTION_NAME "*UND*" 5375796c8dcSSimon Schubert .#define BFD_COM_SECTION_NAME "*COM*" 5385796c8dcSSimon Schubert .#define BFD_IND_SECTION_NAME "*IND*" 5395796c8dcSSimon Schubert . 5405796c8dcSSimon Schubert .{* The absolute section. *} 5415796c8dcSSimon Schubert .extern asection bfd_abs_section; 5425796c8dcSSimon Schubert .#define bfd_abs_section_ptr ((asection *) &bfd_abs_section) 5435796c8dcSSimon Schubert .#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr) 5445796c8dcSSimon Schubert .{* Pointer to the undefined section. *} 5455796c8dcSSimon Schubert .extern asection bfd_und_section; 5465796c8dcSSimon Schubert .#define bfd_und_section_ptr ((asection *) &bfd_und_section) 5475796c8dcSSimon Schubert .#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr) 5485796c8dcSSimon Schubert .{* Pointer to the common section. *} 5495796c8dcSSimon Schubert .extern asection bfd_com_section; 5505796c8dcSSimon Schubert .#define bfd_com_section_ptr ((asection *) &bfd_com_section) 5515796c8dcSSimon Schubert .{* Pointer to the indirect section. *} 5525796c8dcSSimon Schubert .extern asection bfd_ind_section; 5535796c8dcSSimon Schubert .#define bfd_ind_section_ptr ((asection *) &bfd_ind_section) 5545796c8dcSSimon Schubert .#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr) 5555796c8dcSSimon Schubert . 5565796c8dcSSimon Schubert .#define bfd_is_const_section(SEC) \ 5575796c8dcSSimon Schubert . ( ((SEC) == bfd_abs_section_ptr) \ 5585796c8dcSSimon Schubert . || ((SEC) == bfd_und_section_ptr) \ 5595796c8dcSSimon Schubert . || ((SEC) == bfd_com_section_ptr) \ 5605796c8dcSSimon Schubert . || ((SEC) == bfd_ind_section_ptr)) 5615796c8dcSSimon Schubert . 5625796c8dcSSimon Schubert .{* Macros to handle insertion and deletion of a bfd's sections. These 5635796c8dcSSimon Schubert . only handle the list pointers, ie. do not adjust section_count, 5645796c8dcSSimon Schubert . target_index etc. *} 5655796c8dcSSimon Schubert .#define bfd_section_list_remove(ABFD, S) \ 5665796c8dcSSimon Schubert . do \ 5675796c8dcSSimon Schubert . { \ 5685796c8dcSSimon Schubert . asection *_s = S; \ 5695796c8dcSSimon Schubert . asection *_next = _s->next; \ 5705796c8dcSSimon Schubert . asection *_prev = _s->prev; \ 5715796c8dcSSimon Schubert . if (_prev) \ 5725796c8dcSSimon Schubert . _prev->next = _next; \ 5735796c8dcSSimon Schubert . else \ 5745796c8dcSSimon Schubert . (ABFD)->sections = _next; \ 5755796c8dcSSimon Schubert . if (_next) \ 5765796c8dcSSimon Schubert . _next->prev = _prev; \ 5775796c8dcSSimon Schubert . else \ 5785796c8dcSSimon Schubert . (ABFD)->section_last = _prev; \ 5795796c8dcSSimon Schubert . } \ 5805796c8dcSSimon Schubert . while (0) 5815796c8dcSSimon Schubert .#define bfd_section_list_append(ABFD, S) \ 5825796c8dcSSimon Schubert . do \ 5835796c8dcSSimon Schubert . { \ 5845796c8dcSSimon Schubert . asection *_s = S; \ 5855796c8dcSSimon Schubert . bfd *_abfd = ABFD; \ 5865796c8dcSSimon Schubert . _s->next = NULL; \ 5875796c8dcSSimon Schubert . if (_abfd->section_last) \ 5885796c8dcSSimon Schubert . { \ 5895796c8dcSSimon Schubert . _s->prev = _abfd->section_last; \ 5905796c8dcSSimon Schubert . _abfd->section_last->next = _s; \ 5915796c8dcSSimon Schubert . } \ 5925796c8dcSSimon Schubert . else \ 5935796c8dcSSimon Schubert . { \ 5945796c8dcSSimon Schubert . _s->prev = NULL; \ 5955796c8dcSSimon Schubert . _abfd->sections = _s; \ 5965796c8dcSSimon Schubert . } \ 5975796c8dcSSimon Schubert . _abfd->section_last = _s; \ 5985796c8dcSSimon Schubert . } \ 5995796c8dcSSimon Schubert . while (0) 6005796c8dcSSimon Schubert .#define bfd_section_list_prepend(ABFD, S) \ 6015796c8dcSSimon Schubert . do \ 6025796c8dcSSimon Schubert . { \ 6035796c8dcSSimon Schubert . asection *_s = S; \ 6045796c8dcSSimon Schubert . bfd *_abfd = ABFD; \ 6055796c8dcSSimon Schubert . _s->prev = NULL; \ 6065796c8dcSSimon Schubert . if (_abfd->sections) \ 6075796c8dcSSimon Schubert . { \ 6085796c8dcSSimon Schubert . _s->next = _abfd->sections; \ 6095796c8dcSSimon Schubert . _abfd->sections->prev = _s; \ 6105796c8dcSSimon Schubert . } \ 6115796c8dcSSimon Schubert . else \ 6125796c8dcSSimon Schubert . { \ 6135796c8dcSSimon Schubert . _s->next = NULL; \ 6145796c8dcSSimon Schubert . _abfd->section_last = _s; \ 6155796c8dcSSimon Schubert . } \ 6165796c8dcSSimon Schubert . _abfd->sections = _s; \ 6175796c8dcSSimon Schubert . } \ 6185796c8dcSSimon Schubert . while (0) 6195796c8dcSSimon Schubert .#define bfd_section_list_insert_after(ABFD, A, S) \ 6205796c8dcSSimon Schubert . do \ 6215796c8dcSSimon Schubert . { \ 6225796c8dcSSimon Schubert . asection *_a = A; \ 6235796c8dcSSimon Schubert . asection *_s = S; \ 6245796c8dcSSimon Schubert . asection *_next = _a->next; \ 6255796c8dcSSimon Schubert . _s->next = _next; \ 6265796c8dcSSimon Schubert . _s->prev = _a; \ 6275796c8dcSSimon Schubert . _a->next = _s; \ 6285796c8dcSSimon Schubert . if (_next) \ 6295796c8dcSSimon Schubert . _next->prev = _s; \ 6305796c8dcSSimon Schubert . else \ 6315796c8dcSSimon Schubert . (ABFD)->section_last = _s; \ 6325796c8dcSSimon Schubert . } \ 6335796c8dcSSimon Schubert . while (0) 6345796c8dcSSimon Schubert .#define bfd_section_list_insert_before(ABFD, B, S) \ 6355796c8dcSSimon Schubert . do \ 6365796c8dcSSimon Schubert . { \ 6375796c8dcSSimon Schubert . asection *_b = B; \ 6385796c8dcSSimon Schubert . asection *_s = S; \ 6395796c8dcSSimon Schubert . asection *_prev = _b->prev; \ 6405796c8dcSSimon Schubert . _s->prev = _prev; \ 6415796c8dcSSimon Schubert . _s->next = _b; \ 6425796c8dcSSimon Schubert . _b->prev = _s; \ 6435796c8dcSSimon Schubert . if (_prev) \ 6445796c8dcSSimon Schubert . _prev->next = _s; \ 6455796c8dcSSimon Schubert . else \ 6465796c8dcSSimon Schubert . (ABFD)->sections = _s; \ 6475796c8dcSSimon Schubert . } \ 6485796c8dcSSimon Schubert . while (0) 6495796c8dcSSimon Schubert .#define bfd_section_removed_from_list(ABFD, S) \ 6505796c8dcSSimon Schubert . ((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S)) 6515796c8dcSSimon Schubert . 6525796c8dcSSimon Schubert .#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, NAME, IDX) \ 6535796c8dcSSimon Schubert . {* name, id, index, next, prev, flags, user_set_vma, *} \ 6545796c8dcSSimon Schubert . { NAME, IDX, 0, NULL, NULL, FLAGS, 0, \ 6555796c8dcSSimon Schubert . \ 656*cf7f2e2dSJohn Marino . {* linker_mark, linker_has_input, gc_mark, segment_mark, *} \ 657*cf7f2e2dSJohn Marino . 0, 0, 1, 0, \ 6585796c8dcSSimon Schubert . \ 659*cf7f2e2dSJohn Marino . {* sec_info_type, use_rela_p, *} \ 660*cf7f2e2dSJohn Marino . 0, 0, \ 6615796c8dcSSimon Schubert . \ 662*cf7f2e2dSJohn Marino . {* sec_flg0, sec_flg1, sec_flg2, sec_flg3, sec_flg4, sec_flg5, *} \ 663*cf7f2e2dSJohn Marino . 0, 0, 0, 0, 0, 0, \ 6645796c8dcSSimon Schubert . \ 665*cf7f2e2dSJohn Marino . {* vma, lma, size, rawsize, relax, relax_count, *} \ 666*cf7f2e2dSJohn Marino . 0, 0, 0, 0, 0, 0, \ 6675796c8dcSSimon Schubert . \ 6685796c8dcSSimon Schubert . {* output_offset, output_section, alignment_power, *} \ 6695796c8dcSSimon Schubert . 0, (struct bfd_section *) &SEC, 0, \ 6705796c8dcSSimon Schubert . \ 6715796c8dcSSimon Schubert . {* relocation, orelocation, reloc_count, filepos, rel_filepos, *} \ 6725796c8dcSSimon Schubert . NULL, NULL, 0, 0, 0, \ 6735796c8dcSSimon Schubert . \ 6745796c8dcSSimon Schubert . {* line_filepos, userdata, contents, lineno, lineno_count, *} \ 6755796c8dcSSimon Schubert . 0, NULL, NULL, NULL, 0, \ 6765796c8dcSSimon Schubert . \ 6775796c8dcSSimon Schubert . {* entsize, kept_section, moving_line_filepos, *} \ 6785796c8dcSSimon Schubert . 0, NULL, 0, \ 6795796c8dcSSimon Schubert . \ 6805796c8dcSSimon Schubert . {* target_index, used_by_bfd, constructor_chain, owner, *} \ 6815796c8dcSSimon Schubert . 0, NULL, NULL, NULL, \ 6825796c8dcSSimon Schubert . \ 6835796c8dcSSimon Schubert . {* symbol, symbol_ptr_ptr, *} \ 6845796c8dcSSimon Schubert . (struct bfd_symbol *) SYM, &SEC.symbol, \ 6855796c8dcSSimon Schubert . \ 6865796c8dcSSimon Schubert . {* map_head, map_tail *} \ 6875796c8dcSSimon Schubert . { NULL }, { NULL } \ 6885796c8dcSSimon Schubert . } 6895796c8dcSSimon Schubert . 6905796c8dcSSimon Schubert */ 6915796c8dcSSimon Schubert 6925796c8dcSSimon Schubert /* We use a macro to initialize the static asymbol structures because 6935796c8dcSSimon Schubert traditional C does not permit us to initialize a union member while 6945796c8dcSSimon Schubert gcc warns if we don't initialize it. */ 6955796c8dcSSimon Schubert /* the_bfd, name, value, attr, section [, udata] */ 6965796c8dcSSimon Schubert #ifdef __STDC__ 6975796c8dcSSimon Schubert #define GLOBAL_SYM_INIT(NAME, SECTION) \ 6985796c8dcSSimon Schubert { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION, { 0 }} 6995796c8dcSSimon Schubert #else 7005796c8dcSSimon Schubert #define GLOBAL_SYM_INIT(NAME, SECTION) \ 7015796c8dcSSimon Schubert { 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION } 7025796c8dcSSimon Schubert #endif 7035796c8dcSSimon Schubert 7045796c8dcSSimon Schubert /* These symbols are global, not specific to any BFD. Therefore, anything 7055796c8dcSSimon Schubert that tries to change them is broken, and should be repaired. */ 7065796c8dcSSimon Schubert 7075796c8dcSSimon Schubert static const asymbol global_syms[] = 7085796c8dcSSimon Schubert { 7095796c8dcSSimon Schubert GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, &bfd_com_section), 7105796c8dcSSimon Schubert GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, &bfd_und_section), 7115796c8dcSSimon Schubert GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, &bfd_abs_section), 7125796c8dcSSimon Schubert GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section) 7135796c8dcSSimon Schubert }; 7145796c8dcSSimon Schubert 7155796c8dcSSimon Schubert #define STD_SECTION(SEC, FLAGS, NAME, IDX) \ 7165796c8dcSSimon Schubert asection SEC = BFD_FAKE_SECTION(SEC, FLAGS, &global_syms[IDX], \ 7175796c8dcSSimon Schubert NAME, IDX) 7185796c8dcSSimon Schubert 7195796c8dcSSimon Schubert STD_SECTION (bfd_com_section, SEC_IS_COMMON, BFD_COM_SECTION_NAME, 0); 7205796c8dcSSimon Schubert STD_SECTION (bfd_und_section, 0, BFD_UND_SECTION_NAME, 1); 7215796c8dcSSimon Schubert STD_SECTION (bfd_abs_section, 0, BFD_ABS_SECTION_NAME, 2); 7225796c8dcSSimon Schubert STD_SECTION (bfd_ind_section, 0, BFD_IND_SECTION_NAME, 3); 7235796c8dcSSimon Schubert #undef STD_SECTION 7245796c8dcSSimon Schubert 7255796c8dcSSimon Schubert /* Initialize an entry in the section hash table. */ 7265796c8dcSSimon Schubert 7275796c8dcSSimon Schubert struct bfd_hash_entry * 7285796c8dcSSimon Schubert bfd_section_hash_newfunc (struct bfd_hash_entry *entry, 7295796c8dcSSimon Schubert struct bfd_hash_table *table, 7305796c8dcSSimon Schubert const char *string) 7315796c8dcSSimon Schubert { 7325796c8dcSSimon Schubert /* Allocate the structure if it has not already been allocated by a 7335796c8dcSSimon Schubert subclass. */ 7345796c8dcSSimon Schubert if (entry == NULL) 7355796c8dcSSimon Schubert { 7365796c8dcSSimon Schubert entry = (struct bfd_hash_entry *) 7375796c8dcSSimon Schubert bfd_hash_allocate (table, sizeof (struct section_hash_entry)); 7385796c8dcSSimon Schubert if (entry == NULL) 7395796c8dcSSimon Schubert return entry; 7405796c8dcSSimon Schubert } 7415796c8dcSSimon Schubert 7425796c8dcSSimon Schubert /* Call the allocation method of the superclass. */ 7435796c8dcSSimon Schubert entry = bfd_hash_newfunc (entry, table, string); 7445796c8dcSSimon Schubert if (entry != NULL) 7455796c8dcSSimon Schubert memset (&((struct section_hash_entry *) entry)->section, 0, 7465796c8dcSSimon Schubert sizeof (asection)); 7475796c8dcSSimon Schubert 7485796c8dcSSimon Schubert return entry; 7495796c8dcSSimon Schubert } 7505796c8dcSSimon Schubert 7515796c8dcSSimon Schubert #define section_hash_lookup(table, string, create, copy) \ 7525796c8dcSSimon Schubert ((struct section_hash_entry *) \ 7535796c8dcSSimon Schubert bfd_hash_lookup ((table), (string), (create), (copy))) 7545796c8dcSSimon Schubert 7555796c8dcSSimon Schubert /* Create a symbol whose only job is to point to this section. This 7565796c8dcSSimon Schubert is useful for things like relocs which are relative to the base 7575796c8dcSSimon Schubert of a section. */ 7585796c8dcSSimon Schubert 7595796c8dcSSimon Schubert bfd_boolean 7605796c8dcSSimon Schubert _bfd_generic_new_section_hook (bfd *abfd, asection *newsect) 7615796c8dcSSimon Schubert { 7625796c8dcSSimon Schubert newsect->symbol = bfd_make_empty_symbol (abfd); 7635796c8dcSSimon Schubert if (newsect->symbol == NULL) 7645796c8dcSSimon Schubert return FALSE; 7655796c8dcSSimon Schubert 7665796c8dcSSimon Schubert newsect->symbol->name = newsect->name; 7675796c8dcSSimon Schubert newsect->symbol->value = 0; 7685796c8dcSSimon Schubert newsect->symbol->section = newsect; 7695796c8dcSSimon Schubert newsect->symbol->flags = BSF_SECTION_SYM; 7705796c8dcSSimon Schubert 7715796c8dcSSimon Schubert newsect->symbol_ptr_ptr = &newsect->symbol; 7725796c8dcSSimon Schubert return TRUE; 7735796c8dcSSimon Schubert } 7745796c8dcSSimon Schubert 7755796c8dcSSimon Schubert /* Initializes a new section. NEWSECT->NAME is already set. */ 7765796c8dcSSimon Schubert 7775796c8dcSSimon Schubert static asection * 7785796c8dcSSimon Schubert bfd_section_init (bfd *abfd, asection *newsect) 7795796c8dcSSimon Schubert { 7805796c8dcSSimon Schubert static int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */ 7815796c8dcSSimon Schubert 7825796c8dcSSimon Schubert newsect->id = section_id; 7835796c8dcSSimon Schubert newsect->index = abfd->section_count; 7845796c8dcSSimon Schubert newsect->owner = abfd; 7855796c8dcSSimon Schubert 7865796c8dcSSimon Schubert if (! BFD_SEND (abfd, _new_section_hook, (abfd, newsect))) 7875796c8dcSSimon Schubert return NULL; 7885796c8dcSSimon Schubert 7895796c8dcSSimon Schubert section_id++; 7905796c8dcSSimon Schubert abfd->section_count++; 7915796c8dcSSimon Schubert bfd_section_list_append (abfd, newsect); 7925796c8dcSSimon Schubert return newsect; 7935796c8dcSSimon Schubert } 7945796c8dcSSimon Schubert 7955796c8dcSSimon Schubert /* 7965796c8dcSSimon Schubert DOCDD 7975796c8dcSSimon Schubert INODE 7985796c8dcSSimon Schubert section prototypes, , typedef asection, Sections 7995796c8dcSSimon Schubert SUBSECTION 8005796c8dcSSimon Schubert Section prototypes 8015796c8dcSSimon Schubert 8025796c8dcSSimon Schubert These are the functions exported by the section handling part of BFD. 8035796c8dcSSimon Schubert */ 8045796c8dcSSimon Schubert 8055796c8dcSSimon Schubert /* 8065796c8dcSSimon Schubert FUNCTION 8075796c8dcSSimon Schubert bfd_section_list_clear 8085796c8dcSSimon Schubert 8095796c8dcSSimon Schubert SYNOPSIS 8105796c8dcSSimon Schubert void bfd_section_list_clear (bfd *); 8115796c8dcSSimon Schubert 8125796c8dcSSimon Schubert DESCRIPTION 8135796c8dcSSimon Schubert Clears the section list, and also resets the section count and 8145796c8dcSSimon Schubert hash table entries. 8155796c8dcSSimon Schubert */ 8165796c8dcSSimon Schubert 8175796c8dcSSimon Schubert void 8185796c8dcSSimon Schubert bfd_section_list_clear (bfd *abfd) 8195796c8dcSSimon Schubert { 8205796c8dcSSimon Schubert abfd->sections = NULL; 8215796c8dcSSimon Schubert abfd->section_last = NULL; 8225796c8dcSSimon Schubert abfd->section_count = 0; 8235796c8dcSSimon Schubert memset (abfd->section_htab.table, 0, 8245796c8dcSSimon Schubert abfd->section_htab.size * sizeof (struct bfd_hash_entry *)); 8255796c8dcSSimon Schubert } 8265796c8dcSSimon Schubert 8275796c8dcSSimon Schubert /* 8285796c8dcSSimon Schubert FUNCTION 8295796c8dcSSimon Schubert bfd_get_section_by_name 8305796c8dcSSimon Schubert 8315796c8dcSSimon Schubert SYNOPSIS 8325796c8dcSSimon Schubert asection *bfd_get_section_by_name (bfd *abfd, const char *name); 8335796c8dcSSimon Schubert 8345796c8dcSSimon Schubert DESCRIPTION 8355796c8dcSSimon Schubert Run through @var{abfd} and return the one of the 8365796c8dcSSimon Schubert <<asection>>s whose name matches @var{name}, otherwise <<NULL>>. 8375796c8dcSSimon Schubert @xref{Sections}, for more information. 8385796c8dcSSimon Schubert 8395796c8dcSSimon Schubert This should only be used in special cases; the normal way to process 8405796c8dcSSimon Schubert all sections of a given name is to use <<bfd_map_over_sections>> and 8415796c8dcSSimon Schubert <<strcmp>> on the name (or better yet, base it on the section flags 8425796c8dcSSimon Schubert or something else) for each section. 8435796c8dcSSimon Schubert */ 8445796c8dcSSimon Schubert 8455796c8dcSSimon Schubert asection * 8465796c8dcSSimon Schubert bfd_get_section_by_name (bfd *abfd, const char *name) 8475796c8dcSSimon Schubert { 8485796c8dcSSimon Schubert struct section_hash_entry *sh; 8495796c8dcSSimon Schubert 8505796c8dcSSimon Schubert sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE); 8515796c8dcSSimon Schubert if (sh != NULL) 8525796c8dcSSimon Schubert return &sh->section; 8535796c8dcSSimon Schubert 8545796c8dcSSimon Schubert return NULL; 8555796c8dcSSimon Schubert } 8565796c8dcSSimon Schubert 8575796c8dcSSimon Schubert /* 8585796c8dcSSimon Schubert FUNCTION 8595796c8dcSSimon Schubert bfd_get_section_by_name_if 8605796c8dcSSimon Schubert 8615796c8dcSSimon Schubert SYNOPSIS 8625796c8dcSSimon Schubert asection *bfd_get_section_by_name_if 8635796c8dcSSimon Schubert (bfd *abfd, 8645796c8dcSSimon Schubert const char *name, 8655796c8dcSSimon Schubert bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj), 8665796c8dcSSimon Schubert void *obj); 8675796c8dcSSimon Schubert 8685796c8dcSSimon Schubert DESCRIPTION 8695796c8dcSSimon Schubert Call the provided function @var{func} for each section 8705796c8dcSSimon Schubert attached to the BFD @var{abfd} whose name matches @var{name}, 8715796c8dcSSimon Schubert passing @var{obj} as an argument. The function will be called 8725796c8dcSSimon Schubert as if by 8735796c8dcSSimon Schubert 8745796c8dcSSimon Schubert | func (abfd, the_section, obj); 8755796c8dcSSimon Schubert 8765796c8dcSSimon Schubert It returns the first section for which @var{func} returns true, 8775796c8dcSSimon Schubert otherwise <<NULL>>. 8785796c8dcSSimon Schubert 8795796c8dcSSimon Schubert */ 8805796c8dcSSimon Schubert 8815796c8dcSSimon Schubert asection * 8825796c8dcSSimon Schubert bfd_get_section_by_name_if (bfd *abfd, const char *name, 8835796c8dcSSimon Schubert bfd_boolean (*operation) (bfd *, 8845796c8dcSSimon Schubert asection *, 8855796c8dcSSimon Schubert void *), 8865796c8dcSSimon Schubert void *user_storage) 8875796c8dcSSimon Schubert { 8885796c8dcSSimon Schubert struct section_hash_entry *sh; 8895796c8dcSSimon Schubert unsigned long hash; 8905796c8dcSSimon Schubert 8915796c8dcSSimon Schubert sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE); 8925796c8dcSSimon Schubert if (sh == NULL) 8935796c8dcSSimon Schubert return NULL; 8945796c8dcSSimon Schubert 8955796c8dcSSimon Schubert hash = sh->root.hash; 8965796c8dcSSimon Schubert do 8975796c8dcSSimon Schubert { 8985796c8dcSSimon Schubert if ((*operation) (abfd, &sh->section, user_storage)) 8995796c8dcSSimon Schubert return &sh->section; 9005796c8dcSSimon Schubert sh = (struct section_hash_entry *) sh->root.next; 9015796c8dcSSimon Schubert } 9025796c8dcSSimon Schubert while (sh != NULL && sh->root.hash == hash 9035796c8dcSSimon Schubert && strcmp (sh->root.string, name) == 0); 9045796c8dcSSimon Schubert 9055796c8dcSSimon Schubert return NULL; 9065796c8dcSSimon Schubert } 9075796c8dcSSimon Schubert 9085796c8dcSSimon Schubert /* 9095796c8dcSSimon Schubert FUNCTION 9105796c8dcSSimon Schubert bfd_get_unique_section_name 9115796c8dcSSimon Schubert 9125796c8dcSSimon Schubert SYNOPSIS 9135796c8dcSSimon Schubert char *bfd_get_unique_section_name 9145796c8dcSSimon Schubert (bfd *abfd, const char *templat, int *count); 9155796c8dcSSimon Schubert 9165796c8dcSSimon Schubert DESCRIPTION 9175796c8dcSSimon Schubert Invent a section name that is unique in @var{abfd} by tacking 9185796c8dcSSimon Schubert a dot and a digit suffix onto the original @var{templat}. If 9195796c8dcSSimon Schubert @var{count} is non-NULL, then it specifies the first number 9205796c8dcSSimon Schubert tried as a suffix to generate a unique name. The value 9215796c8dcSSimon Schubert pointed to by @var{count} will be incremented in this case. 9225796c8dcSSimon Schubert */ 9235796c8dcSSimon Schubert 9245796c8dcSSimon Schubert char * 9255796c8dcSSimon Schubert bfd_get_unique_section_name (bfd *abfd, const char *templat, int *count) 9265796c8dcSSimon Schubert { 9275796c8dcSSimon Schubert int num; 9285796c8dcSSimon Schubert unsigned int len; 9295796c8dcSSimon Schubert char *sname; 9305796c8dcSSimon Schubert 9315796c8dcSSimon Schubert len = strlen (templat); 9325796c8dcSSimon Schubert sname = (char *) bfd_malloc (len + 8); 9335796c8dcSSimon Schubert if (sname == NULL) 9345796c8dcSSimon Schubert return NULL; 9355796c8dcSSimon Schubert memcpy (sname, templat, len); 9365796c8dcSSimon Schubert num = 1; 9375796c8dcSSimon Schubert if (count != NULL) 9385796c8dcSSimon Schubert num = *count; 9395796c8dcSSimon Schubert 9405796c8dcSSimon Schubert do 9415796c8dcSSimon Schubert { 9425796c8dcSSimon Schubert /* If we have a million sections, something is badly wrong. */ 9435796c8dcSSimon Schubert if (num > 999999) 9445796c8dcSSimon Schubert abort (); 9455796c8dcSSimon Schubert sprintf (sname + len, ".%d", num++); 9465796c8dcSSimon Schubert } 9475796c8dcSSimon Schubert while (section_hash_lookup (&abfd->section_htab, sname, FALSE, FALSE)); 9485796c8dcSSimon Schubert 9495796c8dcSSimon Schubert if (count != NULL) 9505796c8dcSSimon Schubert *count = num; 9515796c8dcSSimon Schubert return sname; 9525796c8dcSSimon Schubert } 9535796c8dcSSimon Schubert 9545796c8dcSSimon Schubert /* 9555796c8dcSSimon Schubert FUNCTION 9565796c8dcSSimon Schubert bfd_make_section_old_way 9575796c8dcSSimon Schubert 9585796c8dcSSimon Schubert SYNOPSIS 9595796c8dcSSimon Schubert asection *bfd_make_section_old_way (bfd *abfd, const char *name); 9605796c8dcSSimon Schubert 9615796c8dcSSimon Schubert DESCRIPTION 9625796c8dcSSimon Schubert Create a new empty section called @var{name} 9635796c8dcSSimon Schubert and attach it to the end of the chain of sections for the 9645796c8dcSSimon Schubert BFD @var{abfd}. An attempt to create a section with a name which 9655796c8dcSSimon Schubert is already in use returns its pointer without changing the 9665796c8dcSSimon Schubert section chain. 9675796c8dcSSimon Schubert 9685796c8dcSSimon Schubert It has the funny name since this is the way it used to be 9695796c8dcSSimon Schubert before it was rewritten.... 9705796c8dcSSimon Schubert 9715796c8dcSSimon Schubert Possible errors are: 9725796c8dcSSimon Schubert o <<bfd_error_invalid_operation>> - 9735796c8dcSSimon Schubert If output has already started for this BFD. 9745796c8dcSSimon Schubert o <<bfd_error_no_memory>> - 9755796c8dcSSimon Schubert If memory allocation fails. 9765796c8dcSSimon Schubert 9775796c8dcSSimon Schubert */ 9785796c8dcSSimon Schubert 9795796c8dcSSimon Schubert asection * 9805796c8dcSSimon Schubert bfd_make_section_old_way (bfd *abfd, const char *name) 9815796c8dcSSimon Schubert { 9825796c8dcSSimon Schubert asection *newsect; 9835796c8dcSSimon Schubert 9845796c8dcSSimon Schubert if (abfd->output_has_begun) 9855796c8dcSSimon Schubert { 9865796c8dcSSimon Schubert bfd_set_error (bfd_error_invalid_operation); 9875796c8dcSSimon Schubert return NULL; 9885796c8dcSSimon Schubert } 9895796c8dcSSimon Schubert 9905796c8dcSSimon Schubert if (strcmp (name, BFD_ABS_SECTION_NAME) == 0) 9915796c8dcSSimon Schubert newsect = bfd_abs_section_ptr; 9925796c8dcSSimon Schubert else if (strcmp (name, BFD_COM_SECTION_NAME) == 0) 9935796c8dcSSimon Schubert newsect = bfd_com_section_ptr; 9945796c8dcSSimon Schubert else if (strcmp (name, BFD_UND_SECTION_NAME) == 0) 9955796c8dcSSimon Schubert newsect = bfd_und_section_ptr; 9965796c8dcSSimon Schubert else if (strcmp (name, BFD_IND_SECTION_NAME) == 0) 9975796c8dcSSimon Schubert newsect = bfd_ind_section_ptr; 9985796c8dcSSimon Schubert else 9995796c8dcSSimon Schubert { 10005796c8dcSSimon Schubert struct section_hash_entry *sh; 10015796c8dcSSimon Schubert 10025796c8dcSSimon Schubert sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE); 10035796c8dcSSimon Schubert if (sh == NULL) 10045796c8dcSSimon Schubert return NULL; 10055796c8dcSSimon Schubert 10065796c8dcSSimon Schubert newsect = &sh->section; 10075796c8dcSSimon Schubert if (newsect->name != NULL) 10085796c8dcSSimon Schubert { 10095796c8dcSSimon Schubert /* Section already exists. */ 10105796c8dcSSimon Schubert return newsect; 10115796c8dcSSimon Schubert } 10125796c8dcSSimon Schubert 10135796c8dcSSimon Schubert newsect->name = name; 10145796c8dcSSimon Schubert return bfd_section_init (abfd, newsect); 10155796c8dcSSimon Schubert } 10165796c8dcSSimon Schubert 10175796c8dcSSimon Schubert /* Call new_section_hook when "creating" the standard abs, com, und 10185796c8dcSSimon Schubert and ind sections to tack on format specific section data. 10195796c8dcSSimon Schubert Also, create a proper section symbol. */ 10205796c8dcSSimon Schubert if (! BFD_SEND (abfd, _new_section_hook, (abfd, newsect))) 10215796c8dcSSimon Schubert return NULL; 10225796c8dcSSimon Schubert return newsect; 10235796c8dcSSimon Schubert } 10245796c8dcSSimon Schubert 10255796c8dcSSimon Schubert /* 10265796c8dcSSimon Schubert FUNCTION 10275796c8dcSSimon Schubert bfd_make_section_anyway_with_flags 10285796c8dcSSimon Schubert 10295796c8dcSSimon Schubert SYNOPSIS 10305796c8dcSSimon Schubert asection *bfd_make_section_anyway_with_flags 10315796c8dcSSimon Schubert (bfd *abfd, const char *name, flagword flags); 10325796c8dcSSimon Schubert 10335796c8dcSSimon Schubert DESCRIPTION 10345796c8dcSSimon Schubert Create a new empty section called @var{name} and attach it to the end of 10355796c8dcSSimon Schubert the chain of sections for @var{abfd}. Create a new section even if there 10365796c8dcSSimon Schubert is already a section with that name. Also set the attributes of the 10375796c8dcSSimon Schubert new section to the value @var{flags}. 10385796c8dcSSimon Schubert 10395796c8dcSSimon Schubert Return <<NULL>> and set <<bfd_error>> on error; possible errors are: 10405796c8dcSSimon Schubert o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}. 10415796c8dcSSimon Schubert o <<bfd_error_no_memory>> - If memory allocation fails. 10425796c8dcSSimon Schubert */ 10435796c8dcSSimon Schubert 10445796c8dcSSimon Schubert sec_ptr 10455796c8dcSSimon Schubert bfd_make_section_anyway_with_flags (bfd *abfd, const char *name, 10465796c8dcSSimon Schubert flagword flags) 10475796c8dcSSimon Schubert { 10485796c8dcSSimon Schubert struct section_hash_entry *sh; 10495796c8dcSSimon Schubert asection *newsect; 10505796c8dcSSimon Schubert 10515796c8dcSSimon Schubert if (abfd->output_has_begun) 10525796c8dcSSimon Schubert { 10535796c8dcSSimon Schubert bfd_set_error (bfd_error_invalid_operation); 10545796c8dcSSimon Schubert return NULL; 10555796c8dcSSimon Schubert } 10565796c8dcSSimon Schubert 10575796c8dcSSimon Schubert sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE); 10585796c8dcSSimon Schubert if (sh == NULL) 10595796c8dcSSimon Schubert return NULL; 10605796c8dcSSimon Schubert 10615796c8dcSSimon Schubert newsect = &sh->section; 10625796c8dcSSimon Schubert if (newsect->name != NULL) 10635796c8dcSSimon Schubert { 10645796c8dcSSimon Schubert /* We are making a section of the same name. Put it in the 10655796c8dcSSimon Schubert section hash table. Even though we can't find it directly by a 10665796c8dcSSimon Schubert hash lookup, we'll be able to find the section by traversing 10675796c8dcSSimon Schubert sh->root.next quicker than looking at all the bfd sections. */ 10685796c8dcSSimon Schubert struct section_hash_entry *new_sh; 10695796c8dcSSimon Schubert new_sh = (struct section_hash_entry *) 10705796c8dcSSimon Schubert bfd_section_hash_newfunc (NULL, &abfd->section_htab, name); 10715796c8dcSSimon Schubert if (new_sh == NULL) 10725796c8dcSSimon Schubert return NULL; 10735796c8dcSSimon Schubert 10745796c8dcSSimon Schubert new_sh->root = sh->root; 10755796c8dcSSimon Schubert sh->root.next = &new_sh->root; 10765796c8dcSSimon Schubert newsect = &new_sh->section; 10775796c8dcSSimon Schubert } 10785796c8dcSSimon Schubert 10795796c8dcSSimon Schubert newsect->flags = flags; 10805796c8dcSSimon Schubert newsect->name = name; 10815796c8dcSSimon Schubert return bfd_section_init (abfd, newsect); 10825796c8dcSSimon Schubert } 10835796c8dcSSimon Schubert 10845796c8dcSSimon Schubert /* 10855796c8dcSSimon Schubert FUNCTION 10865796c8dcSSimon Schubert bfd_make_section_anyway 10875796c8dcSSimon Schubert 10885796c8dcSSimon Schubert SYNOPSIS 10895796c8dcSSimon Schubert asection *bfd_make_section_anyway (bfd *abfd, const char *name); 10905796c8dcSSimon Schubert 10915796c8dcSSimon Schubert DESCRIPTION 10925796c8dcSSimon Schubert Create a new empty section called @var{name} and attach it to the end of 10935796c8dcSSimon Schubert the chain of sections for @var{abfd}. Create a new section even if there 10945796c8dcSSimon Schubert is already a section with that name. 10955796c8dcSSimon Schubert 10965796c8dcSSimon Schubert Return <<NULL>> and set <<bfd_error>> on error; possible errors are: 10975796c8dcSSimon Schubert o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}. 10985796c8dcSSimon Schubert o <<bfd_error_no_memory>> - If memory allocation fails. 10995796c8dcSSimon Schubert */ 11005796c8dcSSimon Schubert 11015796c8dcSSimon Schubert sec_ptr 11025796c8dcSSimon Schubert bfd_make_section_anyway (bfd *abfd, const char *name) 11035796c8dcSSimon Schubert { 11045796c8dcSSimon Schubert return bfd_make_section_anyway_with_flags (abfd, name, 0); 11055796c8dcSSimon Schubert } 11065796c8dcSSimon Schubert 11075796c8dcSSimon Schubert /* 11085796c8dcSSimon Schubert FUNCTION 11095796c8dcSSimon Schubert bfd_make_section_with_flags 11105796c8dcSSimon Schubert 11115796c8dcSSimon Schubert SYNOPSIS 11125796c8dcSSimon Schubert asection *bfd_make_section_with_flags 11135796c8dcSSimon Schubert (bfd *, const char *name, flagword flags); 11145796c8dcSSimon Schubert 11155796c8dcSSimon Schubert DESCRIPTION 11165796c8dcSSimon Schubert Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling 11175796c8dcSSimon Schubert bfd_set_error ()) without changing the section chain if there is already a 11185796c8dcSSimon Schubert section named @var{name}. Also set the attributes of the new section to 11195796c8dcSSimon Schubert the value @var{flags}. If there is an error, return <<NULL>> and set 11205796c8dcSSimon Schubert <<bfd_error>>. 11215796c8dcSSimon Schubert */ 11225796c8dcSSimon Schubert 11235796c8dcSSimon Schubert asection * 11245796c8dcSSimon Schubert bfd_make_section_with_flags (bfd *abfd, const char *name, 11255796c8dcSSimon Schubert flagword flags) 11265796c8dcSSimon Schubert { 11275796c8dcSSimon Schubert struct section_hash_entry *sh; 11285796c8dcSSimon Schubert asection *newsect; 11295796c8dcSSimon Schubert 11305796c8dcSSimon Schubert if (abfd->output_has_begun) 11315796c8dcSSimon Schubert { 11325796c8dcSSimon Schubert bfd_set_error (bfd_error_invalid_operation); 11335796c8dcSSimon Schubert return NULL; 11345796c8dcSSimon Schubert } 11355796c8dcSSimon Schubert 11365796c8dcSSimon Schubert if (strcmp (name, BFD_ABS_SECTION_NAME) == 0 11375796c8dcSSimon Schubert || strcmp (name, BFD_COM_SECTION_NAME) == 0 11385796c8dcSSimon Schubert || strcmp (name, BFD_UND_SECTION_NAME) == 0 11395796c8dcSSimon Schubert || strcmp (name, BFD_IND_SECTION_NAME) == 0) 11405796c8dcSSimon Schubert return NULL; 11415796c8dcSSimon Schubert 11425796c8dcSSimon Schubert sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE); 11435796c8dcSSimon Schubert if (sh == NULL) 11445796c8dcSSimon Schubert return NULL; 11455796c8dcSSimon Schubert 11465796c8dcSSimon Schubert newsect = &sh->section; 11475796c8dcSSimon Schubert if (newsect->name != NULL) 11485796c8dcSSimon Schubert { 11495796c8dcSSimon Schubert /* Section already exists. */ 11505796c8dcSSimon Schubert return NULL; 11515796c8dcSSimon Schubert } 11525796c8dcSSimon Schubert 11535796c8dcSSimon Schubert newsect->name = name; 11545796c8dcSSimon Schubert newsect->flags = flags; 11555796c8dcSSimon Schubert return bfd_section_init (abfd, newsect); 11565796c8dcSSimon Schubert } 11575796c8dcSSimon Schubert 11585796c8dcSSimon Schubert /* 11595796c8dcSSimon Schubert FUNCTION 11605796c8dcSSimon Schubert bfd_make_section 11615796c8dcSSimon Schubert 11625796c8dcSSimon Schubert SYNOPSIS 11635796c8dcSSimon Schubert asection *bfd_make_section (bfd *, const char *name); 11645796c8dcSSimon Schubert 11655796c8dcSSimon Schubert DESCRIPTION 11665796c8dcSSimon Schubert Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling 11675796c8dcSSimon Schubert bfd_set_error ()) without changing the section chain if there is already a 11685796c8dcSSimon Schubert section named @var{name}. If there is an error, return <<NULL>> and set 11695796c8dcSSimon Schubert <<bfd_error>>. 11705796c8dcSSimon Schubert */ 11715796c8dcSSimon Schubert 11725796c8dcSSimon Schubert asection * 11735796c8dcSSimon Schubert bfd_make_section (bfd *abfd, const char *name) 11745796c8dcSSimon Schubert { 11755796c8dcSSimon Schubert return bfd_make_section_with_flags (abfd, name, 0); 11765796c8dcSSimon Schubert } 11775796c8dcSSimon Schubert 11785796c8dcSSimon Schubert /* 11795796c8dcSSimon Schubert FUNCTION 11805796c8dcSSimon Schubert bfd_set_section_flags 11815796c8dcSSimon Schubert 11825796c8dcSSimon Schubert SYNOPSIS 11835796c8dcSSimon Schubert bfd_boolean bfd_set_section_flags 11845796c8dcSSimon Schubert (bfd *abfd, asection *sec, flagword flags); 11855796c8dcSSimon Schubert 11865796c8dcSSimon Schubert DESCRIPTION 11875796c8dcSSimon Schubert Set the attributes of the section @var{sec} in the BFD 11885796c8dcSSimon Schubert @var{abfd} to the value @var{flags}. Return <<TRUE>> on success, 11895796c8dcSSimon Schubert <<FALSE>> on error. Possible error returns are: 11905796c8dcSSimon Schubert 11915796c8dcSSimon Schubert o <<bfd_error_invalid_operation>> - 11925796c8dcSSimon Schubert The section cannot have one or more of the attributes 11935796c8dcSSimon Schubert requested. For example, a .bss section in <<a.out>> may not 11945796c8dcSSimon Schubert have the <<SEC_HAS_CONTENTS>> field set. 11955796c8dcSSimon Schubert 11965796c8dcSSimon Schubert */ 11975796c8dcSSimon Schubert 11985796c8dcSSimon Schubert bfd_boolean 11995796c8dcSSimon Schubert bfd_set_section_flags (bfd *abfd ATTRIBUTE_UNUSED, 12005796c8dcSSimon Schubert sec_ptr section, 12015796c8dcSSimon Schubert flagword flags) 12025796c8dcSSimon Schubert { 12035796c8dcSSimon Schubert section->flags = flags; 12045796c8dcSSimon Schubert return TRUE; 12055796c8dcSSimon Schubert } 12065796c8dcSSimon Schubert 12075796c8dcSSimon Schubert /* 12085796c8dcSSimon Schubert FUNCTION 12095796c8dcSSimon Schubert bfd_map_over_sections 12105796c8dcSSimon Schubert 12115796c8dcSSimon Schubert SYNOPSIS 12125796c8dcSSimon Schubert void bfd_map_over_sections 12135796c8dcSSimon Schubert (bfd *abfd, 12145796c8dcSSimon Schubert void (*func) (bfd *abfd, asection *sect, void *obj), 12155796c8dcSSimon Schubert void *obj); 12165796c8dcSSimon Schubert 12175796c8dcSSimon Schubert DESCRIPTION 12185796c8dcSSimon Schubert Call the provided function @var{func} for each section 12195796c8dcSSimon Schubert attached to the BFD @var{abfd}, passing @var{obj} as an 12205796c8dcSSimon Schubert argument. The function will be called as if by 12215796c8dcSSimon Schubert 12225796c8dcSSimon Schubert | func (abfd, the_section, obj); 12235796c8dcSSimon Schubert 12245796c8dcSSimon Schubert This is the preferred method for iterating over sections; an 12255796c8dcSSimon Schubert alternative would be to use a loop: 12265796c8dcSSimon Schubert 12275796c8dcSSimon Schubert | section *p; 12285796c8dcSSimon Schubert | for (p = abfd->sections; p != NULL; p = p->next) 12295796c8dcSSimon Schubert | func (abfd, p, ...) 12305796c8dcSSimon Schubert 12315796c8dcSSimon Schubert */ 12325796c8dcSSimon Schubert 12335796c8dcSSimon Schubert void 12345796c8dcSSimon Schubert bfd_map_over_sections (bfd *abfd, 12355796c8dcSSimon Schubert void (*operation) (bfd *, asection *, void *), 12365796c8dcSSimon Schubert void *user_storage) 12375796c8dcSSimon Schubert { 12385796c8dcSSimon Schubert asection *sect; 12395796c8dcSSimon Schubert unsigned int i = 0; 12405796c8dcSSimon Schubert 12415796c8dcSSimon Schubert for (sect = abfd->sections; sect != NULL; i++, sect = sect->next) 12425796c8dcSSimon Schubert (*operation) (abfd, sect, user_storage); 12435796c8dcSSimon Schubert 12445796c8dcSSimon Schubert if (i != abfd->section_count) /* Debugging */ 12455796c8dcSSimon Schubert abort (); 12465796c8dcSSimon Schubert } 12475796c8dcSSimon Schubert 12485796c8dcSSimon Schubert /* 12495796c8dcSSimon Schubert FUNCTION 12505796c8dcSSimon Schubert bfd_sections_find_if 12515796c8dcSSimon Schubert 12525796c8dcSSimon Schubert SYNOPSIS 12535796c8dcSSimon Schubert asection *bfd_sections_find_if 12545796c8dcSSimon Schubert (bfd *abfd, 12555796c8dcSSimon Schubert bfd_boolean (*operation) (bfd *abfd, asection *sect, void *obj), 12565796c8dcSSimon Schubert void *obj); 12575796c8dcSSimon Schubert 12585796c8dcSSimon Schubert DESCRIPTION 12595796c8dcSSimon Schubert Call the provided function @var{operation} for each section 12605796c8dcSSimon Schubert attached to the BFD @var{abfd}, passing @var{obj} as an 12615796c8dcSSimon Schubert argument. The function will be called as if by 12625796c8dcSSimon Schubert 12635796c8dcSSimon Schubert | operation (abfd, the_section, obj); 12645796c8dcSSimon Schubert 12655796c8dcSSimon Schubert It returns the first section for which @var{operation} returns true. 12665796c8dcSSimon Schubert 12675796c8dcSSimon Schubert */ 12685796c8dcSSimon Schubert 12695796c8dcSSimon Schubert asection * 12705796c8dcSSimon Schubert bfd_sections_find_if (bfd *abfd, 12715796c8dcSSimon Schubert bfd_boolean (*operation) (bfd *, asection *, void *), 12725796c8dcSSimon Schubert void *user_storage) 12735796c8dcSSimon Schubert { 12745796c8dcSSimon Schubert asection *sect; 12755796c8dcSSimon Schubert 12765796c8dcSSimon Schubert for (sect = abfd->sections; sect != NULL; sect = sect->next) 12775796c8dcSSimon Schubert if ((*operation) (abfd, sect, user_storage)) 12785796c8dcSSimon Schubert break; 12795796c8dcSSimon Schubert 12805796c8dcSSimon Schubert return sect; 12815796c8dcSSimon Schubert } 12825796c8dcSSimon Schubert 12835796c8dcSSimon Schubert /* 12845796c8dcSSimon Schubert FUNCTION 12855796c8dcSSimon Schubert bfd_set_section_size 12865796c8dcSSimon Schubert 12875796c8dcSSimon Schubert SYNOPSIS 12885796c8dcSSimon Schubert bfd_boolean bfd_set_section_size 12895796c8dcSSimon Schubert (bfd *abfd, asection *sec, bfd_size_type val); 12905796c8dcSSimon Schubert 12915796c8dcSSimon Schubert DESCRIPTION 12925796c8dcSSimon Schubert Set @var{sec} to the size @var{val}. If the operation is 12935796c8dcSSimon Schubert ok, then <<TRUE>> is returned, else <<FALSE>>. 12945796c8dcSSimon Schubert 12955796c8dcSSimon Schubert Possible error returns: 12965796c8dcSSimon Schubert o <<bfd_error_invalid_operation>> - 12975796c8dcSSimon Schubert Writing has started to the BFD, so setting the size is invalid. 12985796c8dcSSimon Schubert 12995796c8dcSSimon Schubert */ 13005796c8dcSSimon Schubert 13015796c8dcSSimon Schubert bfd_boolean 13025796c8dcSSimon Schubert bfd_set_section_size (bfd *abfd, sec_ptr ptr, bfd_size_type val) 13035796c8dcSSimon Schubert { 13045796c8dcSSimon Schubert /* Once you've started writing to any section you cannot create or change 13055796c8dcSSimon Schubert the size of any others. */ 13065796c8dcSSimon Schubert 13075796c8dcSSimon Schubert if (abfd->output_has_begun) 13085796c8dcSSimon Schubert { 13095796c8dcSSimon Schubert bfd_set_error (bfd_error_invalid_operation); 13105796c8dcSSimon Schubert return FALSE; 13115796c8dcSSimon Schubert } 13125796c8dcSSimon Schubert 13135796c8dcSSimon Schubert ptr->size = val; 13145796c8dcSSimon Schubert return TRUE; 13155796c8dcSSimon Schubert } 13165796c8dcSSimon Schubert 13175796c8dcSSimon Schubert /* 13185796c8dcSSimon Schubert FUNCTION 13195796c8dcSSimon Schubert bfd_set_section_contents 13205796c8dcSSimon Schubert 13215796c8dcSSimon Schubert SYNOPSIS 13225796c8dcSSimon Schubert bfd_boolean bfd_set_section_contents 13235796c8dcSSimon Schubert (bfd *abfd, asection *section, const void *data, 13245796c8dcSSimon Schubert file_ptr offset, bfd_size_type count); 13255796c8dcSSimon Schubert 13265796c8dcSSimon Schubert DESCRIPTION 13275796c8dcSSimon Schubert Sets the contents of the section @var{section} in BFD 13285796c8dcSSimon Schubert @var{abfd} to the data starting in memory at @var{data}. The 13295796c8dcSSimon Schubert data is written to the output section starting at offset 13305796c8dcSSimon Schubert @var{offset} for @var{count} octets. 13315796c8dcSSimon Schubert 13325796c8dcSSimon Schubert Normally <<TRUE>> is returned, else <<FALSE>>. Possible error 13335796c8dcSSimon Schubert returns are: 13345796c8dcSSimon Schubert o <<bfd_error_no_contents>> - 13355796c8dcSSimon Schubert The output section does not have the <<SEC_HAS_CONTENTS>> 13365796c8dcSSimon Schubert attribute, so nothing can be written to it. 13375796c8dcSSimon Schubert o and some more too 13385796c8dcSSimon Schubert 13395796c8dcSSimon Schubert This routine is front end to the back end function 13405796c8dcSSimon Schubert <<_bfd_set_section_contents>>. 13415796c8dcSSimon Schubert 13425796c8dcSSimon Schubert */ 13435796c8dcSSimon Schubert 13445796c8dcSSimon Schubert bfd_boolean 13455796c8dcSSimon Schubert bfd_set_section_contents (bfd *abfd, 13465796c8dcSSimon Schubert sec_ptr section, 13475796c8dcSSimon Schubert const void *location, 13485796c8dcSSimon Schubert file_ptr offset, 13495796c8dcSSimon Schubert bfd_size_type count) 13505796c8dcSSimon Schubert { 13515796c8dcSSimon Schubert bfd_size_type sz; 13525796c8dcSSimon Schubert 13535796c8dcSSimon Schubert if (!(bfd_get_section_flags (abfd, section) & SEC_HAS_CONTENTS)) 13545796c8dcSSimon Schubert { 13555796c8dcSSimon Schubert bfd_set_error (bfd_error_no_contents); 13565796c8dcSSimon Schubert return FALSE; 13575796c8dcSSimon Schubert } 13585796c8dcSSimon Schubert 13595796c8dcSSimon Schubert sz = section->size; 13605796c8dcSSimon Schubert if ((bfd_size_type) offset > sz 13615796c8dcSSimon Schubert || count > sz 13625796c8dcSSimon Schubert || offset + count > sz 13635796c8dcSSimon Schubert || count != (size_t) count) 13645796c8dcSSimon Schubert { 13655796c8dcSSimon Schubert bfd_set_error (bfd_error_bad_value); 13665796c8dcSSimon Schubert return FALSE; 13675796c8dcSSimon Schubert } 13685796c8dcSSimon Schubert 13695796c8dcSSimon Schubert if (!bfd_write_p (abfd)) 13705796c8dcSSimon Schubert { 13715796c8dcSSimon Schubert bfd_set_error (bfd_error_invalid_operation); 13725796c8dcSSimon Schubert return FALSE; 13735796c8dcSSimon Schubert } 13745796c8dcSSimon Schubert 13755796c8dcSSimon Schubert /* Record a copy of the data in memory if desired. */ 13765796c8dcSSimon Schubert if (section->contents 13775796c8dcSSimon Schubert && location != section->contents + offset) 13785796c8dcSSimon Schubert memcpy (section->contents + offset, location, (size_t) count); 13795796c8dcSSimon Schubert 13805796c8dcSSimon Schubert if (BFD_SEND (abfd, _bfd_set_section_contents, 13815796c8dcSSimon Schubert (abfd, section, location, offset, count))) 13825796c8dcSSimon Schubert { 13835796c8dcSSimon Schubert abfd->output_has_begun = TRUE; 13845796c8dcSSimon Schubert return TRUE; 13855796c8dcSSimon Schubert } 13865796c8dcSSimon Schubert 13875796c8dcSSimon Schubert return FALSE; 13885796c8dcSSimon Schubert } 13895796c8dcSSimon Schubert 13905796c8dcSSimon Schubert /* 13915796c8dcSSimon Schubert FUNCTION 13925796c8dcSSimon Schubert bfd_get_section_contents 13935796c8dcSSimon Schubert 13945796c8dcSSimon Schubert SYNOPSIS 13955796c8dcSSimon Schubert bfd_boolean bfd_get_section_contents 13965796c8dcSSimon Schubert (bfd *abfd, asection *section, void *location, file_ptr offset, 13975796c8dcSSimon Schubert bfd_size_type count); 13985796c8dcSSimon Schubert 13995796c8dcSSimon Schubert DESCRIPTION 14005796c8dcSSimon Schubert Read data from @var{section} in BFD @var{abfd} 14015796c8dcSSimon Schubert into memory starting at @var{location}. The data is read at an 14025796c8dcSSimon Schubert offset of @var{offset} from the start of the input section, 14035796c8dcSSimon Schubert and is read for @var{count} bytes. 14045796c8dcSSimon Schubert 14055796c8dcSSimon Schubert If the contents of a constructor with the <<SEC_CONSTRUCTOR>> 14065796c8dcSSimon Schubert flag set are requested or if the section does not have the 14075796c8dcSSimon Schubert <<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled 14085796c8dcSSimon Schubert with zeroes. If no errors occur, <<TRUE>> is returned, else 14095796c8dcSSimon Schubert <<FALSE>>. 14105796c8dcSSimon Schubert 14115796c8dcSSimon Schubert */ 14125796c8dcSSimon Schubert bfd_boolean 14135796c8dcSSimon Schubert bfd_get_section_contents (bfd *abfd, 14145796c8dcSSimon Schubert sec_ptr section, 14155796c8dcSSimon Schubert void *location, 14165796c8dcSSimon Schubert file_ptr offset, 14175796c8dcSSimon Schubert bfd_size_type count) 14185796c8dcSSimon Schubert { 14195796c8dcSSimon Schubert bfd_size_type sz; 14205796c8dcSSimon Schubert 14215796c8dcSSimon Schubert if (section->flags & SEC_CONSTRUCTOR) 14225796c8dcSSimon Schubert { 14235796c8dcSSimon Schubert memset (location, 0, (size_t) count); 14245796c8dcSSimon Schubert return TRUE; 14255796c8dcSSimon Schubert } 14265796c8dcSSimon Schubert 14275796c8dcSSimon Schubert sz = section->rawsize ? section->rawsize : section->size; 14285796c8dcSSimon Schubert if ((bfd_size_type) offset > sz 14295796c8dcSSimon Schubert || count > sz 14305796c8dcSSimon Schubert || offset + count > sz 14315796c8dcSSimon Schubert || count != (size_t) count) 14325796c8dcSSimon Schubert { 14335796c8dcSSimon Schubert bfd_set_error (bfd_error_bad_value); 14345796c8dcSSimon Schubert return FALSE; 14355796c8dcSSimon Schubert } 14365796c8dcSSimon Schubert 14375796c8dcSSimon Schubert if (count == 0) 14385796c8dcSSimon Schubert /* Don't bother. */ 14395796c8dcSSimon Schubert return TRUE; 14405796c8dcSSimon Schubert 14415796c8dcSSimon Schubert if ((section->flags & SEC_HAS_CONTENTS) == 0) 14425796c8dcSSimon Schubert { 14435796c8dcSSimon Schubert memset (location, 0, (size_t) count); 14445796c8dcSSimon Schubert return TRUE; 14455796c8dcSSimon Schubert } 14465796c8dcSSimon Schubert 14475796c8dcSSimon Schubert if ((section->flags & SEC_IN_MEMORY) != 0) 14485796c8dcSSimon Schubert { 14495796c8dcSSimon Schubert if (section->contents == NULL) 14505796c8dcSSimon Schubert { 14515796c8dcSSimon Schubert /* This can happen because of errors earlier on in the linking process. 14525796c8dcSSimon Schubert We do not want to seg-fault here, so clear the flag and return an 14535796c8dcSSimon Schubert error code. */ 14545796c8dcSSimon Schubert section->flags &= ~ SEC_IN_MEMORY; 14555796c8dcSSimon Schubert bfd_set_error (bfd_error_invalid_operation); 14565796c8dcSSimon Schubert return FALSE; 14575796c8dcSSimon Schubert } 14585796c8dcSSimon Schubert 14595796c8dcSSimon Schubert memcpy (location, section->contents + offset, (size_t) count); 14605796c8dcSSimon Schubert return TRUE; 14615796c8dcSSimon Schubert } 14625796c8dcSSimon Schubert 14635796c8dcSSimon Schubert return BFD_SEND (abfd, _bfd_get_section_contents, 14645796c8dcSSimon Schubert (abfd, section, location, offset, count)); 14655796c8dcSSimon Schubert } 14665796c8dcSSimon Schubert 14675796c8dcSSimon Schubert /* 14685796c8dcSSimon Schubert FUNCTION 14695796c8dcSSimon Schubert bfd_malloc_and_get_section 14705796c8dcSSimon Schubert 14715796c8dcSSimon Schubert SYNOPSIS 14725796c8dcSSimon Schubert bfd_boolean bfd_malloc_and_get_section 14735796c8dcSSimon Schubert (bfd *abfd, asection *section, bfd_byte **buf); 14745796c8dcSSimon Schubert 14755796c8dcSSimon Schubert DESCRIPTION 14765796c8dcSSimon Schubert Read all data from @var{section} in BFD @var{abfd} 14775796c8dcSSimon Schubert into a buffer, *@var{buf}, malloc'd by this function. 14785796c8dcSSimon Schubert */ 14795796c8dcSSimon Schubert 14805796c8dcSSimon Schubert bfd_boolean 14815796c8dcSSimon Schubert bfd_malloc_and_get_section (bfd *abfd, sec_ptr sec, bfd_byte **buf) 14825796c8dcSSimon Schubert { 14835796c8dcSSimon Schubert bfd_size_type sz = sec->rawsize ? sec->rawsize : sec->size; 14845796c8dcSSimon Schubert bfd_byte *p = NULL; 14855796c8dcSSimon Schubert 14865796c8dcSSimon Schubert *buf = p; 14875796c8dcSSimon Schubert if (sz == 0) 14885796c8dcSSimon Schubert return TRUE; 14895796c8dcSSimon Schubert 14905796c8dcSSimon Schubert p = (bfd_byte *) 14915796c8dcSSimon Schubert bfd_malloc (sec->rawsize > sec->size ? sec->rawsize : sec->size); 14925796c8dcSSimon Schubert if (p == NULL) 14935796c8dcSSimon Schubert return FALSE; 14945796c8dcSSimon Schubert *buf = p; 14955796c8dcSSimon Schubert 14965796c8dcSSimon Schubert return bfd_get_section_contents (abfd, sec, p, 0, sz); 14975796c8dcSSimon Schubert } 14985796c8dcSSimon Schubert /* 14995796c8dcSSimon Schubert FUNCTION 15005796c8dcSSimon Schubert bfd_copy_private_section_data 15015796c8dcSSimon Schubert 15025796c8dcSSimon Schubert SYNOPSIS 15035796c8dcSSimon Schubert bfd_boolean bfd_copy_private_section_data 15045796c8dcSSimon Schubert (bfd *ibfd, asection *isec, bfd *obfd, asection *osec); 15055796c8dcSSimon Schubert 15065796c8dcSSimon Schubert DESCRIPTION 15075796c8dcSSimon Schubert Copy private section information from @var{isec} in the BFD 15085796c8dcSSimon Schubert @var{ibfd} to the section @var{osec} in the BFD @var{obfd}. 15095796c8dcSSimon Schubert Return <<TRUE>> on success, <<FALSE>> on error. Possible error 15105796c8dcSSimon Schubert returns are: 15115796c8dcSSimon Schubert 15125796c8dcSSimon Schubert o <<bfd_error_no_memory>> - 15135796c8dcSSimon Schubert Not enough memory exists to create private data for @var{osec}. 15145796c8dcSSimon Schubert 15155796c8dcSSimon Schubert .#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \ 15165796c8dcSSimon Schubert . BFD_SEND (obfd, _bfd_copy_private_section_data, \ 15175796c8dcSSimon Schubert . (ibfd, isection, obfd, osection)) 15185796c8dcSSimon Schubert */ 15195796c8dcSSimon Schubert 15205796c8dcSSimon Schubert /* 15215796c8dcSSimon Schubert FUNCTION 15225796c8dcSSimon Schubert bfd_generic_is_group_section 15235796c8dcSSimon Schubert 15245796c8dcSSimon Schubert SYNOPSIS 15255796c8dcSSimon Schubert bfd_boolean bfd_generic_is_group_section (bfd *, const asection *sec); 15265796c8dcSSimon Schubert 15275796c8dcSSimon Schubert DESCRIPTION 15285796c8dcSSimon Schubert Returns TRUE if @var{sec} is a member of a group. 15295796c8dcSSimon Schubert */ 15305796c8dcSSimon Schubert 15315796c8dcSSimon Schubert bfd_boolean 15325796c8dcSSimon Schubert bfd_generic_is_group_section (bfd *abfd ATTRIBUTE_UNUSED, 15335796c8dcSSimon Schubert const asection *sec ATTRIBUTE_UNUSED) 15345796c8dcSSimon Schubert { 15355796c8dcSSimon Schubert return FALSE; 15365796c8dcSSimon Schubert } 15375796c8dcSSimon Schubert 15385796c8dcSSimon Schubert /* 15395796c8dcSSimon Schubert FUNCTION 15405796c8dcSSimon Schubert bfd_generic_discard_group 15415796c8dcSSimon Schubert 15425796c8dcSSimon Schubert SYNOPSIS 15435796c8dcSSimon Schubert bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group); 15445796c8dcSSimon Schubert 15455796c8dcSSimon Schubert DESCRIPTION 15465796c8dcSSimon Schubert Remove all members of @var{group} from the output. 15475796c8dcSSimon Schubert */ 15485796c8dcSSimon Schubert 15495796c8dcSSimon Schubert bfd_boolean 15505796c8dcSSimon Schubert bfd_generic_discard_group (bfd *abfd ATTRIBUTE_UNUSED, 15515796c8dcSSimon Schubert asection *group ATTRIBUTE_UNUSED) 15525796c8dcSSimon Schubert { 15535796c8dcSSimon Schubert return TRUE; 15545796c8dcSSimon Schubert } 1555