if (section != obj_textsec (abfd)
&& section != obj_datasec (abfd))
{
- (*_bfd_error_handler)
- (_("%s: can not represent section `%s' in a.out object file format"),
- bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return FALSE;
+ if (aout_section_merge_with_text_p (abfd, section))
+ section->filepos = obj_textsec (abfd)->filepos +
+ (section->vma - obj_textsec (abfd)->vma);
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: can not represent section `%s' in a.out object file format"),
+ bfd_get_filename (abfd), bfd_get_section_name (abfd, section));
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return FALSE;
+ }
}
if (count != 0)
sym_pointer->e_type[0] = N_UNDF | N_EXT;
else
{
- (*_bfd_error_handler)
- (_("%s: can not represent section `%s' in a.out object file format"),
- bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
- bfd_set_error (bfd_error_nonrepresentable_section);
- return FALSE;
+ if (aout_section_merge_with_text_p (abfd, sec))
+ sym_pointer->e_type[0] |= N_TEXT;
+ else
+ {
+ (*_bfd_error_handler)
+ (_("%s: can not represent section `%s' in a.out object file format"),
+ bfd_get_filename (abfd), bfd_get_section_name (abfd, sec));
+ bfd_set_error (bfd_error_nonrepresentable_section);
+ return FALSE;
+ }
}
/* Turn the symbol from section relative to absolute again. */
Free Software Foundation, Inc.
Written by Cygnus Support.
-This file is part of BFD, the Binary File Descriptor library.
+ 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 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.
+ 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. */
+ 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. */
#ifndef LIBAOUT_H
#define LIBAOUT_H
M_68010 = 1,
M_68020 = 2,
M_SPARC = 3,
- /* skip a bunch so we don't run into any of suns numbers */
- /* make these up for the ns32k*/
- M_NS32032 = (64), /* ns32032 running ? */
- M_NS32532 = (64 + 5), /* ns32532 running mach */
+ /* Skip a bunch so we don't run into any of SUN's numbers. */
+ /* Make these up for the ns32k. */
+ M_NS32032 = (64), /* ns32032 running ? */
+ M_NS32532 = (64 + 5), /* ns32532 running mach */
M_386 = 100,
M_29K = 101, /* AMD 29000 */
struct internal_exec *hdr; /* exec file header */
aout_symbol_type *symbols; /* symtab for input bfd */
- /* For ease, we do this */
+ /* For ease, we do this. */
asection *textsec;
asection *datasec;
asection *bsssec;
file_ptr sym_filepos;
file_ptr str_filepos;
- /* Size of a relocation entry in external form */
+ /* Size of a relocation entry in external form. */
unsigned reloc_entry_size;
- /* Size of a symbol table entry in external form */
+ /* Size of a symbol table entry in external form. */
unsigned symbol_entry_size;
- /* Page size - needed for alignment of demand paged files. */
+ /* Page size - needed for alignment of demand paged files. */
unsigned long page_size;
- /* Segment size - needed for alignment of demand paged files. */
+ /* Segment size - needed for alignment of demand paged files. */
unsigned long segment_size;
/* Zmagic disk block size - need to align the start of the text
unsigned exec_bytes_size;
unsigned vma_adjusted : 1;
- /* used when a bfd supports several highly similar formats */
+ /* Used when a bfd supports several highly similar formats. */
enum
{
default_format = 0,
#define obj_aout_dynamic_info(bfd) (adata(bfd).dynamic_info)
/* We take the address of the first element of an asymbol to ensure that the
- macro is only ever applied to an asymbol */
+ macro is only ever applied to an asymbol. */
#define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
/* Information we keep for each a.out section. This is currently only
#define set_aout_section_data(s,v) \
((s)->used_by_bfd = (PTR)&(v)->relocs)
-/* Prototype declarations for functions defined in aoutx.h */
+/* Prototype declarations for functions defined in aoutx.h. */
extern bfd_boolean NAME(aout,squirt_out_relocs)
PARAMS ((bfd *, asection *));
extern bfd_boolean NAME(aout,bfd_free_cached_info)
PARAMS ((bfd *));
-/* A.out uses the generic versions of these routines... */
+/* A.out uses the generic versions of these routines... */
#define aout_16_get_section_contents _bfd_generic_get_section_contents
|| bfd_bwrite ((PTR) &exec_bytes, (bfd_size_type) EXEC_BYTES_SIZE, \
abfd) != EXEC_BYTES_SIZE) \
return FALSE; \
- /* Now write out reloc info, followed by syms and strings */ \
+ /* Now write out reloc info, followed by syms and strings. */ \
\
if (bfd_get_outsymbols (abfd) != (asymbol **) NULL \
&& bfd_get_symcount (abfd) != 0) \
}
#endif
+/* Test if a read-only section can be merged with .text. This is
+ possible if:
+
+ 1. Section has file contents and is read-only.
+ 2. The VMA of the section is after the end of .text and before
+ the start of .data.
+ 3. The image is demand-pageable (otherwise, a_text in the header
+ will not reflect the gap between .text and .data). */
+
+#define aout_section_merge_with_text_p(abfd, sec) \
+ (((sec)->flags & (SEC_HAS_CONTENTS | SEC_READONLY)) == \
+ (SEC_HAS_CONTENTS | SEC_READONLY) \
+ && obj_textsec (abfd) != NULL \
+ && obj_datasec (abfd) != NULL \
+ && (sec)->vma >= (obj_textsec (abfd)->vma + \
+ obj_textsec (abfd)->_cooked_size) \
+ && ((sec)->vma + (sec)->_cooked_size) <= obj_datasec (abfd)->vma \
+ && ((abfd)->flags & D_PAGED) != 0)
+
#endif /* ! defined (LIBAOUT_H) */