* aout-target.h (MY_zmagic_contiguous): Define as 0 if not already

defined.
	(MY(backend_data)): Use MY_zmagic_contiguous, not hardcoded 0.
	* i386linux.c (MY_zmagic_contiguous): Define.
This commit is contained in:
Ian Lance Taylor 1994-08-15 18:12:05 +00:00
parent 823609fe90
commit a932d0ffb7
3 changed files with 84 additions and 30 deletions

View File

@ -1,5 +1,10 @@
Mon Aug 15 12:16:56 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) Mon Aug 15 12:16:56 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
* aout-target.h (MY_zmagic_contiguous): Define as 0 if not already
defined.
(MY(backend_data)): Use MY_zmagic_contiguous, not hardcoded 0.
* i386linux.c (MY_zmagic_contiguous): Define.
* elfcode.h (bfd_section_from_shdr): If a SHT_SYMTAB section in a * elfcode.h (bfd_section_from_shdr): If a SHT_SYMTAB section in a
shared object has SHF_ALLOC set, create a BFD section for it. shared object has SHF_ALLOC set, create a BFD section for it.
(elf_section_from_bfd_section): There may be a BFD section for a (elf_section_from_bfd_section): There may be a BFD section for a

View File

@ -27,11 +27,13 @@ extern CONST struct reloc_howto_struct * NAME(aout,reloc_type_lookup) ();
/* Set parameters about this a.out file that are machine-dependent. /* Set parameters about this a.out file that are machine-dependent.
This routine is called from some_aout_object_p just before it returns. */ This routine is called from some_aout_object_p just before it returns. */
#ifndef MY_callback #ifndef MY_callback
static bfd_target * static const bfd_target *
MY(callback) (abfd) MY(callback) (abfd)
bfd *abfd; bfd *abfd;
{ {
struct internal_exec *execp = exec_hdr (abfd); struct internal_exec *execp = exec_hdr (abfd);
unsigned int arch_align_power;
unsigned long arch_align;
/* Calculate the file positions of the parts of a newly read aout header */ /* Calculate the file positions of the parts of a newly read aout header */
obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp); obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
@ -63,11 +65,22 @@ MY(callback) (abfd)
/* Now that we know the architecture, set the alignments of the /* Now that we know the architecture, set the alignments of the
sections. This is normally done by NAME(aout,new_section_hook), sections. This is normally done by NAME(aout,new_section_hook),
but when the initial sections were created the architecture had but when the initial sections were created the architecture had
not yet been set. */ not yet been set. However, for backward compatibility, we don't
obj_textsec (abfd)->alignment_power = set the alignment power any higher than as required by the size
obj_datasec (abfd)->alignment_power = of the section. */
obj_bsssec (abfd)->alignment_power = arch_align_power = bfd_get_arch_info (abfd)->section_align_power;
bfd_get_arch_info (abfd)->section_align_power; arch_align = 1 << arch_align_power;
if ((BFD_ALIGN (obj_textsec (abfd)->_raw_size, arch_align)
== obj_textsec (abfd)->_raw_size)
&& (BFD_ALIGN (obj_datasec (abfd)->_raw_size, arch_align)
== obj_datasec (abfd)->_raw_size)
&& (BFD_ALIGN (obj_bsssec (abfd)->_raw_size, arch_align)
== obj_bsssec (abfd)->_raw_size))
{
obj_textsec (abfd)->alignment_power = arch_align_power;
obj_datasec (abfd)->alignment_power = arch_align_power;
obj_bsssec (abfd)->alignment_power = arch_align_power;
}
/* Don't set sizes now -- can't be sure until we know arch & mach. /* Don't set sizes now -- can't be sure until we know arch & mach.
Sizes get set in set_sizes callback, later. */ Sizes get set in set_sizes callback, later. */
@ -88,13 +101,13 @@ MY(callback) (abfd)
#ifndef MY_object_p #ifndef MY_object_p
/* Finish up the reading of an a.out file header */ /* Finish up the reading of an a.out file header */
static bfd_target * static const bfd_target *
MY(object_p) (abfd) MY(object_p) (abfd)
bfd *abfd; bfd *abfd;
{ {
struct external_exec exec_bytes; /* Raw exec header from file */ struct external_exec exec_bytes; /* Raw exec header from file */
struct internal_exec exec; /* Cleaned-up exec header */ struct internal_exec exec; /* Cleaned-up exec header */
bfd_target *target; const bfd_target *target;
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
!= EXEC_BYTES_SIZE) { != EXEC_BYTES_SIZE) {
@ -115,6 +128,12 @@ MY(object_p) (abfd)
#endif #endif
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
#ifdef SWAP_MAGIC
/* swap_exec_header_in read in a_info with the wrong byte order */
exec.a_info = SWAP_MAGIC (exec_bytes.e_info);
#endif /* SWAP_MAGIC */
target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback)); target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
#ifdef ENTRY_CAN_BE_ZERO #ifdef ENTRY_CAN_BE_ZERO
@ -217,11 +236,19 @@ MY(set_sizes) (abfd)
bfd *abfd; bfd *abfd;
{ {
adata(abfd).page_size = PAGE_SIZE; adata(abfd).page_size = PAGE_SIZE;
#ifdef SEGMENT_SIZE #ifdef SEGMENT_SIZE
adata(abfd).segment_size = SEGMENT_SIZE; adata(abfd).segment_size = SEGMENT_SIZE;
#else #else
adata(abfd).segment_size = PAGE_SIZE; adata(abfd).segment_size = PAGE_SIZE;
#endif #endif
#ifdef ZMAGIC_DISK_BLOCK_SIZE
adata(abfd).zmagic_disk_block_size = ZMAGIC_DISK_BLOCK_SIZE;
#else
adata(abfd).zmagic_disk_block_size = PAGE_SIZE;
#endif
adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE; adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
return true; return true;
} }
@ -234,6 +261,9 @@ MY(set_sizes) (abfd)
#ifndef MY_backend_data #ifndef MY_backend_data
#ifndef MY_zmagic_contiguous
#define MY_zmagic_contiguous 0
#endif
#ifndef MY_text_includes_header #ifndef MY_text_includes_header
#define MY_text_includes_header 0 #define MY_text_includes_header 0
#endif #endif
@ -257,7 +287,7 @@ MY(set_sizes) (abfd)
#endif #endif
static CONST struct aout_backend_data MY(backend_data) = { static CONST struct aout_backend_data MY(backend_data) = {
0, /* zmagic contiguous */ MY_zmagic_contiguous,
MY_text_includes_header, MY_text_includes_header,
MY_exec_hdr_flags, MY_exec_hdr_flags,
0, /* text vma? */ 0, /* text vma? */
@ -472,7 +502,7 @@ MY_bfd_final_link (abfd, info)
#endif #endif
#ifndef MY_BFD_TARGET #ifndef MY_BFD_TARGET
bfd_target MY(vec) = const bfd_target MY(vec) =
{ {
TARGETNAME, /* name */ TARGETNAME, /* name */
bfd_target_aout_flavour, bfd_target_aout_flavour,

View File

@ -22,7 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define SEGMENT_SIZE 4096 #define SEGMENT_SIZE 4096
#define TEXT_START_ADDR 0x0 #define TEXT_START_ADDR 0x0
#define N_SHARED_LIB(x) 0 #define N_SHARED_LIB(x) 0
#define ARCH 32
#define BYTES_IN_WORD 4 #define BYTES_IN_WORD 4
#include "bfd.h" #include "bfd.h"
@ -35,7 +34,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define DEFAULT_ARCH bfd_arch_i386 #define DEFAULT_ARCH bfd_arch_i386
#define MY(OP) CAT(i386linux_,OP) #define MY(OP) CAT(i386linux_,OP)
#define MY_text_includes_header 1
#define TARGETNAME "a.out-i386-linux" #define TARGETNAME "a.out-i386-linux"
/* We always generate QMAGIC files in preference to ZMAGIC files. It /* We always generate QMAGIC files in preference to ZMAGIC files. It
@ -343,7 +341,8 @@ linux_add_one_symbol (info, abfd, name, flags, section, value, string,
if (! info->relocateable if (! info->relocateable
&& linux_hash_table (info)->dynobj == NULL && linux_hash_table (info)->dynobj == NULL
&& strcmp (name, SHARABLE_CONFLICTS) == 0) && strcmp (name, SHARABLE_CONFLICTS) == 0
&& (flags & BSF_CONSTRUCTOR) != 0)
{ {
if (! linux_link_create_dynamic_sections (abfd, info)) if (! linux_link_create_dynamic_sections (abfd, info))
return false; return false;
@ -351,7 +350,7 @@ linux_add_one_symbol (info, abfd, name, flags, section, value, string,
insert = true; insert = true;
} }
if (section == &bfd_abs_section if (bfd_is_abs_section (section)
&& (IS_GOT_SYM (name) || IS_PLT_SYM (name))) && (IS_GOT_SYM (name) || IS_PLT_SYM (name)))
{ {
h = linux_link_hash_lookup (linux_hash_table (info), name, false, h = linux_link_hash_lookup (linux_hash_table (info), name, false,
@ -359,12 +358,18 @@ linux_add_one_symbol (info, abfd, name, flags, section, value, string,
if (h != NULL if (h != NULL
&& h->root.root.type == bfd_link_hash_defined) && h->root.root.type == bfd_link_hash_defined)
{ {
if (new_fixup (info, h, value, ! IS_PLT_SYM(name)) == NULL) struct fixup *f;
if (hashp != NULL)
*hashp = (struct bfd_link_hash_entry *) h;
f = new_fixup (info, h, value, ! IS_PLT_SYM (name));
if (f == NULL)
return false; return false;
f->jump = IS_PLT_SYM (name);
return true; return true;
} }
if (hashp != NULL)
*hashp = (struct bfd_link_hash_entry *) h;
} }
/* Do the usual procedure for adding a symbol. */ /* Do the usual procedure for adding a symbol. */
@ -413,6 +418,7 @@ linux_tally_symbols (h, data)
struct fixup *f, *f1; struct fixup *f, *f1;
int is_plt; int is_plt;
struct linux_link_hash_entry *h1, *h2; struct linux_link_hash_entry *h1, *h2;
boolean exists;
/* If this symbol is not a PLT/GOT, we do not even need to look at it */ /* If this symbol is not a PLT/GOT, we do not even need to look at it */
is_plt = IS_PLT_SYM (h->root.root.root.string); is_plt = IS_PLT_SYM (h->root.root.root.string);
@ -440,38 +446,49 @@ linux_tally_symbols (h, data)
from different shared libraries */ from different shared libraries */
if (h1 != NULL if (h1 != NULL
&& ((h1->root.root.type == bfd_link_hash_defined && ((h1->root.root.type == bfd_link_hash_defined
&& h1->root.root.u.def.section != &bfd_abs_section) && ! bfd_is_abs_section (h1->root.root.u.def.section))
|| h2->root.root.type == bfd_link_hash_indirect)) || h2->root.root.type == bfd_link_hash_indirect))
{ {
f = new_fixup (info, h1, h->root.root.u.def.value, 0);
if (f == NULL)
{
/* FIXME: No way to return error. */
abort ();
}
f->jump = is_plt;
/* See if there is a "builtin" fixup already present /* See if there is a "builtin" fixup already present
involving this symbol. If so, convert it to a regular involving this symbol. If so, convert it to a regular
fixup. In the end, this relaxes some of the requirements fixup. In the end, this relaxes some of the requirements
about the order of performing fixups. */ about the order of performing fixups. */
exists = false;
for (f1 = linux_hash_table (info)->fixup_list; for (f1 = linux_hash_table (info)->fixup_list;
f1 != NULL; f1 != NULL;
f1 = f1->next) f1 = f1->next)
{ {
if (f1 == f) if (f1->h != h
continue; || (! f1->builtin && ! f1->jump))
if (f1->h != h)
continue; continue;
if (! exists
&& bfd_is_abs_section (h->root.root.u.def.section))
{
f = new_fixup (info, h1, f1->h->root.root.u.def.value, 0);
f->jump = is_plt;
}
f1->h = h1; f1->h = h1;
f1->jump = is_plt; f1->jump = is_plt;
f1->builtin = 0; f1->builtin = 0;
exists = true;
}
if (! exists
&& bfd_is_abs_section (h->root.root.u.def.section))
{
f = new_fixup (info, h1, h->root.root.u.def.value, 0);
if (f == NULL)
{
/* FIXME: No way to return error. */
abort ();
}
f->jump = is_plt;
} }
} }
/* Quick and dirty way of stripping these symbols from the /* Quick and dirty way of stripping these symbols from the
symtab. */ symtab. */
h->root.written = true; if (bfd_is_abs_section (h->root.root.u.def.section))
h->root.written = true;
} }
return true; return true;
@ -697,4 +714,6 @@ linux_finish_dynamic_link (output_bfd, info)
#define MY_add_one_symbol linux_add_one_symbol #define MY_add_one_symbol linux_add_one_symbol
#define MY_finish_dynamic_link linux_finish_dynamic_link #define MY_finish_dynamic_link linux_finish_dynamic_link
#define MY_zmagic_contiguous 1
#include "aout-target.h" #include "aout-target.h"