* coffcode.h (styp_to_sec_flags): Add name argument. If no flags

are recognized, chose section flags based on the name.
	(bfd_coff_backend_data): _bfd_styp_to_sec_flags_hook field: Add
	name argument.
	(bfd_coff_styp_to_sec_flags_hook): Add name argument.
	(coff_compute_section_file_positions): Don't adjust the section
	position by COFF_PAGE_SIZE unless SEC_ALLOC is set.
	* libcoff.h: Rebuilt.
	* coffgen.c (make_a_section_from_file): Pass section name to
	bfd_coff_styp_to_sec_flags_hook.
	* ecoff.c (_bfd_ecoff_styp_to_sec_flags): Add unused name
	argument.
	* libecoff.h (_bfd_ecoff_styp_to_sec_flags): Add name argument to
	prototype.
This commit is contained in:
Ian Lance Taylor 1994-08-15 16:26:06 +00:00
parent 7de5c5e275
commit e8fbe6d924
5 changed files with 111 additions and 28 deletions

View File

@ -1,3 +1,20 @@
Mon Aug 15 12:16:56 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
* coffcode.h (styp_to_sec_flags): Add name argument. If no flags
are recognized, chose section flags based on the name.
(bfd_coff_backend_data): _bfd_styp_to_sec_flags_hook field: Add
name argument.
(bfd_coff_styp_to_sec_flags_hook): Add name argument.
(coff_compute_section_file_positions): Don't adjust the section
position by COFF_PAGE_SIZE unless SEC_ALLOC is set.
* libcoff.h: Rebuilt.
* coffgen.c (make_a_section_from_file): Pass section name to
bfd_coff_styp_to_sec_flags_hook.
* ecoff.c (_bfd_ecoff_styp_to_sec_flags): Add unused name
argument.
* libecoff.h (_bfd_ecoff_styp_to_sec_flags): Add name argument to
prototype.
Fri Aug 12 11:22:40 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
* elfcode.h (section_from_elf_index): Correct check for invalid

View File

@ -405,9 +405,10 @@ sec_to_styp_flags (sec_name, sec_flags)
* in sec_to_styp_flags().
*/
static flagword
styp_to_sec_flags (abfd, hdr)
bfd * abfd;
styp_to_sec_flags (abfd, hdr, name)
bfd *abfd;
PTR hdr;
const char *name;
{
struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
long styp_flags = internal_s->s_flags;
@ -457,6 +458,54 @@ styp_to_sec_flags (abfd, hdr)
sec_flags |= SEC_DEBUGGING;
#endif
}
else if (strcmp (name, _TEXT) == 0)
{
if (sec_flags & SEC_NEVER_LOAD)
sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
else
sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
}
else if (strcmp (name, _DATA) == 0
#ifdef TWO_DATA_SECS
|| strcmp (name, ".data2") == 0
#endif
)
{
if (sec_flags & SEC_NEVER_LOAD)
sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
else
sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
}
else if (strcmp (name, _BSS) == 0)
{
#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
if (sec_flags & SEC_NEVER_LOAD)
sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
else
#endif
sec_flags |= SEC_ALLOC;
}
else if (strcmp (name, ".debug") == 0
#ifdef _COMMENT
|| strcmp (name, _COMMENT) == 0
#endif
|| strcmp (name, ".stab") == 0
|| strcmp (name, ".stabstr") == 0)
{
#ifdef COFF_PAGE_SIZE
sec_flags |= SEC_DEBUGGING;
#endif
}
#ifdef _LIB
else if (strcmp (name, _LIB) == 0)
;
#endif
#ifdef _LIT
else if (strcmp (name, _LIT) == 0)
{
sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
}
#endif
else
{
sec_flags |= SEC_ALLOC | SEC_LOAD;
@ -585,7 +634,8 @@ dependent COFF routines:
. PTR internal_aouthdr));
. flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
. bfd *abfd,
. PTR internal_scnhdr));
. PTR internal_scnhdr,
. const char *name));
. asection *(*_bfd_make_section_hook) PARAMS ((
. bfd *abfd,
. char *name));
@ -671,8 +721,8 @@ dependent COFF routines:
.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
.
.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\
. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr))
.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
. ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
.
.#define bfd_coff_make_section_hook(abfd, name)\
. ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name))
@ -1378,7 +1428,8 @@ coff_compute_section_file_positions (abfd)
#ifdef COFF_PAGE_SIZE
/* In demand paged files the low order bits of the file offset
must match the low order bits of the virtual address. */
if ((abfd->flags & D_PAGED) != 0)
if ((abfd->flags & D_PAGED) != 0
&& (current->flags & SEC_ALLOC) != 0)
sofar += (current->vma - sofar) % COFF_PAGE_SIZE;
#endif
@ -1771,16 +1822,29 @@ coff_write_object_contents (abfd)
internal_a.magic = APOLLO_COFF_VERSION_NUMBER;
#endif
#if M68 || WE32K
#if defined(M68) || defined(WE32K) || defined(M68K)
#define __A_MAGIC_SET__
/* Never was anything here for the 68k */
#endif /* M68 || WE32K */
#if defined(LYNXOS)
internal_a.magic = LYNXCOFFMAGIC;
#endif /* LYNXOS */
#endif /* M68 || WE32K || M68K */
#if I386
#if defined(I386)
#define __A_MAGIC_SET__
#if defined(LYNXOS)
internal_a.magic = LYNXCOFFMAGIC;
#else /* LYNXOS */
internal_a.magic = ZMAGIC;
#endif /* LYNXOS */
#endif /* I386 */
#if defined(SPARC)
#define __A_MAGIC_SET__
#if defined(LYNXOS)
internal_a.magic = LYNXCOFFMAGIC;
#endif /* LYNXOS */
#endif /* SPARC */
#if RS6000COFF_C
#define __A_MAGIC_SET__
internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :

View File

@ -99,7 +99,7 @@ make_a_section_from_file (abfd, hdr, target_index)
return_section->lineno_count = hdr->s_nlnno;
return_section->userdata = NULL;
return_section->next = (asection *) NULL;
return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr);
return_section->flags = bfd_coff_styp_to_sec_flags_hook (abfd, hdr, name);
return_section->target_index = target_index;
@ -254,7 +254,7 @@ coff_object_p (abfd)
/* Get the BFD section from a COFF symbol section number. */
struct sec *
asection *
coff_section_from_bfd_index (abfd, index)
bfd *abfd;
int index;
@ -263,11 +263,11 @@ coff_section_from_bfd_index (abfd, index)
if (index == N_ABS)
{
return &bfd_abs_section;
return bfd_abs_section_ptr;
}
if (index == N_UNDEF)
{
return &bfd_und_section;
return bfd_und_section_ptr;
}
if(index == N_DEBUG)
{
@ -283,7 +283,7 @@ coff_section_from_bfd_index (abfd, index)
/* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
has a bad symbol table in biglitpow.o. */
return &bfd_und_section;
return bfd_und_section_ptr;
}
/* Get the upper bound of a COFF symbol table. */
@ -410,7 +410,7 @@ fixup_symbol_value (coff_symbol_ptr, syment)
else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING) {
syment->n_value = coff_symbol_ptr->symbol.value;
}
else if (coff_symbol_ptr->symbol.section == & bfd_und_section) {
else if (bfd_is_und_section (coff_symbol_ptr->symbol.section)) {
syment->n_scnum = N_UNDEF;
syment->n_value = 0;
}
@ -472,10 +472,10 @@ coff_renumber_symbols (bfd_ptr)
}
bfd_ptr->outsymbols = newsyms;
for (i = 0; i < symbol_count; i++)
if (symbol_ptr_ptr[i]->section != &bfd_und_section)
if (! bfd_is_und_section (symbol_ptr_ptr[i]->section))
*newsyms++ = symbol_ptr_ptr[i];
for (i = 0; i < symbol_count; i++)
if (symbol_ptr_ptr[i]->section == &bfd_und_section)
if (bfd_is_und_section (symbol_ptr_ptr[i]->section))
*newsyms++ = symbol_ptr_ptr[i];
*newsyms = (asymbol *) NULL;
symbol_ptr_ptr = bfd_ptr->outsymbols;
@ -685,7 +685,7 @@ coff_write_symbol (abfd, symbol, native, written)
if (native->u.syment.n_sclass == C_FILE)
symbol->section = &bfd_debug_section;
if (symbol->section == &bfd_abs_section)
if (bfd_is_abs_section (symbol->section))
{
native->u.syment.n_scnum = N_ABS;
}
@ -693,7 +693,7 @@ coff_write_symbol (abfd, symbol, native, written)
{
native->u.syment.n_scnum = N_DEBUG;
}
else if (symbol->section == &bfd_und_section)
else if (bfd_is_und_section (symbol->section))
{
native->u.syment.n_scnum = N_UNDEF;
}
@ -767,7 +767,7 @@ coff_write_alien_symbol (abfd, symbol, written)
native = &dummy;
native->u.syment.n_type = T_NULL;
native->u.syment.n_flags = 0;
if (symbol->section == &bfd_und_section)
if (bfd_is_und_section (symbol->section))
{
native->u.syment.n_scnum = N_UNDEF;
native->u.syment.n_value = symbol->value;

View File

@ -75,7 +75,7 @@ typedef struct coff_tdata
#define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
/* Functions in coffgen.c. */
extern bfd_target *coff_object_p PARAMS ((bfd *));
extern const bfd_target *coff_object_p PARAMS ((bfd *));
extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
extern long coff_get_symtab_upper_bound PARAMS ((bfd *));
extern long coff_get_symtab PARAMS ((bfd *, asymbol **));
@ -83,7 +83,7 @@ extern int coff_count_linenumbers PARAMS ((bfd *));
extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
extern boolean coff_renumber_symbols PARAMS ((bfd *));
extern void coff_mangle_symbols PARAMS ((bfd *));
extern void coff_write_symbols PARAMS ((bfd *));
extern boolean coff_write_symbols PARAMS ((bfd *));
extern boolean coff_write_linenumbers PARAMS ((bfd *));
extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
@ -258,7 +258,8 @@ typedef struct
PTR internal_aouthdr));
flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
bfd *abfd,
PTR internal_scnhdr));
PTR internal_scnhdr,
const char *name));
asection *(*_bfd_make_section_hook) PARAMS ((
bfd *abfd,
char *name));
@ -344,8 +345,8 @@ typedef struct
#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\
((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr))
#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
#define bfd_coff_make_section_hook(abfd, name)\
((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name))

View File

@ -229,7 +229,7 @@ extern boolean _bfd_ecoff_slurp_symbolic_info
/* Generic ECOFF BFD backend vectors. */
extern boolean _bfd_ecoff_write_object_contents PARAMS ((bfd *abfd));
extern bfd_target *_bfd_ecoff_archive_p PARAMS ((bfd *abfd));
extern const bfd_target *_bfd_ecoff_archive_p PARAMS ((bfd *abfd));
#define _bfd_ecoff_close_and_cleanup _bfd_generic_close_and_cleanup
#define _bfd_ecoff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
@ -293,5 +293,6 @@ extern asection *_bfd_ecoff_make_section_hook PARAMS ((bfd *abfd, char *name));
#define _bfd_ecoff_set_alignment_hook \
((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)
extern boolean _bfd_ecoff_set_arch_mach_hook PARAMS ((bfd *abfd, PTR filehdr));
extern flagword _bfd_ecoff_styp_to_sec_flags PARAMS ((bfd *abfd, PTR hdr));
extern flagword _bfd_ecoff_styp_to_sec_flags
PARAMS ((bfd *abfd, PTR hdr, const char *name));
extern boolean _bfd_ecoff_slurp_symbol_table PARAMS ((bfd *abfd));