1999-05-03 09:29:11 +02:00
|
|
|
/* Object file "section" support for the BFD library.
|
2001-03-08 22:04:02 +01:00
|
|
|
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
bfd
* elf-bfd.h (enum elf_link_info_type): Remove.
(struct bfd_elf_section_data): Move sec_info_type, use_rela_p fields
to struct sec. Remove linkonce_p field.
(elf_linkonce_p): Delete.
(elf_discarded_section): Update for sec_info_type change.
* section.c (struct sec): Add sec_info_type, use_rela_p, has_tls_reloc,
flag11, flag12, flag13, flag14, flag15, flag16, flag20, flag24.
(ELF_INFO_TYPE_NONE): Define.
(ELF_INFO_TYPE_STABS): Define.
(ELF_INFO_TYPE_MERGE): Define.
(ELF_INFO_TYPE_EH_FRAME): Define.
(ELF_INFO_TYPE_JUST_SYMS): Define.
(STD_SECTION): Update struct sec initializer.
* ecoff.c (bfd_debug_section): Likewise.
* elf.c: Likewise. Update occurrences of sec_info_type and use_rela_p.
* elflink.h: Likewise.
* elf-eh-frame.c: Likewise.
* elf64-alpha.c: Likewise.
* elfxx-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* bfd-in2.h: Regenerate.
* elf32-sparc.c (sec_do_relax): Use elf_section_data macro rather than
referring to used_by_bfd.
* elf64-sparc.c (sec_do_relax): Likewise.
* elf64-mmix.c (mmix_elf_section_data): Likewise.
* elfxx-mips.c (mips_elf_section_data): Likewise.
* ieee.c (ieee_slurp_section_data): Use ieee_per_section macro.
(ieee_get_section_contents): Likewise.
(ieee_new_section_hook): Formatting.
(ieee_canonicalize_reloc): Remove commented out code.
* mmo.c (mmo_section_data): Define. Use throughout file.
* oasys.c (oasys_get_section_contents): Use oasys_per_section macro.
gas
* config/obj-elf.c (obj_elf_change_section): Set SEC_LINK_ONCE and
SEC_LINK_DUPLICATES_DISCARD directly rather than using elf_linkonce_p.
2003-02-04 13:34:08 +01:00
|
|
|
2000, 2001, 2002, 2003
|
1999-05-03 09:29:11 +02:00
|
|
|
Free Software Foundation, Inc.
|
|
|
|
Written by Cygnus Support.
|
|
|
|
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
SECTION
|
|
|
|
Sections
|
|
|
|
|
|
|
|
The raw data contained within a BFD is maintained through the
|
|
|
|
section abstraction. A single BFD may have any number of
|
|
|
|
sections. It keeps hold of them by pointing to the first;
|
|
|
|
each one points to the next in the list.
|
|
|
|
|
|
|
|
Sections are supported in BFD in <<section.c>>.
|
|
|
|
|
|
|
|
@menu
|
|
|
|
@* Section Input::
|
|
|
|
@* Section Output::
|
|
|
|
@* typedef asection::
|
|
|
|
@* section prototypes::
|
|
|
|
@end menu
|
|
|
|
|
|
|
|
INODE
|
|
|
|
Section Input, Section Output, Sections, Sections
|
|
|
|
SUBSECTION
|
|
|
|
Section input
|
|
|
|
|
|
|
|
When a BFD is opened for reading, the section structures are
|
|
|
|
created and attached to the BFD.
|
|
|
|
|
|
|
|
Each section has a name which describes the section in the
|
|
|
|
outside world---for example, <<a.out>> would contain at least
|
|
|
|
three sections, called <<.text>>, <<.data>> and <<.bss>>.
|
|
|
|
|
|
|
|
Names need not be unique; for example a COFF file may have several
|
|
|
|
sections named <<.data>>.
|
|
|
|
|
|
|
|
Sometimes a BFD will contain more than the ``natural'' number of
|
|
|
|
sections. A back end may attach other sections containing
|
|
|
|
constructor data, or an application may add a section (using
|
|
|
|
<<bfd_make_section>>) to the sections attached to an already open
|
|
|
|
BFD. For example, the linker creates an extra section
|
|
|
|
<<COMMON>> for each input file's BFD to hold information about
|
|
|
|
common storage.
|
|
|
|
|
|
|
|
The raw data is not necessarily read in when
|
|
|
|
the section descriptor is created. Some targets may leave the
|
|
|
|
data in place until a <<bfd_get_section_contents>> call is
|
|
|
|
made. Other back ends may read in all the data at once. For
|
|
|
|
example, an S-record file has to be read once to determine the
|
|
|
|
size of the data. An IEEE-695 file doesn't contain raw data in
|
|
|
|
sections, but data and relocation expressions intermixed, so
|
|
|
|
the data area has to be parsed to get out the data and
|
|
|
|
relocations.
|
|
|
|
|
|
|
|
INODE
|
|
|
|
Section Output, typedef asection, Section Input, Sections
|
|
|
|
|
|
|
|
SUBSECTION
|
|
|
|
Section output
|
|
|
|
|
|
|
|
To write a new object style BFD, the various sections to be
|
|
|
|
written have to be created. They are attached to the BFD in
|
|
|
|
the same way as input sections; data is written to the
|
|
|
|
sections using <<bfd_set_section_contents>>.
|
|
|
|
|
|
|
|
Any program that creates or combines sections (e.g., the assembler
|
|
|
|
and linker) must use the <<asection>> fields <<output_section>> and
|
|
|
|
<<output_offset>> to indicate the file sections to which each
|
|
|
|
section must be written. (If the section is being created from
|
|
|
|
scratch, <<output_section>> should probably point to the section
|
|
|
|
itself and <<output_offset>> should probably be zero.)
|
|
|
|
|
|
|
|
The data to be written comes from input sections attached
|
|
|
|
(via <<output_section>> pointers) to
|
|
|
|
the output sections. The output section structure can be
|
|
|
|
considered a filter for the input section: the output section
|
|
|
|
determines the vma of the output data and the name, but the
|
|
|
|
input section determines the offset into the output section of
|
|
|
|
the data to be written.
|
|
|
|
|
|
|
|
E.g., to create a section "O", starting at 0x100, 0x123 long,
|
|
|
|
containing two subsections, "A" at offset 0x0 (i.e., at vma
|
|
|
|
0x100) and "B" at offset 0x20 (i.e., at vma 0x120) the <<asection>>
|
|
|
|
structures would look like:
|
|
|
|
|
|
|
|
| section name "A"
|
|
|
|
| output_offset 0x00
|
|
|
|
| size 0x20
|
|
|
|
| output_section -----------> section name "O"
|
|
|
|
| | vma 0x100
|
|
|
|
| section name "B" | size 0x123
|
|
|
|
| output_offset 0x20 |
|
|
|
|
| size 0x103 |
|
|
|
|
| output_section --------|
|
|
|
|
|
|
|
|
SUBSECTION
|
|
|
|
Link orders
|
|
|
|
|
|
|
|
The data within a section is stored in a @dfn{link_order}.
|
|
|
|
These are much like the fixups in <<gas>>. The link_order
|
|
|
|
abstraction allows a section to grow and shrink within itself.
|
|
|
|
|
|
|
|
A link_order knows how big it is, and which is the next
|
|
|
|
link_order and where the raw data for it is; it also points to
|
|
|
|
a list of relocations which apply to it.
|
|
|
|
|
|
|
|
The link_order is used by the linker to perform relaxing on
|
|
|
|
final code. The compiler creates code which is as big as
|
|
|
|
necessary to make it work without relaxing, and the user can
|
|
|
|
select whether to relax. Sometimes relaxing takes a lot of
|
|
|
|
time. The linker runs around the relocations to see if any
|
|
|
|
are attached to data which can be shrunk, if so it does it on
|
|
|
|
a link_order by link_order basis.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "bfd.h"
|
|
|
|
#include "sysdep.h"
|
|
|
|
#include "libbfd.h"
|
|
|
|
#include "bfdlink.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
DOCDD
|
|
|
|
INODE
|
|
|
|
typedef asection, section prototypes, Section Output, Sections
|
|
|
|
SUBSECTION
|
|
|
|
typedef asection
|
|
|
|
|
|
|
|
Here is the section structure:
|
|
|
|
|
|
|
|
CODE_FRAGMENT
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
.{* This structure is used for a comdat section, as in PE. A comdat
|
|
|
|
. section is associated with a particular symbol. When the linker
|
|
|
|
. sees a comdat section, it keeps only one of the sections with a
|
|
|
|
. given name and associated with a given symbol. *}
|
1999-09-06 20:34:29 +02:00
|
|
|
.
|
|
|
|
.struct bfd_comdat_info
|
|
|
|
.{
|
|
|
|
. {* The name of the symbol associated with a comdat section. *}
|
|
|
|
. const char *name;
|
|
|
|
.
|
|
|
|
. {* The local symbol table index of the symbol associated with a
|
|
|
|
. comdat section. This is only meaningful to the object file format
|
|
|
|
. specific code; it is not an index into the list returned by
|
|
|
|
. bfd_canonicalize_symtab. *}
|
|
|
|
. long symbol;
|
|
|
|
.};
|
|
|
|
.
|
1999-05-03 09:29:11 +02:00
|
|
|
.typedef struct sec
|
|
|
|
.{
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The name of the section; the name isn't a copy, the pointer is
|
|
|
|
. the same as that passed to bfd_make_section. *}
|
|
|
|
. const char *name;
|
|
|
|
.
|
|
|
|
. {* A unique sequence number. *}
|
|
|
|
. int id;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2001-10-09 08:05:17 +02:00
|
|
|
. {* Which section in the bfd; 0..n-1 as sections are created in a bfd. *}
|
2000-07-08 14:08:43 +02:00
|
|
|
. int index;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The next section in the list belonging to the BFD, or NULL. *}
|
|
|
|
. struct sec *next;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The field flags contains attributes of the section. Some
|
|
|
|
. flags are read in from the object file, and some are
|
|
|
|
. synthesized from other information. *}
|
|
|
|
. flagword flags;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
|
|
|
.#define SEC_NO_FLAGS 0x000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Tells the OS to allocate space for this section when loading.
|
|
|
|
. This is clear for a section containing debug information only. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_ALLOC 0x001
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Tells the OS to load the section from the file when loading.
|
|
|
|
. This is clear for a .bss section. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LOAD 0x002
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section contains data still to be relocated, so there is
|
|
|
|
. some relocation information too. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_RELOC 0x004
|
|
|
|
.
|
2001-09-28 22:51:15 +02:00
|
|
|
. {* ELF reserves 4 processor specific bits and 8 operating system
|
|
|
|
. specific bits in sh_flags; at present we can get away with just
|
|
|
|
. one in communicating between the assembler and BFD, but this
|
|
|
|
. isn't a good long-term solution. *}
|
|
|
|
.#define SEC_ARCH_BIT_0 0x008
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* A signal to the OS that the section contains read only data. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_READONLY 0x010
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section contains code only. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_CODE 0x020
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section contains data only. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_DATA 0x040
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section will reside in ROM. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_ROM 0x080
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section contains constructor information. This section
|
|
|
|
. type is used by the linker to create lists of constructors and
|
|
|
|
. destructors used by <<g++>>. When a back end sees a symbol
|
|
|
|
. which should be used in a constructor list, it creates a new
|
|
|
|
. section for the type of name (e.g., <<__CTOR_LIST__>>), attaches
|
|
|
|
. the symbol to it, and builds a relocation. To build the lists
|
|
|
|
. of constructors, all the linker has to do is catenate all the
|
|
|
|
. sections called <<__CTOR_LIST__>> and relocate the data
|
|
|
|
. contained within - exactly the operations it would peform on
|
|
|
|
. standard data. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_CONSTRUCTOR 0x100
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section has contents - a data section could be
|
|
|
|
. <<SEC_ALLOC>> | <<SEC_HAS_CONTENTS>>; a debug section could be
|
|
|
|
. <<SEC_HAS_CONTENTS>> *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_HAS_CONTENTS 0x200
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* An instruction to the linker to not output the section
|
|
|
|
. even if it has information which would normally be written. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_NEVER_LOAD 0x400
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section is a COFF shared library section. This flag is
|
|
|
|
. only for the linker. If this type of section appears in
|
|
|
|
. the input file, the linker must copy it to the output file
|
|
|
|
. without changing the vma or size. FIXME: Although this
|
|
|
|
. was originally intended to be general, it really is COFF
|
|
|
|
. specific (and the flag was renamed to indicate this). It
|
|
|
|
. might be cleaner to have some more general mechanism to
|
|
|
|
. allow the back end to control what the linker does with
|
|
|
|
. sections. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_COFF_SHARED_LIBRARY 0x800
|
|
|
|
.
|
* elf.c (_bfd_elf_make_section_from_shdr): Set SEC_THREAD_LOCAL
for symbols from SHF_TLS section.
(_bfd_elf_print_private_bfd_data): Add PT_TLS.
(elf_fake_sections): Set SHF_TLS for SEC_THREAD_LOCAL sections.
(map_sections_to_segments): Build PT_TLS segment if necessary.
(assign_file_positions_for_segments): Likewise.
(get_program_header_size): Account for PT_TLS segment.
(swap_out_syms): Set type of BSF_THREAD_LOCAL symbols and symbols from
SEC_THREAD_LOCAL sections to STT_TLS.
* reloc.c: Add 386 and IA-64 TLS relocs.
* section.c (SEC_THREAD_LOCAL): Define.
(SEC_CONSTRUCTOR_TEXT, SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS):
Remove.
* elflink.h (elf_link_add_object_symbols): Support .tcommon.
(size_dynamic_sections): If DF_STATIC_TLS, set DF_FLAGS
unconditionally.
(struct elf_final_link_info): Add first_tls_sec.
(elf_bfd_final_link): Set first_tls_sec.
Compute elf_hash_table (info)->tls_segment.
(elf_link_output_extsym): Handle STT_TLS symbols.
(elf_link_input_bfd): Likewise.
* syms.c (BSF_THREAD_LOCAL): Define.
* bfd-in2.h: Rebuilt.
* libbfd.h: Rebuilt.
* elf32-i386.c (elf_i386_tls_transition, dtpoff_base, tpoff,
elf_i386_mkobject, elf_i386_object_p): New functions.
(elf_howto_table): Add TLS relocs.
(elf_i386_reloc_type_lookup): Support TLS relocs.
(elf_i386_info_to_howto_rel): Likewise.
(struct elf_i386_link_hash_entry): Add tls_type.
(struct elf_i386_obj_tdata): New.
(elf_i386_hash_entry, elf_i386_tdata, elf_i386_local_got_tls_type):
New macros.
(struct elf_i386_link_hash_table): Add tls_ldm_got.
(link_hash_newfunc): Clear tls_type.
(elf_i386_check_relocs): Support TLS relocs.
(elf_i386_gc_sweep_hook): Likewise.
(allocate_dynrelocs): Likewise.
(elf_i386_size_dynamic_sections): Likewise.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_symbol): Likewise.
(bfd_elf32_mkobject, elf_backend_object_p): Define.
* elfxx-ia64.c (struct elfNN_ia64_dyn_sym_info): Add tprel_offset,
dtpmod_offset, dtprel_offset, tprel_done, dtpmod_done, dtprel_done,
want_tprel, want_dtpmod, want_dtprel.
(elfNN_ia64_tprel_base, elfNN_ia64_dtprel_base): New functions.
(ia64_howto_table): Add TLS relocs, rename R_IA64_LTOFF_TP22 to
R_IA64_LTOFF_TPREL22.
(elf_code_to_howto_index): Add TLS relocs.
(elfNN_ia64_check_relocs): Support TLS relocs.
(allocate_global_data_got): Account for TLS .got data.
(allocate_dynrel_entries): Account for TLS dynamic relocations.
(elfNN_ia64_install_value): Supprt TLS relocs.
(set_got_entry): Support TLS relocs.
(elfNN_ia64_relocate_section): Likewise.
* config/obj-elf.c (elf_common): Renamed from obj_elf_common.
(obj_elf_common): Call elf_common.
(obj_elf_tls_common): New function.
(elf_pseudo_tab): Support .tls_common.
(special_sections): Add .tdata and .tbss.
(obj_elf_change_section): Set SEC_THREAD_LOCAL for SHF_TLS
sections.
(obj_elf_parse_section_letters): Support T in section flags (SHF_TLS).
(obj_elf_parse_section_letters): Include T in error message.
* config/tc-ppc.c (ppc_section_letter): Likewise.
* config/tc-alpha.c (alpha_elf_section_letter): Likewise.
(tc_gen_reloc): Handle SEC_THREAD_LOCAL the same way as
SEC_MERGE.
* config/tc-sparc.c (md_apply_fix3): Likewise.
* config/tc-i386.c (tc_i386_fix_adjustable): Add TLS relocs.
Define them if not BFD_ASSEMBLER.
(lex_got): Support @TLSGD, @TLSLDM, @GOTTPOFF, @TPOFF, @DTPOFF
and @NTPOFF.
(md_apply_fix3): Add TLS relocs.
* config/tc-ia64.c (enum reloc_func): Add FUNC_DTP_MODULE,
FUNC_DTP_RELATIVE, FUNC_TP_RELATIVE, FUNC_LT_DTP_MODULE,
FUNC_LT_DTP_RELATIVE, FUNC_LT_TP_RELATIVE.
(pseudo_func): Support @dtpmod(), @dtprel() and @tprel().
(ia64_elf_section_letter): Include T in error message.
(md_begin): Support TLS operators.
(md_operand): Likewise.
(ia64_gen_real_reloc_type): Support TLS relocs.
* testsuite/gas/i386/tlspic.s: New file.
* testsuite/gas/i386/tlsd.s: New file.
* testsuite/gas/i386/tlsnopic.s: New file.
* testsuite/gas/i386/tlsd.d: New file.
* testsuite/gas/i386/tlsnopic.d: New file.
* testsuite/gas/i386/tlspic.d: New file.
* testsuite/gas/i386/i386.exp: Add tlsd, tlsnopic and tlspic tests.
* testsuite/gas/ia64/tls.s: New file.
* testsuite/gas/ia64/tls.d: New file.
* testsuite/gas/ia64/ia64.exp: Add tls test.
* write.c (adjust_reloc_syms): Don't change symbols in
SEC_THREAD_LOCAL sections to STT_SECTION + addend.
* elf/common.h (PT_TLS, SHF_TLS, STT_TLS, DF_STATIC_TLS): Define.
* elf/ia64.h (R_IA64_LTOFF_TPREL22): Renamed from R_IA64_LTOFF_TP22.
* elf/i386.h: Add TLS relocs.
* scripttempl/elf.sc: Add .rel{,a}.t{bss,data}, .tdata and .tbss.
* ldlang.c (lang_add_section): Set SEC_THREAD_LOCAL for
output section if necessary. Handle .tbss.
(lang_size_sections): Clear _raw_size for .tbss section
(it allocates space in PT_TLS segment only).
* ldwrite.c (build_link_order): Build link order for .tbss too.
* readelf.c (get_segment_type): Add PT_TLS.
(get_elf_section_flags): Add SHF_TLS.
(get_dynamic_flags): Optimize. Add DF_STATIC_TLS.
(process_dynamic_segment): Use puts instead of printf.
(get_symbol_type): Support STT_TLS.
* objdump.c (dump_section_header): Remove SEC_CONSTRUCTOR_TEXT,
SEC_CONSTRUCTOR_DATA, SEC_CONSTRUCTOR_BSS.
Add SEC_THREAD_LOCAL.
2002-05-23 15:12:53 +02:00
|
|
|
. {* The section contains thread local data. *}
|
|
|
|
.#define SEC_THREAD_LOCAL 0x1000
|
|
|
|
.
|
2000-09-05 04:42:16 +02:00
|
|
|
. {* The section has GOT references. This flag is only for the
|
|
|
|
. linker, and is currently only used by the elf32-hppa back end.
|
|
|
|
. It will be set if global offset table references were detected
|
|
|
|
. in this section, which indicate to the linker that the section
|
|
|
|
. contains PIC code, and must be handled specially when doing a
|
|
|
|
. static link. *}
|
|
|
|
.#define SEC_HAS_GOT_REF 0x4000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section contains common symbols (symbols may be defined
|
|
|
|
. multiple times, the value of a symbol is the amount of
|
|
|
|
. space it requires, and the largest symbol value is the one
|
|
|
|
. used). Most targets have exactly one of these (which we
|
|
|
|
. translate to bfd_com_section_ptr), but ECOFF has two. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_IS_COMMON 0x8000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The section contains only debugging information. For
|
|
|
|
. example, this is set for ELF .debug and .stab sections.
|
|
|
|
. strip tests this flag to see if a section can be
|
|
|
|
. discarded. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_DEBUGGING 0x10000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The contents of this section are held in memory pointed to
|
|
|
|
. by the contents field. This is checked by bfd_get_section_contents,
|
|
|
|
. and the data is retrieved from memory if appropriate. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_IN_MEMORY 0x20000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The contents of this section are to be excluded by the
|
|
|
|
. linker for executable and shared objects unless those
|
|
|
|
. objects are to be further relocated. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_EXCLUDE 0x40000
|
|
|
|
.
|
2001-10-09 08:05:17 +02:00
|
|
|
. {* The contents of this section are to be sorted based on the sum of
|
|
|
|
. the symbol and addend values specified by the associated relocation
|
|
|
|
. entries. Entries without associated relocation entries will be
|
|
|
|
. appended to the end of the section in an unspecified order. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_SORT_ENTRIES 0x80000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* When linking, duplicate sections of the same name should be
|
|
|
|
. discarded, rather than being combined into a single section as
|
|
|
|
. is usually done. This is similar to how common symbols are
|
|
|
|
. handled. See SEC_LINK_DUPLICATES below. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LINK_ONCE 0x100000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* If SEC_LINK_ONCE is set, this bitfield describes how the linker
|
|
|
|
. should handle duplicate sections. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LINK_DUPLICATES 0x600000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This value for SEC_LINK_DUPLICATES means that duplicate
|
|
|
|
. sections with the same name should simply be discarded. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LINK_DUPLICATES_DISCARD 0x0
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This value for SEC_LINK_DUPLICATES means that the linker
|
|
|
|
. should warn if there are any duplicate sections, although
|
|
|
|
. it should still only link one copy. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This value for SEC_LINK_DUPLICATES means that the linker
|
|
|
|
. should warn if any duplicate sections are a different size. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This value for SEC_LINK_DUPLICATES means that the linker
|
|
|
|
. should warn if any duplicate sections contain different
|
|
|
|
. contents. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This section was created by the linker as part of dynamic
|
|
|
|
. relocation or other arcane processing. It is skipped when
|
|
|
|
. going through the first-pass output, trusting that someone
|
|
|
|
. else up the line will take care of it later. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_LINKER_CREATED 0x800000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This section should not be subject to garbage collection. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define SEC_KEEP 0x1000000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This section contains "short" data, and should be placed
|
|
|
|
. "near" the GP. *}
|
1999-08-09 05:20:31 +02:00
|
|
|
.#define SEC_SMALL_DATA 0x2000000
|
1999-06-15 17:12:23 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* This section contains data which may be shared with other
|
|
|
|
. executables or shared objects. *}
|
1999-08-08 18:50:27 +02:00
|
|
|
.#define SEC_SHARED 0x4000000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* When a section with this flag is being linked, then if the size of
|
|
|
|
. the input section is less than a page, it should not cross a page
|
|
|
|
. boundary. If the size of the input section is one page or more, it
|
|
|
|
. should be aligned on a page boundary. *}
|
2000-04-07 02:58:07 +02:00
|
|
|
.#define SEC_BLOCK 0x8000000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Conditionally link this section; do not link if there are no
|
|
|
|
. references found to any symbol in the section. *}
|
2000-04-07 02:58:07 +02:00
|
|
|
.#define SEC_CLINK 0x10000000
|
|
|
|
.
|
2001-04-14 06:13:00 +02:00
|
|
|
. {* Attempt to merge identical entities in the section.
|
|
|
|
. Entity size is given in the entsize field. *}
|
|
|
|
.#define SEC_MERGE 0x20000000
|
|
|
|
.
|
|
|
|
. {* If given with SEC_MERGE, entities to merge are zero terminated
|
|
|
|
. strings where entsize specifies character size instead of fixed
|
|
|
|
. size entries. *}
|
|
|
|
.#define SEC_STRINGS 0x40000000
|
|
|
|
.
|
2001-10-09 08:05:17 +02:00
|
|
|
. {* This section contains data about section groups. *}
|
|
|
|
.#define SEC_GROUP 0x80000000
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* End of section flags. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Some internal packed boolean fields. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* See the vma field. *}
|
|
|
|
. unsigned int user_set_vma : 1;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Whether relocations have been processed. *}
|
|
|
|
. unsigned int reloc_done : 1;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* A mark flag used by some of the linker backends. *}
|
|
|
|
. unsigned int linker_mark : 1;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2001-05-17 05:58:45 +02:00
|
|
|
. {* Another mark flag used by some of the linker backends. Set for
|
2001-10-10 14:08:29 +02:00
|
|
|
. output sections that have an input section. *}
|
2001-05-17 05:58:45 +02:00
|
|
|
. unsigned int linker_has_input : 1;
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* A mark flag used by some linker backends for garbage collection. *}
|
|
|
|
. unsigned int gc_mark : 1;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
bfd
* elf-bfd.h (enum elf_link_info_type): Remove.
(struct bfd_elf_section_data): Move sec_info_type, use_rela_p fields
to struct sec. Remove linkonce_p field.
(elf_linkonce_p): Delete.
(elf_discarded_section): Update for sec_info_type change.
* section.c (struct sec): Add sec_info_type, use_rela_p, has_tls_reloc,
flag11, flag12, flag13, flag14, flag15, flag16, flag20, flag24.
(ELF_INFO_TYPE_NONE): Define.
(ELF_INFO_TYPE_STABS): Define.
(ELF_INFO_TYPE_MERGE): Define.
(ELF_INFO_TYPE_EH_FRAME): Define.
(ELF_INFO_TYPE_JUST_SYMS): Define.
(STD_SECTION): Update struct sec initializer.
* ecoff.c (bfd_debug_section): Likewise.
* elf.c: Likewise. Update occurrences of sec_info_type and use_rela_p.
* elflink.h: Likewise.
* elf-eh-frame.c: Likewise.
* elf64-alpha.c: Likewise.
* elfxx-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* bfd-in2.h: Regenerate.
* elf32-sparc.c (sec_do_relax): Use elf_section_data macro rather than
referring to used_by_bfd.
* elf64-sparc.c (sec_do_relax): Likewise.
* elf64-mmix.c (mmix_elf_section_data): Likewise.
* elfxx-mips.c (mips_elf_section_data): Likewise.
* ieee.c (ieee_slurp_section_data): Use ieee_per_section macro.
(ieee_get_section_contents): Likewise.
(ieee_new_section_hook): Formatting.
(ieee_canonicalize_reloc): Remove commented out code.
* mmo.c (mmo_section_data): Define. Use throughout file.
* oasys.c (oasys_get_section_contents): Use oasys_per_section macro.
gas
* config/obj-elf.c (obj_elf_change_section): Set SEC_LINK_ONCE and
SEC_LINK_DUPLICATES_DISCARD directly rather than using elf_linkonce_p.
2003-02-04 13:34:08 +01:00
|
|
|
. {* The following flags are used by the ELF linker. *}
|
|
|
|
.
|
|
|
|
. {* Mark sections which have been allocated to segments. *}
|
2000-08-03 21:40:29 +02:00
|
|
|
. unsigned int segment_mark : 1;
|
|
|
|
.
|
bfd
* elf-bfd.h (enum elf_link_info_type): Remove.
(struct bfd_elf_section_data): Move sec_info_type, use_rela_p fields
to struct sec. Remove linkonce_p field.
(elf_linkonce_p): Delete.
(elf_discarded_section): Update for sec_info_type change.
* section.c (struct sec): Add sec_info_type, use_rela_p, has_tls_reloc,
flag11, flag12, flag13, flag14, flag15, flag16, flag20, flag24.
(ELF_INFO_TYPE_NONE): Define.
(ELF_INFO_TYPE_STABS): Define.
(ELF_INFO_TYPE_MERGE): Define.
(ELF_INFO_TYPE_EH_FRAME): Define.
(ELF_INFO_TYPE_JUST_SYMS): Define.
(STD_SECTION): Update struct sec initializer.
* ecoff.c (bfd_debug_section): Likewise.
* elf.c: Likewise. Update occurrences of sec_info_type and use_rela_p.
* elflink.h: Likewise.
* elf-eh-frame.c: Likewise.
* elf64-alpha.c: Likewise.
* elfxx-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* bfd-in2.h: Regenerate.
* elf32-sparc.c (sec_do_relax): Use elf_section_data macro rather than
referring to used_by_bfd.
* elf64-sparc.c (sec_do_relax): Likewise.
* elf64-mmix.c (mmix_elf_section_data): Likewise.
* elfxx-mips.c (mips_elf_section_data): Likewise.
* ieee.c (ieee_slurp_section_data): Use ieee_per_section macro.
(ieee_get_section_contents): Likewise.
(ieee_new_section_hook): Formatting.
(ieee_canonicalize_reloc): Remove commented out code.
* mmo.c (mmo_section_data): Define. Use throughout file.
* oasys.c (oasys_get_section_contents): Use oasys_per_section macro.
gas
* config/obj-elf.c (obj_elf_change_section): Set SEC_LINK_ONCE and
SEC_LINK_DUPLICATES_DISCARD directly rather than using elf_linkonce_p.
2003-02-04 13:34:08 +01:00
|
|
|
. {* Type of sec_info information. *}
|
|
|
|
. unsigned int sec_info_type:3;
|
|
|
|
.#define ELF_INFO_TYPE_NONE 0
|
|
|
|
.#define ELF_INFO_TYPE_STABS 1
|
|
|
|
.#define ELF_INFO_TYPE_MERGE 2
|
|
|
|
.#define ELF_INFO_TYPE_EH_FRAME 3
|
|
|
|
.#define ELF_INFO_TYPE_JUST_SYMS 4
|
|
|
|
.
|
|
|
|
. {* Nonzero if this section uses RELA relocations, rather than REL. *}
|
|
|
|
. unsigned int use_rela_p:1;
|
|
|
|
.
|
|
|
|
. {* Bits used by various backends. *}
|
|
|
|
. unsigned int has_tls_reloc:1;
|
|
|
|
.
|
2003-04-29 03:53:46 +02:00
|
|
|
. {* Nonzero if this section needs the relax finalize pass. *}
|
|
|
|
. unsigned int need_finalize_relax:1;
|
|
|
|
.
|
2003-06-08 16:06:38 +02:00
|
|
|
. {* Nonzero if this section has a gp reloc. *}
|
|
|
|
. unsigned int has_gp_reloc:1;
|
|
|
|
.
|
bfd
* elf-bfd.h (enum elf_link_info_type): Remove.
(struct bfd_elf_section_data): Move sec_info_type, use_rela_p fields
to struct sec. Remove linkonce_p field.
(elf_linkonce_p): Delete.
(elf_discarded_section): Update for sec_info_type change.
* section.c (struct sec): Add sec_info_type, use_rela_p, has_tls_reloc,
flag11, flag12, flag13, flag14, flag15, flag16, flag20, flag24.
(ELF_INFO_TYPE_NONE): Define.
(ELF_INFO_TYPE_STABS): Define.
(ELF_INFO_TYPE_MERGE): Define.
(ELF_INFO_TYPE_EH_FRAME): Define.
(ELF_INFO_TYPE_JUST_SYMS): Define.
(STD_SECTION): Update struct sec initializer.
* ecoff.c (bfd_debug_section): Likewise.
* elf.c: Likewise. Update occurrences of sec_info_type and use_rela_p.
* elflink.h: Likewise.
* elf-eh-frame.c: Likewise.
* elf64-alpha.c: Likewise.
* elfxx-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* bfd-in2.h: Regenerate.
* elf32-sparc.c (sec_do_relax): Use elf_section_data macro rather than
referring to used_by_bfd.
* elf64-sparc.c (sec_do_relax): Likewise.
* elf64-mmix.c (mmix_elf_section_data): Likewise.
* elfxx-mips.c (mips_elf_section_data): Likewise.
* ieee.c (ieee_slurp_section_data): Use ieee_per_section macro.
(ieee_get_section_contents): Likewise.
(ieee_new_section_hook): Formatting.
(ieee_canonicalize_reloc): Remove commented out code.
* mmo.c (mmo_section_data): Define. Use throughout file.
* oasys.c (oasys_get_section_contents): Use oasys_per_section macro.
gas
* config/obj-elf.c (obj_elf_change_section): Set SEC_LINK_ONCE and
SEC_LINK_DUPLICATES_DISCARD directly rather than using elf_linkonce_p.
2003-02-04 13:34:08 +01:00
|
|
|
. {* Usused bits. *}
|
|
|
|
. unsigned int flag13:1;
|
|
|
|
. unsigned int flag14:1;
|
|
|
|
. unsigned int flag15:1;
|
|
|
|
. unsigned int flag16:4;
|
|
|
|
. unsigned int flag20:4;
|
|
|
|
. unsigned int flag24:8;
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* End of internal packed boolean fields. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The virtual memory address of the section - where it will be
|
|
|
|
. at run time. The symbols are relocated against this. The
|
|
|
|
. user_set_vma flag is maintained by bfd; if it's not set, the
|
|
|
|
. backend can assign addresses (for example, in <<a.out>>, where
|
|
|
|
. the default address for <<.data>> is dependent on the specific
|
|
|
|
. target and various flags). *}
|
|
|
|
. bfd_vma vma;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The load address of the section - where it would be in a
|
|
|
|
. rom image; really only used for writing section header
|
2002-01-30 19:12:17 +01:00
|
|
|
. information. *}
|
2000-07-08 14:08:43 +02:00
|
|
|
. bfd_vma lma;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The size of the section in octets, as it will be output.
|
|
|
|
. Contains a value even if the section has no contents (e.g., the
|
|
|
|
. size of <<.bss>>). This will be filled in after relocation. *}
|
|
|
|
. bfd_size_type _cooked_size;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The original size on disk of the section, in octets. Normally this
|
|
|
|
. value is the same as the size, but if some relaxing has
|
|
|
|
. been done, then this value will be bigger. *}
|
|
|
|
. bfd_size_type _raw_size;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* If this section is going to be output, then this value is the
|
|
|
|
. offset in *bytes* into the output section of the first byte in the
|
|
|
|
. input section (byte ==> smallest addressable unit on the
|
|
|
|
. target). In most cases, if this was going to start at the
|
|
|
|
. 100th octet (8-bit quantity) in the output section, this value
|
|
|
|
. would be 100. However, if the target byte size is 16 bits
|
|
|
|
. (bfd_octets_per_byte is "2"), this value would be 50. *}
|
|
|
|
. bfd_vma output_offset;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The output section through which to map on output. *}
|
|
|
|
. struct sec *output_section;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The alignment requirement of the section, as an exponent of 2 -
|
|
|
|
. e.g., 3 aligns to 2^3 (or 8). *}
|
|
|
|
. unsigned int alignment_power;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* If an input section, a pointer to a vector of relocation
|
|
|
|
. records for the data in this section. *}
|
|
|
|
. struct reloc_cache_entry *relocation;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* If an output section, a pointer to a vector of pointers to
|
|
|
|
. relocation records for the data in this section. *}
|
|
|
|
. struct reloc_cache_entry **orelocation;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2002-01-30 19:12:17 +01:00
|
|
|
. {* The number of relocation records in one of the above. *}
|
2000-07-08 14:08:43 +02:00
|
|
|
. unsigned reloc_count;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Information below is back end specific - and not always used
|
|
|
|
. or updated. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* File position of section data. *}
|
|
|
|
. file_ptr filepos;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* File position of relocation info. *}
|
|
|
|
. file_ptr rel_filepos;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* File position of line data. *}
|
|
|
|
. file_ptr line_filepos;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Pointer to data for applications. *}
|
|
|
|
. PTR userdata;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* If the SEC_IN_MEMORY flag is set, this points to the actual
|
|
|
|
. contents. *}
|
|
|
|
. unsigned char *contents;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Attached line number information. *}
|
|
|
|
. alent *lineno;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Number of line number records. *}
|
|
|
|
. unsigned int lineno_count;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2001-04-14 06:13:00 +02:00
|
|
|
. {* Entity size for merging purposes. *}
|
|
|
|
. unsigned int entsize;
|
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* Optional information about a COMDAT entry; NULL if not COMDAT. *}
|
|
|
|
. struct bfd_comdat_info *comdat;
|
1999-09-06 20:34:29 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* When a section is being output, this value changes as more
|
|
|
|
. linenumbers are written out. *}
|
|
|
|
. file_ptr moving_line_filepos;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* What the section number is in the target world. *}
|
|
|
|
. int target_index;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. PTR used_by_bfd;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* If this is a constructor section then here is a list of the
|
|
|
|
. relocations created to relocate items within it. *}
|
|
|
|
. struct relent_chain *constructor_chain;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. {* The BFD which owns the section. *}
|
|
|
|
. bfd *owner;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2002-01-30 19:12:17 +01:00
|
|
|
. {* A symbol which points at this section only. *}
|
2000-07-08 14:08:43 +02:00
|
|
|
. struct symbol_cache_entry *symbol;
|
|
|
|
. struct symbol_cache_entry **symbol_ptr_ptr;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
. struct bfd_link_order *link_order_head;
|
|
|
|
. struct bfd_link_order *link_order_tail;
|
2002-01-30 19:12:17 +01:00
|
|
|
.} asection;
|
1999-05-03 09:29:11 +02:00
|
|
|
.
|
2000-07-08 14:08:43 +02:00
|
|
|
.{* These sections are global, and are managed by BFD. The application
|
|
|
|
. and target back end are not permitted to change the values in
|
|
|
|
. these sections. New code should use the section_ptr macros rather
|
|
|
|
. than referring directly to the const sections. The const sections
|
|
|
|
. may eventually vanish. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define BFD_ABS_SECTION_NAME "*ABS*"
|
|
|
|
.#define BFD_UND_SECTION_NAME "*UND*"
|
|
|
|
.#define BFD_COM_SECTION_NAME "*COM*"
|
|
|
|
.#define BFD_IND_SECTION_NAME "*IND*"
|
|
|
|
.
|
2002-01-30 19:12:17 +01:00
|
|
|
.{* The absolute section. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.extern const asection bfd_abs_section;
|
|
|
|
.#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)
|
|
|
|
.#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)
|
2002-01-30 19:12:17 +01:00
|
|
|
.{* Pointer to the undefined section. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.extern const asection bfd_und_section;
|
|
|
|
.#define bfd_und_section_ptr ((asection *) &bfd_und_section)
|
|
|
|
.#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)
|
2002-01-30 19:12:17 +01:00
|
|
|
.{* Pointer to the common section. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.extern const asection bfd_com_section;
|
|
|
|
.#define bfd_com_section_ptr ((asection *) &bfd_com_section)
|
2002-01-30 19:12:17 +01:00
|
|
|
.{* Pointer to the indirect section. *}
|
1999-05-03 09:29:11 +02:00
|
|
|
.extern const asection bfd_ind_section;
|
|
|
|
.#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)
|
|
|
|
.#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)
|
|
|
|
.
|
2001-11-19 16:35:38 +01:00
|
|
|
.#define bfd_is_const_section(SEC) \
|
|
|
|
. ( ((SEC) == bfd_abs_section_ptr) \
|
|
|
|
. || ((SEC) == bfd_und_section_ptr) \
|
|
|
|
. || ((SEC) == bfd_com_section_ptr) \
|
|
|
|
. || ((SEC) == bfd_ind_section_ptr))
|
|
|
|
.
|
1999-05-03 09:29:11 +02:00
|
|
|
.extern const struct symbol_cache_entry * const bfd_abs_symbol;
|
|
|
|
.extern const struct symbol_cache_entry * const bfd_com_symbol;
|
|
|
|
.extern const struct symbol_cache_entry * const bfd_und_symbol;
|
|
|
|
.extern const struct symbol_cache_entry * const bfd_ind_symbol;
|
|
|
|
.#define bfd_get_section_size_before_reloc(section) \
|
2000-02-21 13:01:27 +01:00
|
|
|
. ((section)->reloc_done ? (abort (), (bfd_size_type) 1) \
|
|
|
|
. : (section)->_raw_size)
|
1999-05-03 09:29:11 +02:00
|
|
|
.#define bfd_get_section_size_after_reloc(section) \
|
2000-02-21 13:01:27 +01:00
|
|
|
. ((section)->reloc_done ? (section)->_cooked_size \
|
|
|
|
. : (abort (), (bfd_size_type) 1))
|
2002-01-05 14:11:33 +01:00
|
|
|
.
|
|
|
|
.{* Macros to handle insertion and deletion of a bfd's sections. These
|
|
|
|
. only handle the list pointers, ie. do not adjust section_count,
|
|
|
|
. target_index etc. *}
|
|
|
|
.#define bfd_section_list_remove(ABFD, PS) \
|
|
|
|
. do \
|
|
|
|
. { \
|
|
|
|
. asection **_ps = PS; \
|
|
|
|
. asection *_s = *_ps; \
|
|
|
|
. *_ps = _s->next; \
|
|
|
|
. if (_s->next == NULL) \
|
|
|
|
. (ABFD)->section_tail = _ps; \
|
|
|
|
. } \
|
|
|
|
. while (0)
|
|
|
|
.#define bfd_section_list_insert(ABFD, PS, S) \
|
|
|
|
. do \
|
|
|
|
. { \
|
|
|
|
. asection **_ps = PS; \
|
|
|
|
. asection *_s = S; \
|
|
|
|
. _s->next = *_ps; \
|
|
|
|
. *_ps = _s; \
|
|
|
|
. if (_s->next == NULL) \
|
|
|
|
. (ABFD)->section_tail = &_s->next; \
|
|
|
|
. } \
|
|
|
|
. while (0)
|
|
|
|
.
|
1999-05-03 09:29:11 +02:00
|
|
|
*/
|
|
|
|
|
1999-08-07 01:31:14 +02:00
|
|
|
/* We use a macro to initialize the static asymbol structures because
|
|
|
|
traditional C does not permit us to initialize a union member while
|
|
|
|
gcc warns if we don't initialize it. */
|
|
|
|
/* the_bfd, name, value, attr, section [, udata] */
|
|
|
|
#ifdef __STDC__
|
|
|
|
#define GLOBAL_SYM_INIT(NAME, SECTION) \
|
|
|
|
{ 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION, { 0 }}
|
|
|
|
#else
|
|
|
|
#define GLOBAL_SYM_INIT(NAME, SECTION) \
|
|
|
|
{ 0, NAME, 0, BSF_SECTION_SYM, (asection *) SECTION }
|
|
|
|
#endif
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
/* These symbols are global, not specific to any BFD. Therefore, anything
|
|
|
|
that tries to change them is broken, and should be repaired. */
|
1999-08-07 01:31:14 +02:00
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
static const asymbol global_syms[] =
|
|
|
|
{
|
1999-08-07 01:31:14 +02:00
|
|
|
GLOBAL_SYM_INIT (BFD_COM_SECTION_NAME, &bfd_com_section),
|
|
|
|
GLOBAL_SYM_INIT (BFD_UND_SECTION_NAME, &bfd_und_section),
|
|
|
|
GLOBAL_SYM_INIT (BFD_ABS_SECTION_NAME, &bfd_abs_section),
|
|
|
|
GLOBAL_SYM_INIT (BFD_IND_SECTION_NAME, &bfd_ind_section)
|
1999-05-03 09:29:11 +02:00
|
|
|
};
|
|
|
|
|
2000-08-03 21:40:29 +02:00
|
|
|
#define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \
|
|
|
|
const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
|
|
|
|
const asection SEC = \
|
2000-07-10 04:05:40 +02:00
|
|
|
/* name, id, index, next, flags, user_set_vma, reloc_done, */ \
|
|
|
|
{ NAME, IDX, 0, NULL, FLAGS, 0, 0, \
|
2000-07-08 14:08:43 +02:00
|
|
|
\
|
2001-05-17 05:58:45 +02:00
|
|
|
/* linker_mark, linker_has_input, gc_mark, segment_mark, */ \
|
|
|
|
0, 0, 1, 0, \
|
|
|
|
\
|
2003-06-08 16:06:38 +02:00
|
|
|
/* sec_info_type, use_rela_p, has_tls_reloc, */ \
|
|
|
|
0, 0, 0, \
|
|
|
|
\
|
|
|
|
/* need_finalize_relax, has_gp_reloc, */ \
|
|
|
|
0, 0, \
|
bfd
* elf-bfd.h (enum elf_link_info_type): Remove.
(struct bfd_elf_section_data): Move sec_info_type, use_rela_p fields
to struct sec. Remove linkonce_p field.
(elf_linkonce_p): Delete.
(elf_discarded_section): Update for sec_info_type change.
* section.c (struct sec): Add sec_info_type, use_rela_p, has_tls_reloc,
flag11, flag12, flag13, flag14, flag15, flag16, flag20, flag24.
(ELF_INFO_TYPE_NONE): Define.
(ELF_INFO_TYPE_STABS): Define.
(ELF_INFO_TYPE_MERGE): Define.
(ELF_INFO_TYPE_EH_FRAME): Define.
(ELF_INFO_TYPE_JUST_SYMS): Define.
(STD_SECTION): Update struct sec initializer.
* ecoff.c (bfd_debug_section): Likewise.
* elf.c: Likewise. Update occurrences of sec_info_type and use_rela_p.
* elflink.h: Likewise.
* elf-eh-frame.c: Likewise.
* elf64-alpha.c: Likewise.
* elfxx-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* bfd-in2.h: Regenerate.
* elf32-sparc.c (sec_do_relax): Use elf_section_data macro rather than
referring to used_by_bfd.
* elf64-sparc.c (sec_do_relax): Likewise.
* elf64-mmix.c (mmix_elf_section_data): Likewise.
* elfxx-mips.c (mips_elf_section_data): Likewise.
* ieee.c (ieee_slurp_section_data): Use ieee_per_section macro.
(ieee_get_section_contents): Likewise.
(ieee_new_section_hook): Formatting.
(ieee_canonicalize_reloc): Remove commented out code.
* mmo.c (mmo_section_data): Define. Use throughout file.
* oasys.c (oasys_get_section_contents): Use oasys_per_section macro.
gas
* config/obj-elf.c (obj_elf_change_section): Set SEC_LINK_ONCE and
SEC_LINK_DUPLICATES_DISCARD directly rather than using elf_linkonce_p.
2003-02-04 13:34:08 +01:00
|
|
|
\
|
|
|
|
/* flag13, flag14, flag15, flag16, flag20, flag24, */ \
|
|
|
|
0, 0, 0, 0, 0, 0, \
|
|
|
|
\
|
2001-05-17 05:58:45 +02:00
|
|
|
/* vma, lma, _cooked_size, _raw_size, */ \
|
|
|
|
0, 0, 0, 0, \
|
2000-07-08 14:08:43 +02:00
|
|
|
\
|
2001-05-17 05:58:45 +02:00
|
|
|
/* output_offset, output_section, alignment_power, */ \
|
|
|
|
0, (struct sec *) &SEC, 0, \
|
2000-07-08 14:08:43 +02:00
|
|
|
\
|
|
|
|
/* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \
|
|
|
|
NULL, NULL, 0, 0, 0, \
|
|
|
|
\
|
|
|
|
/* line_filepos, userdata, contents, lineno, lineno_count, */ \
|
|
|
|
0, NULL, NULL, NULL, 0, \
|
|
|
|
\
|
2001-09-29 14:07:01 +02:00
|
|
|
/* entsize, comdat, moving_line_filepos, */ \
|
|
|
|
0, NULL, 0, \
|
2000-07-08 14:08:43 +02:00
|
|
|
\
|
2001-04-14 16:23:31 +02:00
|
|
|
/* target_index, used_by_bfd, constructor_chain, owner, */ \
|
|
|
|
0, NULL, NULL, NULL, \
|
2000-07-08 14:08:43 +02:00
|
|
|
\
|
|
|
|
/* symbol, */ \
|
|
|
|
(struct symbol_cache_entry *) &global_syms[IDX], \
|
|
|
|
\
|
|
|
|
/* symbol_ptr_ptr, */ \
|
|
|
|
(struct symbol_cache_entry **) &SYM, \
|
|
|
|
\
|
|
|
|
/* link_order_head, link_order_tail */ \
|
|
|
|
NULL, NULL \
|
1999-09-06 20:34:29 +02:00
|
|
|
}
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
|
|
|
|
BFD_COM_SECTION_NAME, 0);
|
|
|
|
STD_SECTION (bfd_und_section, 0, bfd_und_symbol, BFD_UND_SECTION_NAME, 1);
|
|
|
|
STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2);
|
|
|
|
STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3);
|
|
|
|
#undef STD_SECTION
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
struct section_hash_entry
|
|
|
|
{
|
|
|
|
struct bfd_hash_entry root;
|
|
|
|
asection section;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Initialize an entry in the section hash table. */
|
|
|
|
|
|
|
|
struct bfd_hash_entry *
|
|
|
|
bfd_section_hash_newfunc (entry, table, string)
|
|
|
|
struct bfd_hash_entry *entry;
|
|
|
|
struct bfd_hash_table *table;
|
|
|
|
const char *string;
|
|
|
|
{
|
|
|
|
/* Allocate the structure if it has not already been allocated by a
|
|
|
|
subclass. */
|
|
|
|
if (entry == NULL)
|
|
|
|
{
|
* aoutx.h (NAME(aout,swap_ext_reloc_in)): Cast bytes->r_index to
unsigned int. Cast RELOC_BASE10, RELOC_BASE13 and RELOC_BASE22 to
unsigned int.
(NAME(aout,final_link)): Cast enum used in assignment.
(aout_link_write_symbols): Cast enums in comparisons, int values to
boolean, enums in assignments to int.
(aout_link_input_section_std): Cast rel->r_index to unsigned int.
(aout_link_input_section_ext): Likewise. Cast enums used in comparisons
with unsigned ints.
(aout_link_reloc_link_order): Cast enum to int in assignment.
* archive.c (_bfd_generic_read_ar_hdr_mag): Cast result of memchr
calls to char *.
* bfd-in.h (bfd_set_section_vma): Cast enum true to unsigned int in
assignment.
* bfd-in2.h (bfd_set_section_vma): Likewise.
* bfd.c (bfd_record_phdr): Cast enums in assignments.
* binary.c (bfd_alloc): Cast enum to long.
* coffgen.c (_bfd_coff_is_local_label_name): Cast return to boolean.
* dwarf2.c (read_abbrevs): Add casts to enum types.
(read_attribute_value): Likewise.
(arange_add): Cast result of bfd_zalloc call.
(comp_unit_contains_address): Return true and false.
(comp_unit_find_nearest_line): Cast return to boolean.
* format.c (bfd_check_format_matches, bfd_set_format): Likewise.
* gen-aout.c: define macro '_' if not defined.
* libbfd.c (bfd_realloc): Cast malloc and realloc to PTR.
(bfd_bwrite): Cast bfd_realloc to bfd_byte *.
(bfd_write_bigendian_4byte_int): Cast return to boolean.
(bfd_seek): Cast bfd_realloc to bfd_byte *.
(bfd_generic_is_local_label_name): Cast return to boolean.
* libcoff.h (_bfd_coff_adjust_symndx): Remove extraneous '\'.
* linker.c (_bfd_link_hash_newfunc): Cast bfd_hash_allocate result to
struct bfd_hash_entry *.
(_bfd_generic_link_hash_newfunc): likewise.
(_bfd_generic_final_link): Cast enum to unsigned int.
* merge.c (sec_merge_emit): Cast return to boolean.
(merge_strings): Add casts to const unsigned char *.
* reloc.c (bfd_get_reloc_code_name): Cast enums in comparison to int.
(bfd_generic_get_relocated_section_content): Cast enum to unsigned int.
* section.c (bfd_section_hash_newfunc): Cast bfd_hash_allocate result to
struct bfd_hash_entry *.
(bfd_set_section_content): Add cast to PTR in comparison.
* simple.c (simple_dummy_warning, simple_dummy_undefined_symbol,
simple_dummy_reloc_overflow, simple_dummy_reloc_dangerous,
simple_dummy_unattached_reloc,
bfd_simple_get_relocated_section_contents): Add K&R declarations and
function definitions.
* srec.c (S3Forced): Initialize to false.
(srec_get_symtab): Cast return value from bfd_alloc to asymbol *.
* stabs.c (_bfd_link_section_stabs): Cast enum to int in comparisons.
(_bfd_discard_section_stabs): Likewise. Also cast return to boolean.
* syms.c (bfd_is_undefined_symclass): Cast return to boolean.
(_bfd_stab_section_find_nearest_line): Cast enum to bfd_byte in
comparisons.
2002-10-25 04:45:54 +02:00
|
|
|
entry = (struct bfd_hash_entry *)
|
|
|
|
bfd_hash_allocate (table, sizeof (struct section_hash_entry));
|
2001-12-17 01:40:53 +01:00
|
|
|
if (entry == NULL)
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the allocation method of the superclass. */
|
|
|
|
entry = bfd_hash_newfunc (entry, table, string);
|
|
|
|
if (entry != NULL)
|
|
|
|
{
|
|
|
|
memset ((PTR) &((struct section_hash_entry *) entry)->section,
|
|
|
|
0, sizeof (asection));
|
|
|
|
}
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define section_hash_lookup(table, string, create, copy) \
|
|
|
|
((struct section_hash_entry *) \
|
|
|
|
bfd_hash_lookup ((table), (string), (create), (copy)))
|
|
|
|
|
|
|
|
/* Initializes a new section. NEWSECT->NAME is already set. */
|
|
|
|
|
|
|
|
static asection *bfd_section_init PARAMS ((bfd *, asection *));
|
|
|
|
|
|
|
|
static asection *
|
|
|
|
bfd_section_init (abfd, newsect)
|
|
|
|
bfd *abfd;
|
|
|
|
asection *newsect;
|
|
|
|
{
|
|
|
|
static int section_id = 0x10; /* id 0 to 3 used by STD_SECTION. */
|
|
|
|
|
|
|
|
newsect->id = section_id;
|
|
|
|
newsect->index = abfd->section_count;
|
|
|
|
newsect->owner = abfd;
|
|
|
|
|
|
|
|
/* Create a symbol whose only job is to point to this section. This
|
|
|
|
is useful for things like relocs which are relative to the base
|
|
|
|
of a section. */
|
|
|
|
newsect->symbol = bfd_make_empty_symbol (abfd);
|
|
|
|
if (newsect->symbol == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
newsect->symbol->name = newsect->name;
|
|
|
|
newsect->symbol->value = 0;
|
|
|
|
newsect->symbol->section = newsect;
|
|
|
|
newsect->symbol->flags = BSF_SECTION_SYM;
|
|
|
|
|
|
|
|
newsect->symbol_ptr_ptr = &newsect->symbol;
|
|
|
|
|
|
|
|
if (! BFD_SEND (abfd, _new_section_hook, (abfd, newsect)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
section_id++;
|
|
|
|
abfd->section_count++;
|
|
|
|
*abfd->section_tail = newsect;
|
|
|
|
abfd->section_tail = &newsect->next;
|
|
|
|
return newsect;
|
|
|
|
}
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
/*
|
|
|
|
DOCDD
|
|
|
|
INODE
|
|
|
|
section prototypes, , typedef asection, Sections
|
|
|
|
SUBSECTION
|
|
|
|
Section prototypes
|
|
|
|
|
|
|
|
These are the functions exported by the section handling part of BFD.
|
|
|
|
*/
|
|
|
|
|
2002-01-05 14:11:33 +01:00
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_section_list_clear
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
void bfd_section_list_clear (bfd *);
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Clears the section list, and also resets the section count and
|
|
|
|
hash table entries.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
bfd_section_list_clear (abfd)
|
|
|
|
bfd *abfd;
|
|
|
|
{
|
|
|
|
abfd->sections = NULL;
|
|
|
|
abfd->section_tail = &abfd->sections;
|
|
|
|
abfd->section_count = 0;
|
|
|
|
memset ((PTR) abfd->section_htab.table, 0,
|
|
|
|
abfd->section_htab.size * sizeof (struct bfd_hash_entry *));
|
|
|
|
}
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_get_section_by_name
|
|
|
|
|
|
|
|
SYNOPSIS
|
2000-07-08 14:08:43 +02:00
|
|
|
asection *bfd_get_section_by_name(bfd *abfd, const char *name);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Run through @var{abfd} and return the one of the
|
|
|
|
<<asection>>s whose name matches @var{name}, otherwise <<NULL>>.
|
|
|
|
@xref{Sections}, for more information.
|
|
|
|
|
|
|
|
This should only be used in special cases; the normal way to process
|
|
|
|
all sections of a given name is to use <<bfd_map_over_sections>> and
|
|
|
|
<<strcmp>> on the name (or better yet, base it on the section flags
|
|
|
|
or something else) for each section.
|
|
|
|
*/
|
|
|
|
|
|
|
|
asection *
|
|
|
|
bfd_get_section_by_name (abfd, name)
|
|
|
|
bfd *abfd;
|
2000-07-08 14:08:43 +02:00
|
|
|
const char *name;
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
struct section_hash_entry *sh;
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE);
|
2001-12-17 01:40:53 +01:00
|
|
|
if (sh != NULL)
|
|
|
|
return &sh->section;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-09-05 04:42:16 +02:00
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_get_unique_section_name
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
char *bfd_get_unique_section_name(bfd *abfd,
|
2000-09-06 02:22:01 +02:00
|
|
|
const char *templat,
|
2000-09-05 04:42:16 +02:00
|
|
|
int *count);
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Invent a section name that is unique in @var{abfd} by tacking
|
2000-09-08 04:11:34 +02:00
|
|
|
a dot and a digit suffix onto the original @var{templat}. If
|
|
|
|
@var{count} is non-NULL, then it specifies the first number
|
|
|
|
tried as a suffix to generate a unique name. The value
|
|
|
|
pointed to by @var{count} will be incremented in this case.
|
2000-09-05 04:42:16 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
char *
|
2000-09-06 02:22:01 +02:00
|
|
|
bfd_get_unique_section_name (abfd, templat, count)
|
2000-09-05 04:42:16 +02:00
|
|
|
bfd *abfd;
|
2000-09-06 02:22:01 +02:00
|
|
|
const char *templat;
|
2000-09-05 04:42:16 +02:00
|
|
|
int *count;
|
|
|
|
{
|
|
|
|
int num;
|
|
|
|
unsigned int len;
|
|
|
|
char *sname;
|
|
|
|
|
2000-09-06 02:22:01 +02:00
|
|
|
len = strlen (templat);
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
sname = bfd_malloc ((bfd_size_type) len + 8);
|
2000-09-20 06:20:26 +02:00
|
|
|
if (sname == NULL)
|
|
|
|
return NULL;
|
2002-06-25 11:40:45 +02:00
|
|
|
memcpy (sname, templat, len);
|
2000-09-05 04:42:16 +02:00
|
|
|
num = 1;
|
|
|
|
if (count != NULL)
|
|
|
|
num = *count;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
/* If we have a million sections, something is badly wrong. */
|
|
|
|
if (num > 999999)
|
|
|
|
abort ();
|
2000-09-08 04:11:34 +02:00
|
|
|
sprintf (sname + len, ".%d", num++);
|
2000-09-05 04:42:16 +02:00
|
|
|
}
|
2002-11-30 09:39:46 +01:00
|
|
|
while (section_hash_lookup (&abfd->section_htab, sname, FALSE, FALSE));
|
2000-09-05 04:42:16 +02:00
|
|
|
|
|
|
|
if (count != NULL)
|
|
|
|
*count = num;
|
|
|
|
return sname;
|
|
|
|
}
|
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_make_section_old_way
|
|
|
|
|
|
|
|
SYNOPSIS
|
2000-07-08 14:08:43 +02:00
|
|
|
asection *bfd_make_section_old_way(bfd *abfd, const char *name);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Create a new empty section called @var{name}
|
|
|
|
and attach it to the end of the chain of sections for the
|
|
|
|
BFD @var{abfd}. An attempt to create a section with a name which
|
|
|
|
is already in use returns its pointer without changing the
|
|
|
|
section chain.
|
|
|
|
|
|
|
|
It has the funny name since this is the way it used to be
|
|
|
|
before it was rewritten....
|
|
|
|
|
|
|
|
Possible errors are:
|
|
|
|
o <<bfd_error_invalid_operation>> -
|
|
|
|
If output has already started for this BFD.
|
|
|
|
o <<bfd_error_no_memory>> -
|
|
|
|
If memory allocation fails.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
asection *
|
|
|
|
bfd_make_section_old_way (abfd, name)
|
|
|
|
bfd *abfd;
|
2000-07-08 14:08:43 +02:00
|
|
|
const char *name;
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
struct section_hash_entry *sh;
|
|
|
|
asection *newsect;
|
|
|
|
|
|
|
|
if (abfd->output_has_begun)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp (name, BFD_ABS_SECTION_NAME) == 0)
|
|
|
|
return bfd_abs_section_ptr;
|
|
|
|
|
|
|
|
if (strcmp (name, BFD_COM_SECTION_NAME) == 0)
|
|
|
|
return bfd_com_section_ptr;
|
|
|
|
|
|
|
|
if (strcmp (name, BFD_UND_SECTION_NAME) == 0)
|
|
|
|
return bfd_und_section_ptr;
|
|
|
|
|
|
|
|
if (strcmp (name, BFD_IND_SECTION_NAME) == 0)
|
|
|
|
return bfd_ind_section_ptr;
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
|
2001-12-17 01:40:53 +01:00
|
|
|
if (sh == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
newsect = &sh->section;
|
|
|
|
if (newsect->name != NULL)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
/* Section already exists. */
|
|
|
|
return newsect;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
2001-12-17 01:40:53 +01:00
|
|
|
|
|
|
|
newsect->name = name;
|
|
|
|
return bfd_section_init (abfd, newsect);
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_make_section_anyway
|
|
|
|
|
|
|
|
SYNOPSIS
|
2000-07-08 14:08:43 +02:00
|
|
|
asection *bfd_make_section_anyway(bfd *abfd, const char *name);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Create a new empty section called @var{name} and attach it to the end of
|
|
|
|
the chain of sections for @var{abfd}. Create a new section even if there
|
|
|
|
is already a section with that name.
|
|
|
|
|
|
|
|
Return <<NULL>> and set <<bfd_error>> on error; possible errors are:
|
|
|
|
o <<bfd_error_invalid_operation>> - If output has already started for @var{abfd}.
|
|
|
|
o <<bfd_error_no_memory>> - If memory allocation fails.
|
|
|
|
*/
|
|
|
|
|
|
|
|
sec_ptr
|
|
|
|
bfd_make_section_anyway (abfd, name)
|
|
|
|
bfd *abfd;
|
2000-07-08 14:08:43 +02:00
|
|
|
const char *name;
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
struct section_hash_entry *sh;
|
1999-05-03 09:29:11 +02:00
|
|
|
asection *newsect;
|
|
|
|
|
|
|
|
if (abfd->output_has_begun)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
|
2001-12-17 01:40:53 +01:00
|
|
|
if (sh == NULL)
|
1999-05-03 09:29:11 +02:00
|
|
|
return NULL;
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
newsect = &sh->section;
|
|
|
|
if (newsect->name != NULL)
|
2000-10-10 17:23:38 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
/* We are making a section of the same name. It can't go in
|
|
|
|
section_htab without generating a unique section name and
|
|
|
|
that would be pointless; We don't need to traverse the
|
|
|
|
hash table. */
|
|
|
|
newsect = (asection *) bfd_zalloc (abfd, sizeof (asection));
|
|
|
|
if (newsect == NULL)
|
|
|
|
return NULL;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
newsect->name = name;
|
|
|
|
return bfd_section_init (abfd, newsect);
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_make_section
|
|
|
|
|
|
|
|
SYNOPSIS
|
2000-07-08 14:08:43 +02:00
|
|
|
asection *bfd_make_section(bfd *, const char *name);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling
|
|
|
|
bfd_set_error ()) without changing the section chain if there is already a
|
|
|
|
section named @var{name}. If there is an error, return <<NULL>> and set
|
|
|
|
<<bfd_error>>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
asection *
|
|
|
|
bfd_make_section (abfd, name)
|
|
|
|
bfd *abfd;
|
2000-07-08 14:08:43 +02:00
|
|
|
const char *name;
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
struct section_hash_entry *sh;
|
|
|
|
asection *newsect;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
if (abfd->output_has_begun)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
|
|
|
return NULL;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
if (strcmp (name, BFD_ABS_SECTION_NAME) == 0
|
|
|
|
|| strcmp (name, BFD_COM_SECTION_NAME) == 0
|
|
|
|
|| strcmp (name, BFD_UND_SECTION_NAME) == 0
|
|
|
|
|| strcmp (name, BFD_IND_SECTION_NAME) == 0)
|
|
|
|
return NULL;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
sh = section_hash_lookup (&abfd->section_htab, name, TRUE, FALSE);
|
2001-12-17 01:40:53 +01:00
|
|
|
if (sh == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
newsect = &sh->section;
|
|
|
|
if (newsect->name != NULL)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
2001-12-17 01:40:53 +01:00
|
|
|
/* Section already exists. */
|
|
|
|
return newsect;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2001-12-17 01:40:53 +01:00
|
|
|
newsect->name = name;
|
|
|
|
return bfd_section_init (abfd, newsect);
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_set_section_flags
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean bfd_set_section_flags (bfd *abfd, asection *sec, flagword flags);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Set the attributes of the section @var{sec} in the BFD
|
2002-11-30 09:39:46 +01:00
|
|
|
@var{abfd} to the value @var{flags}. Return <<TRUE>> on success,
|
|
|
|
<<FALSE>> on error. Possible error returns are:
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
o <<bfd_error_invalid_operation>> -
|
|
|
|
The section cannot have one or more of the attributes
|
|
|
|
requested. For example, a .bss section in <<a.out>> may not
|
|
|
|
have the <<SEC_HAS_CONTENTS>> field set.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean
|
1999-05-03 09:29:11 +02:00
|
|
|
bfd_set_section_flags (abfd, section, flags)
|
1999-07-11 21:49:48 +02:00
|
|
|
bfd *abfd ATTRIBUTE_UNUSED;
|
1999-05-03 09:29:11 +02:00
|
|
|
sec_ptr section;
|
|
|
|
flagword flags;
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
/* If you try to copy a text section from an input file (where it
|
|
|
|
has the SEC_CODE flag set) to an output file, this loses big if
|
|
|
|
the bfd_applicable_section_flags (abfd) doesn't have the SEC_CODE
|
|
|
|
set - which it doesn't, at least not for a.out. FIXME */
|
|
|
|
|
|
|
|
if ((flags & bfd_applicable_section_flags (abfd)) != flags)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
section->flags = flags;
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_map_over_sections
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
void bfd_map_over_sections(bfd *abfd,
|
2000-12-20 01:21:57 +01:00
|
|
|
void (*func) (bfd *abfd,
|
1999-05-03 09:29:11 +02:00
|
|
|
asection *sect,
|
|
|
|
PTR obj),
|
|
|
|
PTR obj);
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Call the provided function @var{func} for each section
|
|
|
|
attached to the BFD @var{abfd}, passing @var{obj} as an
|
|
|
|
argument. The function will be called as if by
|
|
|
|
|
|
|
|
| func(abfd, the_section, obj);
|
|
|
|
|
|
|
|
This is the prefered method for iterating over sections; an
|
|
|
|
alternative would be to use a loop:
|
|
|
|
|
|
|
|
| section *p;
|
|
|
|
| for (p = abfd->sections; p != NULL; p = p->next)
|
|
|
|
| func(abfd, p, ...)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*VARARGS2*/
|
|
|
|
void
|
|
|
|
bfd_map_over_sections (abfd, operation, user_storage)
|
|
|
|
bfd *abfd;
|
|
|
|
void (*operation) PARAMS ((bfd * abfd, asection * sect, PTR obj));
|
|
|
|
PTR user_storage;
|
|
|
|
{
|
|
|
|
asection *sect;
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
|
|
for (sect = abfd->sections; sect != NULL; i++, sect = sect->next)
|
|
|
|
(*operation) (abfd, sect, user_storage);
|
|
|
|
|
|
|
|
if (i != abfd->section_count) /* Debugging */
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_set_section_size
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean bfd_set_section_size (bfd *abfd, asection *sec, bfd_size_type val);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Set @var{sec} to the size @var{val}. If the operation is
|
2002-11-30 09:39:46 +01:00
|
|
|
ok, then <<TRUE>> is returned, else <<FALSE>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
Possible error returns:
|
|
|
|
o <<bfd_error_invalid_operation>> -
|
|
|
|
Writing has started to the BFD, so setting the size is invalid.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean
|
1999-05-03 09:29:11 +02:00
|
|
|
bfd_set_section_size (abfd, ptr, val)
|
|
|
|
bfd *abfd;
|
|
|
|
sec_ptr ptr;
|
|
|
|
bfd_size_type val;
|
|
|
|
{
|
|
|
|
/* Once you've started writing to any section you cannot create or change
|
2000-12-20 01:21:57 +01:00
|
|
|
the size of any others. */
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
if (abfd->output_has_begun)
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ptr->_cooked_size = val;
|
|
|
|
ptr->_raw_size = val;
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_set_section_contents
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean bfd_set_section_contents (bfd *abfd, asection *section,
|
|
|
|
PTR data, file_ptr offset,
|
|
|
|
bfd_size_type count);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Sets the contents of the section @var{section} in BFD
|
|
|
|
@var{abfd} to the data starting in memory at @var{data}. The
|
|
|
|
data is written to the output section starting at offset
|
2000-01-13 23:10:36 +01:00
|
|
|
@var{offset} for @var{count} octets.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
Normally <<TRUE>> is returned, else <<FALSE>>. Possible error
|
1999-05-03 09:29:11 +02:00
|
|
|
returns are:
|
|
|
|
o <<bfd_error_no_contents>> -
|
|
|
|
The output section does not have the <<SEC_HAS_CONTENTS>>
|
|
|
|
attribute, so nothing can be written to it.
|
|
|
|
o and some more too
|
|
|
|
|
|
|
|
This routine is front end to the back end function
|
|
|
|
<<_bfd_set_section_contents>>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define bfd_get_section_size_now(abfd,sec) \
|
|
|
|
(sec->reloc_done \
|
|
|
|
? bfd_get_section_size_after_reloc (sec) \
|
|
|
|
: bfd_get_section_size_before_reloc (sec))
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean
|
1999-05-03 09:29:11 +02:00
|
|
|
bfd_set_section_contents (abfd, section, location, offset, count)
|
|
|
|
bfd *abfd;
|
|
|
|
sec_ptr section;
|
|
|
|
PTR location;
|
|
|
|
file_ptr offset;
|
|
|
|
bfd_size_type count;
|
|
|
|
{
|
|
|
|
bfd_size_type sz;
|
|
|
|
|
|
|
|
if (!(bfd_get_section_flags (abfd, section) & SEC_HAS_CONTENTS))
|
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_no_contents);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
sz = bfd_get_section_size_now (abfd, section);
|
|
|
|
if ((bfd_size_type) offset > sz
|
|
|
|
|| count > sz
|
|
|
|
|| offset + count > sz
|
|
|
|
|| count != (size_t) count)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (abfd->direction)
|
|
|
|
{
|
|
|
|
case read_direction:
|
|
|
|
case no_direction:
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
case write_direction:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case both_direction:
|
|
|
|
/* File is opened for update. `output_has_begun' some time ago when
|
|
|
|
the file was created. Do not recompute sections sizes or alignments
|
|
|
|
in _bfd_set_section_content. */
|
2002-11-30 09:39:46 +01:00
|
|
|
abfd->output_has_begun = TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-11-08 08:54:31 +01:00
|
|
|
/* Record a copy of the data in memory if desired. */
|
|
|
|
if (section->contents
|
* aoutx.h (NAME(aout,swap_ext_reloc_in)): Cast bytes->r_index to
unsigned int. Cast RELOC_BASE10, RELOC_BASE13 and RELOC_BASE22 to
unsigned int.
(NAME(aout,final_link)): Cast enum used in assignment.
(aout_link_write_symbols): Cast enums in comparisons, int values to
boolean, enums in assignments to int.
(aout_link_input_section_std): Cast rel->r_index to unsigned int.
(aout_link_input_section_ext): Likewise. Cast enums used in comparisons
with unsigned ints.
(aout_link_reloc_link_order): Cast enum to int in assignment.
* archive.c (_bfd_generic_read_ar_hdr_mag): Cast result of memchr
calls to char *.
* bfd-in.h (bfd_set_section_vma): Cast enum true to unsigned int in
assignment.
* bfd-in2.h (bfd_set_section_vma): Likewise.
* bfd.c (bfd_record_phdr): Cast enums in assignments.
* binary.c (bfd_alloc): Cast enum to long.
* coffgen.c (_bfd_coff_is_local_label_name): Cast return to boolean.
* dwarf2.c (read_abbrevs): Add casts to enum types.
(read_attribute_value): Likewise.
(arange_add): Cast result of bfd_zalloc call.
(comp_unit_contains_address): Return true and false.
(comp_unit_find_nearest_line): Cast return to boolean.
* format.c (bfd_check_format_matches, bfd_set_format): Likewise.
* gen-aout.c: define macro '_' if not defined.
* libbfd.c (bfd_realloc): Cast malloc and realloc to PTR.
(bfd_bwrite): Cast bfd_realloc to bfd_byte *.
(bfd_write_bigendian_4byte_int): Cast return to boolean.
(bfd_seek): Cast bfd_realloc to bfd_byte *.
(bfd_generic_is_local_label_name): Cast return to boolean.
* libcoff.h (_bfd_coff_adjust_symndx): Remove extraneous '\'.
* linker.c (_bfd_link_hash_newfunc): Cast bfd_hash_allocate result to
struct bfd_hash_entry *.
(_bfd_generic_link_hash_newfunc): likewise.
(_bfd_generic_final_link): Cast enum to unsigned int.
* merge.c (sec_merge_emit): Cast return to boolean.
(merge_strings): Add casts to const unsigned char *.
* reloc.c (bfd_get_reloc_code_name): Cast enums in comparison to int.
(bfd_generic_get_relocated_section_content): Cast enum to unsigned int.
* section.c (bfd_section_hash_newfunc): Cast bfd_hash_allocate result to
struct bfd_hash_entry *.
(bfd_set_section_content): Add cast to PTR in comparison.
* simple.c (simple_dummy_warning, simple_dummy_undefined_symbol,
simple_dummy_reloc_overflow, simple_dummy_reloc_dangerous,
simple_dummy_unattached_reloc,
bfd_simple_get_relocated_section_contents): Add K&R declarations and
function definitions.
* srec.c (S3Forced): Initialize to false.
(srec_get_symtab): Cast return value from bfd_alloc to asymbol *.
* stabs.c (_bfd_link_section_stabs): Cast enum to int in comparisons.
(_bfd_discard_section_stabs): Likewise. Also cast return to boolean.
* syms.c (bfd_is_undefined_symclass): Cast return to boolean.
(_bfd_stab_section_find_nearest_line): Cast enum to bfd_byte in
comparisons.
2002-10-25 04:45:54 +02:00
|
|
|
&& location != (PTR) (section->contents + offset))
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
memcpy (section->contents + offset, location, (size_t) count);
|
2000-11-08 08:54:31 +01:00
|
|
|
|
1999-05-03 09:29:11 +02:00
|
|
|
if (BFD_SEND (abfd, _bfd_set_section_contents,
|
|
|
|
(abfd, section, location, offset, count)))
|
|
|
|
{
|
2002-11-30 09:39:46 +01:00
|
|
|
abfd->output_has_begun = TRUE;
|
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_get_section_contents
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean bfd_get_section_contents (bfd *abfd, asection *section,
|
|
|
|
PTR location, file_ptr offset,
|
|
|
|
bfd_size_type count);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Read data from @var{section} in BFD @var{abfd}
|
|
|
|
into memory starting at @var{location}. The data is read at an
|
|
|
|
offset of @var{offset} from the start of the input section,
|
|
|
|
and is read for @var{count} bytes.
|
|
|
|
|
|
|
|
If the contents of a constructor with the <<SEC_CONSTRUCTOR>>
|
|
|
|
flag set are requested or if the section does not have the
|
|
|
|
<<SEC_HAS_CONTENTS>> flag set, then the @var{location} is filled
|
2002-11-30 09:39:46 +01:00
|
|
|
with zeroes. If no errors occur, <<TRUE>> is returned, else
|
|
|
|
<<FALSE>>.
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
*/
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean
|
1999-05-03 09:29:11 +02:00
|
|
|
bfd_get_section_contents (abfd, section, location, offset, count)
|
|
|
|
bfd *abfd;
|
|
|
|
sec_ptr section;
|
|
|
|
PTR location;
|
|
|
|
file_ptr offset;
|
|
|
|
bfd_size_type count;
|
|
|
|
{
|
|
|
|
bfd_size_type sz;
|
|
|
|
|
|
|
|
if (section->flags & SEC_CONSTRUCTOR)
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
memset (location, 0, (size_t) count);
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
/* Even if reloc_done is TRUE, this function reads unrelocated
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
contents, so we want the raw size. */
|
|
|
|
sz = section->_raw_size;
|
|
|
|
if ((bfd_size_type) offset > sz
|
|
|
|
|| count > sz
|
|
|
|
|| offset + count > sz
|
|
|
|
|| count != (size_t) count)
|
1999-05-03 09:29:11 +02:00
|
|
|
{
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 09:39:46 +01:00
|
|
|
return FALSE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
/* Don't bother. */
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
if ((section->flags & SEC_HAS_CONTENTS) == 0)
|
|
|
|
{
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 11:57:26 +02:00
|
|
|
memset (location, 0, (size_t) count);
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((section->flags & SEC_IN_MEMORY) != 0)
|
|
|
|
{
|
|
|
|
memcpy (location, section->contents + offset, (size_t) count);
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return BFD_SEND (abfd, _bfd_get_section_contents,
|
|
|
|
(abfd, section, location, offset, count));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
bfd_copy_private_section_data
|
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean bfd_copy_private_section_data (bfd *ibfd, asection *isec,
|
|
|
|
bfd *obfd, asection *osec);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Copy private section information from @var{isec} in the BFD
|
|
|
|
@var{ibfd} to the section @var{osec} in the BFD @var{obfd}.
|
2002-11-30 09:39:46 +01:00
|
|
|
Return <<TRUE>> on success, <<FALSE>> on error. Possible error
|
1999-05-03 09:29:11 +02:00
|
|
|
returns are:
|
|
|
|
|
|
|
|
o <<bfd_error_no_memory>> -
|
|
|
|
Not enough memory exists to create private data for @var{osec}.
|
|
|
|
|
|
|
|
.#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \
|
|
|
|
. BFD_SEND (obfd, _bfd_copy_private_section_data, \
|
|
|
|
. (ibfd, isection, obfd, osection))
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
_bfd_strip_section_from_output
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
void _bfd_strip_section_from_output
|
2000-02-13 23:45:29 +01:00
|
|
|
(struct bfd_link_info *info, asection *section);
|
1999-05-03 09:29:11 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
2000-02-13 23:45:29 +01:00
|
|
|
Remove @var{section} from the output. If the output section
|
2002-07-04 16:40:25 +02:00
|
|
|
becomes empty, remove it from the output bfd.
|
|
|
|
|
|
|
|
This function won't actually do anything except twiddle flags
|
|
|
|
if called too late in the linking process, when it's not safe
|
|
|
|
to remove sections.
|
1999-05-03 09:29:11 +02:00
|
|
|
*/
|
|
|
|
void
|
2000-02-13 23:45:29 +01:00
|
|
|
_bfd_strip_section_from_output (info, s)
|
|
|
|
struct bfd_link_info *info;
|
1999-05-03 09:29:11 +02:00
|
|
|
asection *s;
|
|
|
|
{
|
2002-07-04 16:40:25 +02:00
|
|
|
asection *os;
|
|
|
|
asection *is;
|
|
|
|
bfd *abfd;
|
1999-05-03 09:29:11 +02:00
|
|
|
|
2002-07-04 16:40:25 +02:00
|
|
|
s->flags |= SEC_EXCLUDE;
|
2000-02-13 23:45:29 +01:00
|
|
|
|
2002-07-04 16:40:25 +02:00
|
|
|
/* If the section wasn't assigned to an output section, or the
|
|
|
|
section has been discarded by the linker script, there's nothing
|
|
|
|
more to do. */
|
1999-05-03 09:29:11 +02:00
|
|
|
os = s->output_section;
|
2002-07-04 16:40:25 +02:00
|
|
|
if (os == NULL || os->owner == NULL)
|
2001-06-02 21:05:34 +02:00
|
|
|
return;
|
|
|
|
|
2002-07-04 16:40:25 +02:00
|
|
|
/* If the output section has other (non-excluded) input sections, we
|
|
|
|
can't remove it. */
|
|
|
|
for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link_next)
|
|
|
|
for (is = abfd->sections; is != NULL; is = is->next)
|
|
|
|
if (is->output_section == os && (is->flags & SEC_EXCLUDE) == 0)
|
|
|
|
return;
|
2000-02-13 23:45:29 +01:00
|
|
|
|
2002-07-04 16:40:25 +02:00
|
|
|
/* If the output section is empty, flag it for removal too.
|
|
|
|
See ldlang.c:strip_excluded_output_sections for the action. */
|
|
|
|
os->flags |= SEC_EXCLUDE;
|
1999-05-03 09:29:11 +02:00
|
|
|
}
|
2002-06-04 03:05:21 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
2002-06-05 05:43:11 +02:00
|
|
|
bfd_generic_discard_group
|
2002-06-04 03:05:21 +02:00
|
|
|
|
|
|
|
SYNOPSIS
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean bfd_generic_discard_group (bfd *abfd, asection *group);
|
2002-06-04 03:05:21 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
Remove all members of @var{group} from the output.
|
|
|
|
*/
|
|
|
|
|
2002-11-30 09:39:46 +01:00
|
|
|
bfd_boolean
|
2002-06-05 05:43:11 +02:00
|
|
|
bfd_generic_discard_group (abfd, group)
|
|
|
|
bfd *abfd ATTRIBUTE_UNUSED;
|
|
|
|
asection *group ATTRIBUTE_UNUSED;
|
2002-06-04 03:05:21 +02:00
|
|
|
{
|
2002-11-30 09:39:46 +01:00
|
|
|
return TRUE;
|
2002-06-04 03:05:21 +02:00
|
|
|
}
|