Allow an otherwise unrepresentable read-only section that lies after .text
and before .data to be written into the output file and included in a_text.
This commit is contained in:
parent
e06d9b4589
commit
e6af3a53b1
3 changed files with 76 additions and 36 deletions
|
@ -1,3 +1,13 @@
|
|||
2002-12-10 Jason Thorpe <thorpej@wasabisystems.com>
|
||||
|
||||
* aoutx.h (set_section_contents): Allow an otherwise unrepresentable
|
||||
read-only section that lies after .text and before .data to be
|
||||
written into the output file and included in a_text.
|
||||
(translate_to_native_sym_flags): If an otherwise unrepresentable
|
||||
section was merged with .text, convert its symbols to N_TEXT
|
||||
symbols.
|
||||
* libaout.h (aout_section_merge_with_text_p): New macro.
|
||||
|
||||
2002-12-08 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* bfd-in.h: Comment typo fix. Formatting.
|
||||
|
|
11
bfd/aoutx.h
11
bfd/aoutx.h
|
@ -1286,6 +1286,11 @@ NAME(aout,set_section_contents) (abfd, section, location, offset, count)
|
|||
|
||||
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"),
|
||||
|
@ -1293,6 +1298,7 @@ NAME(aout,set_section_contents) (abfd, section, location, offset, count)
|
|||
bfd_set_error (bfd_error_nonrepresentable_section);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (count != 0)
|
||||
{
|
||||
|
@ -1701,6 +1707,10 @@ translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
|
|||
sym_pointer->e_type[0] = N_INDR;
|
||||
else if (bfd_is_com_section (sec))
|
||||
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)
|
||||
|
@ -1709,6 +1719,7 @@ translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer)
|
|||
bfd_set_error (bfd_error_nonrepresentable_section);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn the symbol from section relative to absolute again. */
|
||||
value += sec->vma + off;
|
||||
|
|
|
@ -4,21 +4,21 @@
|
|||
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
|
||||
|
@ -282,8 +282,8 @@ enum machine_type {
|
|||
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*/
|
||||
/* 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 */
|
||||
|
||||
|
@ -377,7 +377,7 @@ struct aoutdata {
|
|||
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;
|
||||
|
@ -387,10 +387,10 @@ struct aoutdata {
|
|||
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. */
|
||||
|
@ -406,7 +406,7 @@ struct aoutdata {
|
|||
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,
|
||||
|
@ -471,7 +471,7 @@ struct aout_data_struct {
|
|||
#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
|
||||
|
@ -489,7 +489,7 @@ struct aout_section_data_struct
|
|||
#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 *));
|
||||
|
@ -648,7 +648,7 @@ extern bfd_boolean NAME(aout,bfd_free_cached_info)
|
|||
|| 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) \
|
||||
|
@ -672,4 +672,23 @@ extern bfd_boolean NAME(aout,bfd_free_cached_info)
|
|||
}
|
||||
#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) */
|
||||
|
|
Loading…
Reference in a new issue