* section.c (struct sec): Remove usused flags. Reorganize a little.

(bfd_get_section_size_before_reloc): Delete.
	(bfd_get_section_size_after_reloc): Delete.
	(STD_SECTION): Update.
	(bfd_get_section_size_now): Delete.
	(bfd_set_section_contents): Don't referece reloc_done.
	(bfd_get_section_contents): Remove reloc_done comment.
	* bout.c (b_out_bfd_get_relocated_section_contents): Don't set
	reloc_done.
	* coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Likewise.
	* ecoff.c (bfd_debug_section): Update initializer.
	* elfxx-mips.c (_bfd_elf_mips_get_relocated_section_contents): Ditto.
	* reloc.c (bfd_generic_get_relocated_section_contents): Likewise.
	* bfd-in.h (bfd_section_size): Expand.
	(bfd_get_section_size): New macro.
	* bfd-in2.h: Regenerate.
	* coff64-rs6000.c (xcoff64_write_object_contents): Replace
	bfd_get_section_size_before_reloc with bfd_get_section_size.
	* coffcode.h (coff_write_object_contents): Likewise.
	* coffgen.c (build_debug_section): Likewise.
	* dwarf1.c (parse_line_table): Likewise.
	(_bfd_dwarf1_find_nearest_line): Likewise.
	* ecoff.c (_bfd_ecoff_write_object_contents): Likewise.
	* i386msdos.c (msdos_write_object_contents): Likewise.
	* pdp11.c (squirt_out_relocs): Likewise.
	* elf32-sh64.c (sh64_find_section_for_address): Remove comment.
	* elf64-mmix.c (mmix_elf_final_link): Update comment.
This commit is contained in:
Alan Modra 2004-06-15 01:24:22 +00:00
parent 135dfb4a65
commit 911d08a746
17 changed files with 88 additions and 99 deletions

View File

@ -1,3 +1,33 @@
2004-06-15 Alan Modra <amodra@bigpond.net.au>
* section.c (struct sec): Remove usused flags. Reorganize a little.
(bfd_get_section_size_before_reloc): Delete.
(bfd_get_section_size_after_reloc): Delete.
(STD_SECTION): Update.
(bfd_get_section_size_now): Delete.
(bfd_set_section_contents): Don't referece reloc_done.
(bfd_get_section_contents): Remove reloc_done comment.
* bout.c (b_out_bfd_get_relocated_section_contents): Don't set
reloc_done.
* coff-alpha.c (alpha_ecoff_get_relocated_section_contents): Likewise.
* ecoff.c (bfd_debug_section): Update initializer.
* elfxx-mips.c (_bfd_elf_mips_get_relocated_section_contents): Ditto.
* reloc.c (bfd_generic_get_relocated_section_contents): Likewise.
* bfd-in.h (bfd_section_size): Expand.
(bfd_get_section_size): New macro.
* bfd-in2.h: Regenerate.
* coff64-rs6000.c (xcoff64_write_object_contents): Replace
bfd_get_section_size_before_reloc with bfd_get_section_size.
* coffcode.h (coff_write_object_contents): Likewise.
* coffgen.c (build_debug_section): Likewise.
* dwarf1.c (parse_line_table): Likewise.
(_bfd_dwarf1_find_nearest_line): Likewise.
* ecoff.c (_bfd_ecoff_write_object_contents): Likewise.
* i386msdos.c (msdos_write_object_contents): Likewise.
* pdp11.c (squirt_out_relocs): Likewise.
* elf32-sh64.c (sh64_find_section_for_address): Remove comment.
* elf64-mmix.c (mmix_elf_final_link): Update comment.
2004-06-14 Chris Demetriou <cgd@broadcom.com>
* elf32-mips.c (elf_mips_gnu_pcrel32): Add (undoing 2004-04-24

View File

@ -308,7 +308,8 @@ typedef struct bfd_section *sec_ptr;
#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
#define bfd_section_name(bfd, ptr) ((ptr)->name)
#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
#define bfd_section_size(bfd, ptr) ((ptr)->_raw_size)
#define bfd_get_section_size(ptr) ((ptr)->_raw_size)
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)

View File

@ -315,7 +315,8 @@ typedef struct bfd_section *sec_ptr;
#define bfd_get_section_lma(bfd, ptr) ((ptr)->lma + 0)
#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)
#define bfd_section_name(bfd, ptr) ((ptr)->name)
#define bfd_section_size(bfd, ptr) (bfd_get_section_size_before_reloc(ptr))
#define bfd_section_size(bfd, ptr) ((ptr)->_raw_size)
#define bfd_get_section_size(ptr) ((ptr)->_raw_size)
#define bfd_section_vma(bfd, ptr) ((ptr)->vma)
#define bfd_section_lma(bfd, ptr) ((ptr)->lma)
#define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
@ -1210,9 +1211,6 @@ typedef struct bfd_section
/* See the vma field. */
unsigned int user_set_vma : 1;
/* Whether relocations have been processed. */
unsigned int reloc_done : 1;
/* A mark flag used by some of the linker backends. */
unsigned int linker_mark : 1;
@ -1240,21 +1238,18 @@ typedef struct bfd_section
unsigned int use_rela_p:1;
/* Bits used by various backends. */
unsigned int has_tls_reloc:1;
/* Nonzero if this section needs the relax finalize pass. */
unsigned int need_finalize_relax:1;
/* Nonzero if this section has TLS related relocations. */
unsigned int has_tls_reloc:1;
/* Nonzero if this section has a gp reloc. */
unsigned int has_gp_reloc:1;
/* Unused 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;
/* Nonzero if this section needs the relax finalize pass. */
unsigned int need_finalize_relax:1;
/* Whether relocations have been processed. */
unsigned int reloc_done : 1;
/* End of internal packed boolean fields. */
@ -1403,11 +1398,6 @@ extern const struct bfd_symbol * const bfd_abs_symbol;
extern const struct bfd_symbol * const bfd_com_symbol;
extern const struct bfd_symbol * const bfd_und_symbol;
extern const struct bfd_symbol * const bfd_ind_symbol;
#define bfd_get_section_size_before_reloc(section) \
((section)->_raw_size)
#define bfd_get_section_size_after_reloc(section) \
((section)->reloc_done ? (section)->_cooked_size \
: (abort (), (bfd_size_type) 1))
/* Macros to handle insertion and deletion of a bfd's sections. These
only handle the list pointers, ie. do not adjust section_count,

View File

@ -1328,8 +1328,6 @@ b_out_bfd_get_relocated_section_contents (output_bfd, link_info, link_order,
if (reloc_vector == NULL && reloc_size != 0)
goto error_return;
input_section->reloc_done = 1;
/* Read in the section. */
BFD_ASSERT (bfd_get_section_contents (input_bfd,
input_section,

View File

@ -784,7 +784,6 @@ alpha_ecoff_get_relocated_section_contents (abfd, link_info, link_order,
/* The section size is not going to change. */
input_section->_cooked_size = input_section->_raw_size;
input_section->reloc_done = TRUE;
reloc_count = bfd_canonicalize_reloc (input_bfd, input_section,
reloc_vector, symbols);

View File

@ -965,19 +965,19 @@ xcoff64_write_object_contents (abfd)
if (text_sec)
{
internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
internal_a.tsize = bfd_get_section_size (text_sec);
internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
}
if (data_sec)
{
internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
internal_a.dsize = bfd_get_section_size (data_sec);
internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
}
if (bss_sec)
{
internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
internal_a.bsize = bfd_get_section_size (bss_sec);
if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
internal_a.data_start = bss_sec->vma;
}

View File

@ -4132,17 +4132,17 @@ coff_write_object_contents (abfd)
if (text_sec)
{
internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
internal_a.tsize = bfd_get_section_size (text_sec);
internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
}
if (data_sec)
{
internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
internal_a.dsize = bfd_get_section_size (data_sec);
internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
}
if (bss_sec)
{
internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
internal_a.bsize = bfd_get_section_size (bss_sec);
if (internal_a.bsize && bss_sec->vma < internal_a.data_start)
internal_a.data_start = bss_sec->vma;
}

View File

@ -1,6 +1,6 @@
/* Support for the generic parts of COFF, for BFD.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003
2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by Cygnus Support.
@ -1537,7 +1537,7 @@ build_debug_section (abfd)
return NULL;
}
sec_size = bfd_get_section_size_before_reloc (sect);
sec_size = bfd_get_section_size (sect);
debug_section = (PTR) bfd_alloc (abfd, sec_size);
if (debug_section == NULL)
return NULL;

View File

@ -1,5 +1,5 @@
/* DWARF 1 find nearest line (_bfd_dwarf1_find_nearest_line).
Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Copyright 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
Written by Gavin Romig-Koch of Cygnus Solutions (gavin@cygnus.com).
@ -285,7 +285,7 @@ parse_line_table (stash, aUnit)
if (! msec)
return FALSE;
size = bfd_get_section_size_before_reloc (msec);
size = bfd_get_section_size (msec);
stash->line_section = (char *) bfd_alloc (stash->abfd, size);
if (! stash->line_section)
@ -502,7 +502,7 @@ _bfd_dwarf1_find_nearest_line (abfd, section, symbols, offset,
return FALSE;
}
size = bfd_get_section_size_before_reloc (msec);
size = bfd_get_section_size (msec);
stash->debug_section = (char *) bfd_alloc (abfd, size);
if (! stash->debug_section)

View File

@ -1,6 +1,6 @@
/* Generic ECOFF (Extended-COFF) routines.
Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
2002, 2003, 2004 Free Software Foundation, Inc.
Original version by Per Bothner.
Full support added by Ian Lance Taylor, ian@cygnus.com.
@ -77,16 +77,14 @@ static unsigned int ecoff_armap_hash
static asection bfd_debug_section =
{
/* name, id, index, next, flags, user_set_vma, reloc_done, */
"*DEBUG*", 0, 0, NULL, 0, 0, 0,
/* name, id, index, next, flags, user_set_vma, */
"*DEBUG*", 0, 0, NULL, 0, 0,
/* linker_mark, linker_has_input, gc_mark, segment_mark, */
0, 0, 0, 0,
/* sec_info_type, use_rela_p, has_tls_reloc, */
0, 0, 0,
/* need_finalize_relax, has_gp_reloc, */
/* sec_info_type, use_rela_p, has_tls_reloc, has_gp_reloc, */
0, 0, 0, 0,
/* need_finalize_relax, reloc_done, */
0, 0,
/* flag13, flag14, flag15, flag16, flag20, flag24, */
0, 0, 0, 0, 0, 0,
/* vma, lma, _cooked_size, _raw_size, */
0, 0, 0, 0,
/* output_offset, output_section, alignment_power, */
@ -2550,7 +2548,7 @@ _bfd_ecoff_write_object_contents (abfd)
section.s_vaddr = vma;
section.s_paddr = current->lma;
section.s_size = bfd_get_section_size_before_reloc (current);
section.s_size = bfd_get_section_size (current);
/* If this section is unloadable then the scnptr will be 0. */
if ((current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
@ -2601,7 +2599,7 @@ _bfd_ecoff_write_object_contents (abfd)
|| (section.s_flags & STYP_ECOFF_FINI) != 0
|| section.s_flags == STYP_RCONST)
{
text_size += bfd_get_section_size_before_reloc (current);
text_size += bfd_get_section_size (current);
if (! set_text_start || text_start > vma)
{
text_start = vma;
@ -2617,7 +2615,7 @@ _bfd_ecoff_write_object_contents (abfd)
|| section.s_flags == STYP_XDATA
|| (section.s_flags & STYP_GOT) != 0)
{
data_size += bfd_get_section_size_before_reloc (current);
data_size += bfd_get_section_size (current);
if (! set_data_start || data_start > vma)
{
data_start = vma;
@ -2626,7 +2624,7 @@ _bfd_ecoff_write_object_contents (abfd)
}
else if ((section.s_flags & STYP_BSS) != 0
|| (section.s_flags & STYP_SBSS) != 0)
bss_size += bfd_get_section_size_before_reloc (current);
bss_size += bfd_get_section_size (current);
else if (section.s_flags == 0
|| (section.s_flags & STYP_ECOFF_LIB) != 0
|| section.s_flags == STYP_COMMENT)

View File

@ -620,8 +620,6 @@ sh64_find_section_for_address (bfd *abfd ATTRIBUTE_UNUSED,
if (fsec_datap->addr < vma)
return;
/* FIXME: section->reloc_done isn't set properly; a generic buglet
preventing us from using bfd_get_section_size_after_reloc. */
size
= section->_cooked_size ? section->_cooked_size : section->_raw_size;

View File

@ -2296,12 +2296,11 @@ mmix_elf_final_link (abfd, info)
/* We need to include the maximum size of PUSHJ-stubs in the initial
section size. This is expected to shrink during linker relaxation.
You might think that we should set *only* _cooked_size, but that won't
work: section contents allocation will be using _raw_size in mixed
format linking and not enough storage will be allocated. FIXME: That's
a major bug, including the name bfd_get_section_size_before_reloc; it
should be bfd_get_section_size_before_relax. The relaxation functions
set _cooked size. Relaxation happens before relocation. All functions
You might think that we should set *only* _cooked_size, but that
won't work: section contents allocation will be using _raw_size in
mixed format linking and not enough storage will be allocated.
FIXME: That's a major bug. The relaxation functions set _cooked
size. Relaxation happens before relocation. All functions
*after relaxation* should be using _cooked size. */
static void

View File

@ -7919,7 +7919,6 @@ _bfd_elf_mips_get_relocated_section_contents
/* We're not relaxing the section, so just copy the size info */
input_section->_cooked_size = input_section->_raw_size;
input_section->reloc_done = TRUE;
reloc_count = bfd_canonicalize_reloc (input_bfd,
input_section,

View File

@ -83,20 +83,20 @@ msdos_write_object_contents (abfd)
/* Find the total size of the program on disk and in memory. */
for (sec = abfd->sections; sec != (asection *) NULL; sec = sec->next)
{
if (bfd_get_section_size_before_reloc (sec) == 0)
if (bfd_get_section_size (sec) == 0)
continue;
if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC)
{
bfd_vma sec_vma = bfd_get_section_vma (abfd, sec)
+ bfd_get_section_size_before_reloc (sec);
bfd_vma sec_vma = (bfd_get_section_vma (abfd, sec)
+ bfd_get_section_size (sec));
if (sec_vma > high_vma)
high_vma = sec_vma;
}
if (bfd_get_section_flags (abfd, sec) & SEC_LOAD)
{
file_ptr sec_end = sizeof(hdr)
+ bfd_get_section_vma (abfd, sec)
+ bfd_get_section_size_before_reloc (sec);
file_ptr sec_end = (sizeof (hdr)
+ bfd_get_section_vma (abfd, sec)
+ bfd_get_section_size (sec));
if (sec_end > outfile_size)
outfile_size = sec_end;
}

View File

@ -1,5 +1,5 @@
/* BFD back-end for PDP-11 a.out binaries.
Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@ -2314,7 +2314,7 @@ NAME(aout,squirt_out_relocs) (abfd, section)
return TRUE;
#endif
natsize = bfd_get_section_size_before_reloc (section);
natsize = bfd_get_section_size (section);
native = (unsigned char *) bfd_zalloc (abfd, natsize);
if (!native)
return FALSE;

View File

@ -4292,8 +4292,6 @@ bfd_generic_get_relocated_section_contents (bfd *abfd,
this function is called. We do not want to clobber the _cooked_size
they computed. */
input_section->reloc_done = TRUE;
reloc_count = bfd_canonicalize_reloc (input_bfd,
input_section,
reloc_vector,

View File

@ -364,9 +364,6 @@ CODE_FRAGMENT
. {* See the vma field. *}
. unsigned int user_set_vma : 1;
.
. {* Whether relocations have been processed. *}
. unsigned int reloc_done : 1;
.
. {* A mark flag used by some of the linker backends. *}
. unsigned int linker_mark : 1;
.
@ -394,21 +391,18 @@ CODE_FRAGMENT
. unsigned int use_rela_p:1;
.
. {* Bits used by various backends. *}
. unsigned int has_tls_reloc:1;
.
. {* Nonzero if this section needs the relax finalize pass. *}
. unsigned int need_finalize_relax:1;
. {* Nonzero if this section has TLS related relocations. *}
. unsigned int has_tls_reloc:1;
.
. {* Nonzero if this section has a gp reloc. *}
. unsigned int has_gp_reloc:1;
.
. {* Unused 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;
. {* Nonzero if this section needs the relax finalize pass. *}
. unsigned int need_finalize_relax:1;
.
. {* Whether relocations have been processed. *}
. unsigned int reloc_done : 1;
.
. {* End of internal packed boolean fields. *}
.
@ -557,11 +551,6 @@ CODE_FRAGMENT
.extern const struct bfd_symbol * const bfd_com_symbol;
.extern const struct bfd_symbol * const bfd_und_symbol;
.extern const struct bfd_symbol * const bfd_ind_symbol;
.#define bfd_get_section_size_before_reloc(section) \
. ((section)->_raw_size)
.#define bfd_get_section_size_after_reloc(section) \
. ((section)->reloc_done ? (section)->_cooked_size \
. : (abort (), (bfd_size_type) 1))
.
.{* Macros to handle insertion and deletion of a bfd's sections. These
. only handle the list pointers, ie. do not adjust section_count,
@ -616,21 +605,18 @@ static const asymbol global_syms[] =
#define STD_SECTION(SEC, FLAGS, SYM, NAME, IDX) \
const asymbol * const SYM = (asymbol *) &global_syms[IDX]; \
asection SEC = \
/* name, id, index, next, flags, user_set_vma, reloc_done, */ \
{ NAME, IDX, 0, NULL, FLAGS, 0, 0, \
/* name, id, index, next, flags, user_set_vma, */ \
{ NAME, IDX, 0, NULL, FLAGS, 0, \
\
/* linker_mark, linker_has_input, gc_mark, segment_mark, */ \
0, 0, 1, 0, \
\
/* sec_info_type, use_rela_p, has_tls_reloc, */ \
0, 0, 0, \
/* sec_info_type, use_rela_p, has_tls_reloc, has_gp_reloc, */ \
0, 0, 0, 0, \
\
/* need_finalize_relax, has_gp_reloc, */ \
/* need_finalize_relax, reloc_done, */ \
0, 0, \
\
/* flag13, flag14, flag15, flag16, flag20, flag24, */ \
0, 0, 0, 0, 0, 0, \
\
/* vma, lma, _cooked_size, _raw_size, */ \
0, 0, 0, 0, \
\
@ -1243,11 +1229,6 @@ DESCRIPTION
*/
#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))
bfd_boolean
bfd_set_section_contents (bfd *abfd,
sec_ptr section,
@ -1263,7 +1244,7 @@ bfd_set_section_contents (bfd *abfd,
return FALSE;
}
sz = bfd_get_section_size_now (abfd, section);
sz = section->_cooked_size != 0 ? section->_cooked_size : section->_raw_size;
if ((bfd_size_type) offset > sz
|| count > sz
|| offset + count > sz
@ -1343,8 +1324,6 @@ bfd_get_section_contents (bfd *abfd,
return TRUE;
}
/* Even if reloc_done is TRUE, this function reads unrelocated
contents, so we want the raw size. */
sz = section->_raw_size;
if ((bfd_size_type) offset > sz
|| count > sz