Add sequence id field to asection.

Tidy comments and replace deprecated CONST with const.
This commit is contained in:
Alan Modra 2000-07-08 12:08:43 +00:00
parent 181866dcc7
commit 52b219b5e4
8 changed files with 671 additions and 644 deletions

View file

@ -1,3 +1,17 @@
2000-07-08 Alan Modra <alan@linuxcare.com.au>
* section.c (struct sec): Add id field. Tidy comment formatting.
(bfd_make_section_anyway): Set id.
(STD_SECTION): Init id too.
Change CONST to const throughout.
* archures.c (bfd_arch_info): Tidy comment.
(bfd_arch_list): Change a CONST to const.
* libbfd-in.h: Tidy comments and replace CONST with const.
* elf-bfd.h: Likewise.
* libbfd.h: Regenerate.
* bfd-in2.h: Regenerate.
* libcoff.h: Regenerate.
2000-07-07 DJ Delorie <dj@redhat.com>
* archive.c (_bfd_write_archive_contents): Add an informative

View file

@ -256,7 +256,7 @@ DESCRIPTION
. const char *arch_name;
. const char *printable_name;
. unsigned int section_align_power;
. {* true if this is the default machine for the architecture *}
. {* True if this is the default machine for the architecture. *}
. boolean the_default;
. const struct bfd_arch_info * (*compatible)
. PARAMS ((const struct bfd_arch_info *a,
@ -444,7 +444,7 @@ bfd_arch_list ()
}
}
name_list = (CONST char **)
name_list = (const char **)
bfd_malloc ((vec_length + 1) * sizeof (char **));
if (name_list == NULL)
return NULL;

View file

@ -793,7 +793,7 @@ boolean
bfd_make_readable PARAMS ((bfd *abfd));
/* Byte swapping macros for user section data. */
/* Byte swapping macros for user section data. */
#define bfd_put_8(abfd, val, ptr) \
((void) (*((unsigned char *)(ptr)) = (unsigned char)(val)))
@ -846,7 +846,7 @@ bfd_make_readable PARAMS ((bfd *abfd));
: (abort (), (void) 0))
/* Byte swapping macros for file header data. */
/* Byte swapping macros for file header data. */
#define bfd_h_put_8(abfd, val, ptr) \
bfd_put_8 (abfd, val, ptr)
@ -884,7 +884,7 @@ bfd_make_readable PARAMS ((bfd *abfd));
#define bfd_h_get_signed_64(abfd, ptr) \
BFD_SEND(abfd, bfd_h_getx_signed_64, (ptr))
/* This structure is used for a comdat section, as in PE. A comdat
/* 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. */
@ -910,7 +910,11 @@ typedef struct sec
/* The name of the section; the name isn't a copy, the pointer is
the same as that passed to bfd_make_section. */
CONST char *name;
const char *name;
/* A unique sequence number. */
int id;
/* Which section is it; 0..nth. */
@ -929,8 +933,7 @@ typedef struct sec
#define SEC_NO_FLAGS 0x000
/* Tells the OS to allocate space for this section when loading.
This is clear for a section containing debug information
only. */
This is clear for a section containing debug information only. */
#define SEC_ALLOC 0x001
/* Tells the OS to load the section from the file when loading.
@ -945,8 +948,7 @@ typedef struct sec
#define SEC_BALIGN 0x008
#endif
/* A signal to the OS that the section contains read only
data. */
/* A signal to the OS that the section contains read only data. */
#define SEC_READONLY 0x010
/* The section contains code only. */
@ -1010,9 +1012,8 @@ typedef struct sec
#define SEC_DEBUGGING 0x10000
/* The contents of this section are held in memory pointed to
by the contents field. This is checked by
bfd_get_section_contents, and the data is retrieved from
memory if appropriate. */
by the contents field. This is checked by bfd_get_section_contents,
and the data is retrieved from memory if appropriate. */
#define SEC_IN_MEMORY 0x20000
/* The contents of this section are to be excluded by the
@ -1161,19 +1162,19 @@ typedef struct sec
/* Information below is back end specific - and not always used
or updated. */
/* File position of section data */
/* File position of section data. */
file_ptr filepos;
/* File position of relocation info */
/* File position of relocation info. */
file_ptr rel_filepos;
/* File position of line data */
/* File position of line data. */
file_ptr line_filepos;
/* Pointer to data for applications */
/* Pointer to data for applications. */
PTR userdata;
@ -1181,24 +1182,24 @@ typedef struct sec
contents. */
unsigned char *contents;
/* Attached line number information */
/* Attached line number information. */
alent *lineno;
/* Number of line number records */
/* Number of line number records. */
unsigned int lineno_count;
/* Optional information about a COMDAT entry; NULL if not COMDAT */
/* Optional information about a COMDAT entry; NULL if not COMDAT. */
struct bfd_comdat_info *comdat;
/* When a section is being output, this value changes as more
linenumbers are written out */
linenumbers are written out. */
file_ptr moving_line_filepos;
/* What the section number is in the target world */
/* What the section number is in the target world. */
int target_index;
@ -1221,7 +1222,7 @@ typedef struct sec
struct bfd_link_order *link_order_tail;
} asection ;
/* These sections are global, and are managed by BFD. The application
/* 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
@ -1231,18 +1232,18 @@ typedef struct sec
#define BFD_COM_SECTION_NAME "*COM*"
#define BFD_IND_SECTION_NAME "*IND*"
/* the absolute section */
/* the absolute section */
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)
/* Pointer to the undefined section */
/* Pointer to the undefined section */
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)
/* Pointer to the common section */
/* Pointer to the common section */
extern const asection bfd_com_section;
#define bfd_com_section_ptr ((asection *) &bfd_com_section)
/* Pointer to the indirect section */
/* Pointer to the indirect section */
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)
@ -1258,16 +1259,16 @@ extern const struct symbol_cache_entry * const bfd_ind_symbol;
((section)->reloc_done ? (section)->_cooked_size \
: (abort (), (bfd_size_type) 1))
asection *
bfd_get_section_by_name PARAMS ((bfd *abfd, CONST char *name));
bfd_get_section_by_name PARAMS ((bfd *abfd, const char *name));
asection *
bfd_make_section_old_way PARAMS ((bfd *abfd, CONST char *name));
bfd_make_section_old_way PARAMS ((bfd *abfd, const char *name));
asection *
bfd_make_section_anyway PARAMS ((bfd *abfd, CONST char *name));
bfd_make_section_anyway PARAMS ((bfd *abfd, const char *name));
asection *
bfd_make_section PARAMS ((bfd *, CONST char *name));
bfd_make_section PARAMS ((bfd *, const char *name));
boolean
bfd_set_section_flags PARAMS ((bfd *abfd, asection *sec, flagword flags));
@ -1340,7 +1341,7 @@ enum bfd_architecture
bfd_arch_a29k, /* AMD 29000 */
bfd_arch_sparc, /* SPARC */
#define bfd_mach_sparc 1
/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */
/* The difference between v8plus and v9 is that v9 is a true 64 bit env. */
#define bfd_mach_sparc_sparclet 2
#define bfd_mach_sparc_sparclite 3
#define bfd_mach_sparc_v8plus 4
@ -1348,7 +1349,7 @@ enum bfd_architecture
#define bfd_mach_sparc_sparclite_le 6
#define bfd_mach_sparc_v9 7
#define bfd_mach_sparc_v9a 8 /* with ultrasparc add'ns */
/* Nonzero if MACH has the v9 instruction set. */
/* Nonzero if MACH has the v9 instruction set. */
#define bfd_mach_sparc_v9_p(mach) \
((mach) >= bfd_mach_sparc_v8plus && (mach) <= bfd_mach_sparc_v9a)
bfd_arch_mips, /* MIPS Rxxxx */
@ -1482,7 +1483,7 @@ typedef struct bfd_arch_info
const char *arch_name;
const char *printable_name;
unsigned int section_align_power;
/* true if this is the default machine for the architecture */
/* True if this is the default machine for the architecture. */
boolean the_default;
const struct bfd_arch_info * (*compatible)
PARAMS ((const struct bfd_arch_info *a,
@ -3114,7 +3115,7 @@ enum bfd_flavour {
enum bfd_endian { BFD_ENDIAN_BIG, BFD_ENDIAN_LITTLE, BFD_ENDIAN_UNKNOWN };
/* Forward declaration. */
/* Forward declaration. */
typedef struct bfd_link_info _bfd_link_info;
typedef struct bfd_target

View file

@ -1013,8 +1013,8 @@ extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
unsigned long));
extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
asymbol **,
bfd_vma, CONST char **,
CONST char **,
bfd_vma, const char **,
const char **,
unsigned int *));
#define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
#define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol

View file

@ -128,11 +128,11 @@ void bfd_void PARAMS ((bfd *ignore));
bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
void bfd_dont_truncate_arname PARAMS ((bfd *abfd, const char *filename,
char *hdr));
void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, const char *filename,
char *hdr));
void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, const char *filename,
char *hdr));
boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,

View file

@ -128,11 +128,11 @@ void bfd_void PARAMS ((bfd *ignore));
bfd *_bfd_new_bfd_contained_in PARAMS ((bfd *));
const bfd_target *_bfd_dummy_target PARAMS ((bfd *abfd));
void bfd_dont_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
void bfd_dont_truncate_arname PARAMS ((bfd *abfd, const char *filename,
char *hdr));
void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
void bfd_bsd_truncate_arname PARAMS ((bfd *abfd, const char *filename,
char *hdr));
void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, CONST char *filename,
void bfd_gnu_truncate_arname PARAMS ((bfd *abfd, const char *filename,
char *hdr));
boolean bsd_write_armap PARAMS ((bfd *arch, unsigned int elength,

View file

@ -613,7 +613,7 @@ union {
} combined_entry_type;
/* Each canonical asymbol really looks like this: */
/* Each canonical asymbol really looks like this: */
typedef struct coff_symbol_struct
{
@ -629,7 +629,7 @@ struct lineno_cache_entry *lineno;
/* Have the line numbers been relocated yet ? */
boolean done_lineno;
} coff_symbol_type;
/* COFF symbol classifications. */
/* COFF symbol classifications. */
enum coff_symbol_classification
{

View file

@ -1,5 +1,5 @@
/* Object file "section" support for the BFD library.
Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
Written by Cygnus Support.
@ -150,7 +150,7 @@ SUBSECTION
CODE_FRAGMENT
.
. {* This structure is used for a comdat section, as in PE. A comdat
.{* 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. *}
@ -176,7 +176,11 @@ CODE_FRAGMENT
. {* 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;
. const char *name;
.
. {* A unique sequence number. *}
.
. int id;
.
. {* Which section is it; 0..nth. *}
.
@ -195,8 +199,7 @@ CODE_FRAGMENT
.#define SEC_NO_FLAGS 0x000
.
. {* Tells the OS to allocate space for this section when loading.
. This is clear for a section containing debug information
. only. *}
. This is clear for a section containing debug information only. *}
.#define SEC_ALLOC 0x001
.
. {* Tells the OS to load the section from the file when loading.
@ -211,8 +214,7 @@ CODE_FRAGMENT
.#define SEC_BALIGN 0x008
.#endif
.
. {* A signal to the OS that the section contains read only
. data. *}
. {* A signal to the OS that the section contains read only data. *}
.#define SEC_READONLY 0x010
.
. {* The section contains code only. *}
@ -276,9 +278,8 @@ CODE_FRAGMENT
.#define SEC_DEBUGGING 0x10000
.
. {* The contents of this section are held in memory pointed to
. by the contents field. This is checked by
. bfd_get_section_contents, and the data is retrieved from
. memory if appropriate. *}
. by the contents field. This is checked by bfd_get_section_contents,
. and the data is retrieved from memory if appropriate. *}
.#define SEC_IN_MEMORY 0x20000
.
. {* The contents of this section are to be excluded by the
@ -427,19 +428,19 @@ CODE_FRAGMENT
. {* Information below is back end specific - and not always used
. or updated. *}
.
. {* File position of section data *}
. {* File position of section data. *}
.
. file_ptr filepos;
.
. {* File position of relocation info *}
. {* File position of relocation info. *}
.
. file_ptr rel_filepos;
.
. {* File position of line data *}
. {* File position of line data. *}
.
. file_ptr line_filepos;
.
. {* Pointer to data for applications *}
. {* Pointer to data for applications. *}
.
. PTR userdata;
.
@ -447,24 +448,24 @@ CODE_FRAGMENT
. contents. *}
. unsigned char *contents;
.
. {* Attached line number information *}
. {* Attached line number information. *}
.
. alent *lineno;
.
. {* Number of line number records *}
. {* Number of line number records. *}
.
. unsigned int lineno_count;
.
. {* Optional information about a COMDAT entry; NULL if not COMDAT *}
. {* Optional information about a COMDAT entry; NULL if not COMDAT. *}
.
. struct bfd_comdat_info *comdat;
.
. {* When a section is being output, this value changes as more
. linenumbers are written out *}
. linenumbers are written out. *}
.
. file_ptr moving_line_filepos;
.
. {* What the section number is in the target world *}
. {* What the section number is in the target world. *}
.
. int target_index;
.
@ -487,7 +488,7 @@ CODE_FRAGMENT
. struct bfd_link_order *link_order_tail;
.} asection ;
.
. {* These sections are global, and are managed by BFD. The application
.{* 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
@ -497,18 +498,18 @@ CODE_FRAGMENT
.#define BFD_COM_SECTION_NAME "*COM*"
.#define BFD_IND_SECTION_NAME "*IND*"
.
. {* the absolute section *}
.{* the absolute section *}
.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)
. {* Pointer to the undefined section *}
.{* Pointer to the undefined section *}
.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)
. {* Pointer to the common section *}
.{* Pointer to the common section *}
.extern const asection bfd_com_section;
.#define bfd_com_section_ptr ((asection *) &bfd_com_section)
. {* Pointer to the indirect section *}
.{* Pointer to the indirect section *}
.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)
@ -551,26 +552,35 @@ static const asymbol global_syms[] =
#define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \
const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
const asection SEC = \
/* name, index, next, flags, set_vma, reloc_done, linker_mark, gc_mark */ \
{ NAME, 0, NULL, FLAGS, 0, 0, 0, 0, \
/* name, id, index, next, flags, user_set_vma, reloc_done, */ \
{ NAME, -1-(IDX), 0, NULL, FLAGS, 0, 0, \
\
/* vma, lma, _cooked_size, _raw_size, output_offset, output_section, */ \
0, 0, 0, 0, 0, (struct sec *) &SEC, \
/* linker_mark, gc_mark, vma, lma, _cooked_size, _raw_size, */ \
0, 0, 0, 0, 0, 0, \
\
/* alig..., reloc..., orel..., reloc_count, filepos, rel_..., line_... */ \
0, NULL, NULL, 0, 0, 0, 0, \
/* output_offset, output_section, alignment_power, */ \
0, (struct sec *) &SEC, 0, \
\
/* userdata, contents, lineno, lineno_count */ \
NULL, NULL, NULL, 0, \
/* relocation, orelocation, reloc_count, filepos, rel_filepos, */ \
NULL, NULL, 0, 0, 0, \
\
/* comdat_info, moving_line_filepos, target_index, used_by_bfd, */ \
/* line_filepos, userdata, contents, lineno, lineno_count, */ \
0, NULL, NULL, NULL, 0, \
\
/* comdat, moving_line_filepos, target_index, used_by_bfd, */ \
NULL, 0, 0, NULL, \
\
/* cons..., owner, symbol */ \
NULL, NULL, (struct symbol_cache_entry *) &global_syms[IDX], \
/* constructor_chain, owner, */ \
NULL, NULL, \
\
/* symbol_ptr_ptr, link_order_head, ..._tail */ \
(struct symbol_cache_entry **) &SYM, NULL, NULL \
/* symbol, */ \
(struct symbol_cache_entry *) &global_syms[IDX], \
\
/* symbol_ptr_ptr, */ \
(struct symbol_cache_entry **) &SYM, \
\
/* link_order_head, link_order_tail */ \
NULL, NULL \
}
STD_SECTION (bfd_com_section, SEC_IS_COMMON, bfd_com_symbol,
@ -595,7 +605,7 @@ FUNCTION
bfd_get_section_by_name
SYNOPSIS
asection *bfd_get_section_by_name(bfd *abfd, CONST char *name);
asection *bfd_get_section_by_name(bfd *abfd, const char *name);
DESCRIPTION
Run through @var{abfd} and return the one of the
@ -611,7 +621,7 @@ DESCRIPTION
asection *
bfd_get_section_by_name (abfd, name)
bfd *abfd;
CONST char *name;
const char *name;
{
asection *sect;
@ -627,7 +637,7 @@ FUNCTION
bfd_make_section_old_way
SYNOPSIS
asection *bfd_make_section_old_way(bfd *abfd, CONST char *name);
asection *bfd_make_section_old_way(bfd *abfd, const char *name);
DESCRIPTION
Create a new empty section called @var{name}
@ -651,7 +661,7 @@ DESCRIPTION
asection *
bfd_make_section_old_way (abfd, name)
bfd *abfd;
CONST char *name;
const char *name;
{
asection *sec = bfd_get_section_by_name (abfd, name);
if (sec == (asection *) NULL)
@ -666,7 +676,7 @@ FUNCTION
bfd_make_section_anyway
SYNOPSIS
asection *bfd_make_section_anyway(bfd *abfd, CONST char *name);
asection *bfd_make_section_anyway(bfd *abfd, const char *name);
DESCRIPTION
Create a new empty section called @var{name} and attach it to the end of
@ -681,8 +691,9 @@ DESCRIPTION
sec_ptr
bfd_make_section_anyway (abfd, name)
bfd *abfd;
CONST char *name;
const char *name;
{
static int section_id = 0;
asection *newsect;
asection **prev = &abfd->sections;
asection *sect = abfd->sections;
@ -704,6 +715,7 @@ bfd_make_section_anyway (abfd, name)
return NULL;
newsect->name = name;
newsect->id = section_id++;
newsect->index = abfd->section_count++;
newsect->flags = SEC_NO_FLAGS;
@ -744,7 +756,7 @@ FUNCTION
bfd_make_section
SYNOPSIS
asection *bfd_make_section(bfd *, CONST char *name);
asection *bfd_make_section(bfd *, const char *name);
DESCRIPTION
Like <<bfd_make_section_anyway>>, but return <<NULL>> (without calling
@ -756,7 +768,7 @@ DESCRIPTION
asection *
bfd_make_section (abfd, name)
bfd *abfd;
CONST char *name;
const char *name;
{
asection *sect = abfd->sections;