Index: aoutx.h =================================================================== RCS file: /cvs/src/src/bfd/aoutx.h,v retrieving revision 1.36 diff -c -r1.36 aoutx.h *** aoutx.h 25 Oct 2002 02:45:53 -0000 1.36 --- aoutx.h 25 Nov 2002 23:31:15 -0000 *************** *** 1283,1293 **** 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 (count != 0) --- 1283,1299 ---- if (section != obj_textsec (abfd) && section != obj_datasec (abfd)) { ! 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) *************** *** 1699,1709 **** 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; } /* Turn the symbol from section relative to absolute again. */ --- 1705,1720 ---- sym_pointer->e_type[0] = N_UNDF | N_EXT; else { ! 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. */ Index: libaout.h =================================================================== RCS file: /cvs/src/src/bfd/libaout.h,v retrieving revision 1.8 diff -c -r1.8 libaout.h *** libaout.h 8 Jun 2002 23:01:10 -0000 1.8 --- libaout.h 25 Nov 2002 23:31:17 -0000 *************** *** 672,675 **** --- 672,694 ---- } #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) */