static bfd_target * som_object_setup PARAMS ((bfd *,
struct header *,
struct som_exec_auxhdr *));
-static asection * make_unique_section PARAMS ((bfd *, CONST char *, int));
static boolean setup_sections PARAMS ((bfd *, struct header *));
static bfd_target * som_object_p PARAMS ((bfd *));
static boolean som_write_object_contents PARAMS ((bfd *));
static boolean som_new_section_hook PARAMS ((bfd *, asection *));
static boolean som_bfd_copy_private_section_data PARAMS ((bfd *, asection *,
bfd *, asection *));
+static boolean som_bfd_copy_private_bfd_data PARAMS ((bfd *, bfd *));
static boolean som_bfd_is_local_label PARAMS ((bfd *, asymbol *));
static boolean som_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
file_ptr, bfd_size_type));
{R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"},
{R_RESERVED, 0, 0, 32, false, 0, 0, hppa_som_reloc, "R_RESERVED"}};
-
/* Initialize the SOM relocation queue. By definition the queue holds
the last four multibyte fixups. */
obj_som_str_filepos (abfd) = file_hdrp->symbol_strings_location;
obj_som_reloc_filepos (abfd) = file_hdrp->fixup_request_location;
+ obj_som_exec_data (abfd) = (struct som_exec_data *)
+ bfd_zalloc (abfd, sizeof (struct som_exec_data ));
+ if (obj_som_exec_data (abfd) == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+
+ obj_som_exec_data (abfd)->system_id = file_hdrp->system_id;
+ obj_som_exec_data (abfd)->exec_flags = aux_hdrp->exec_flags;
return abfd->xvec;
}
subspace.quadrant);
/* Keep an easy mapping between subspaces and sections. */
- som_section_data (subspace_asect)->subspace_index
- = total_subspaces++;
+ subspace_asect->target_index = total_subspaces++;
/* Set SEC_READONLY and SEC_CODE/SEC_DATA as specified
by the access_control_bits in the subspace header. */
abfd->tdata.som_data = (struct som_data_struct *)
bfd_zalloc (abfd, sizeof (struct som_data_struct));
if (abfd->tdata.som_data == NULL)
- {
- bfd_set_error (bfd_error_no_memory);
- return false;
- }
- obj_som_file_hdr (abfd)
- = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
- if (obj_som_file_hdr (abfd) == NULL)
-
{
bfd_set_error (bfd_error_no_memory);
return false;
som_prep_headers (abfd)
bfd *abfd;
{
- struct header *file_hdr = obj_som_file_hdr (abfd);
+ struct header *file_hdr;
asection *section;
+ /* Make and attach a file header to the BFD. */
+ file_hdr = (struct header *) bfd_zalloc (abfd, sizeof (struct header));
+ if (file_hdr == NULL)
+
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+ obj_som_file_hdr (abfd) = file_hdr;
+
/* FIXME. This should really be conditional based on whether or not
PA1.1 instructions/registers have been used. */
- file_hdr->system_id = CPU_PA_RISC1_0;
+ if (abfd->flags & EXEC_P)
+ file_hdr->system_id = obj_som_exec_data (abfd)->system_id;
+ else
+ file_hdr->system_id = CPU_PA_RISC1_0;
if (abfd->flags & EXEC_P)
{
file_hdr->file_time.secs = 0;
file_hdr->file_time.nanosecs = 0;
- if (abfd->flags & EXEC_P)
- abort ();
- else
- {
- file_hdr->entry_space = 0;
- file_hdr->entry_subspace = 0;
- file_hdr->entry_offset = 0;
- }
-
+ file_hdr->entry_space = 0;
+ file_hdr->entry_subspace = 0;
+ file_hdr->entry_offset = 0;
file_hdr->presumed_dp = 0;
/* Now iterate over the sections translating information from
first_subspace = 0;
}
- som_section_data (subsection)->subspace_index = total_subspaces++;
+ subsection->target_index = total_subspaces++;
/* This is real data to be loaded from the file. */
if (subsection->flags & SEC_LOAD)
{
|| (subsection->flags & SEC_ALLOC) != 0)
continue;
- som_section_data (subsection)->subspace_index = total_subspaces++;
+ subsection->target_index = total_subspaces;
/* This is real data to be loaded from the file. */
if ((subsection->flags & SEC_LOAD) == 0)
{
{
long tmp;
+ exec_header.exec_entry = bfd_get_start_address (abfd);
+ exec_header.exec_flags = obj_som_exec_data (abfd)->exec_flags;
+
/* Oh joys. Ram some of the BSS data into the DATA section
to be compatable with how the hp linker makes objects
(saves memory space). */
/* For all other symbols, the symbol_info field contains the
subspace index of the space this symbol is contained in. */
else
- info->symbol_info = som_section_data (sym->section)->subspace_index;
+ info->symbol_info = sym->section->target_index;
/* Set the symbol's value. */
info->symbol_value = sym->value + sym->section->vma;
asection *section;
for (section = abfd->sections; section != NULL; section = section->next)
- if (som_section_data (section)->subspace_index == index)
+ if (section->target_index == index)
return section;
/* Should never happen. */
}
newsect->alignment_power = 3;
- /* Initialize the subspace_index field to -1 so that it does
- not match a subspace with an index of 0. */
- som_section_data (newsect)->subspace_index = -1;
-
/* We allow more than three sections internally */
return true;
}
if (som_section_data (osection)->containing_space)
som_section_data (osection)->containing_space =
som_section_data (osection)->containing_space->output_section;
+
+ return true;
}
-
+
+/* Copy any private info we understand from the input bfd
+ to the output bfd. */
+
+static boolean
+som_bfd_copy_private_bfd_data (ibfd, obfd)
+ bfd *ibfd, *obfd;
+{
+ /* One day we may try to grok other private data. */
+ if (ibfd->xvec->flavour != bfd_target_som_flavour
+ || obfd->xvec->flavour != bfd_target_som_flavour)
+ return false;
+
+ /* Allocate some memory to hold the data we need. */
+ obj_som_exec_data (obfd) = (struct som_exec_data *)
+ bfd_zalloc (obfd, sizeof (struct som_exec_data));
+ if (obj_som_exec_data (obfd) == NULL)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return false;
+ }
+
+ /* Now copy the data. */
+ memcpy (obj_som_exec_data (obfd), obj_som_exec_data (ibfd),
+ sizeof (struct som_exec_data));
+
+ return true;
+}
+
/* Set backend info for sections which can not be described
in the BFD data structures. */
#define som_core_file_failing_signal _bfd_dummy_core_file_failing_signal
#define som_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p
-#define som_bfd_copy_private_bfd_data \
- ((boolean (*) PARAMS ((bfd *, bfd *))) bfd_true)
-
bfd_target som_vec =
{
"som", /* name */
/* HP PA-RISC SOM object file format: definitions internal to BFD.
- Copyright (C) 1990-1991 Free Software Foundation, Inc.
+ Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
Contributed by the Center for Software Science at the
University of Utah (pa-gdb-bugs@cs.utah.edu).
}
som_symbol_type;
+/* A structure containing all the magic information stored in a BFD's
+ private data which needs to be copied during an objcopy/strip run. */
+struct som_exec_data
+ {
+ /* Sort-of a magic number. BSD uses it to distinguish between
+ native executables and hpux executables. */
+ short system_id;
+
+ /* Magic exec flags. These control things like whether or not
+ null pointer dereferencing is allowed and the like. */
+ long exec_flags;
+
+ /* Add more stuff here as needed. Good examples of information
+ we might want to pass would be presumed_dp, entry_* and maybe
+ others from the file header. */
+ };
+
struct somdata
{
+ /* All the magic information about an executable which lives
+ in the private BFD structure and needs to be copied from
+ the input bfd to the output bfd during a objcopy/strip. */
+ struct som_exec_data *exec_data;
+
+ /* These three fields are only used when writing files and are
+ generated from scratch. They need not be copied for objcopy
+ or strip to work. */
struct header *file_hdr;
struct copyright_aux_hdr *copyright_aux_hdr;
struct user_string_aux_hdr *version_aux_hdr;
+
+ /* Pointers to a saved copy of the symbol and string tables. These
+ need not be copied for objcopy or strip to work. */
som_symbol_type *symtab;
char *stringtab;
/* We remember these offsets so that after check_file_format, we have
- no dependencies on the particular format of the exec_hdr. */
+ no dependencies on the particular format of the exec_hdr.
+ These offsets need not be copied for objcopy or strip to work. */
file_ptr sym_filepos;
file_ptr str_filepos;
file_ptr reloc_filepos;
-
unsigned stringtab_size;
};
struct som_section_data_struct
{
+ unsigned int is_space : 1;
+ unsigned int is_subspace : 1;
unsigned int reloc_size;
char *reloc_stream;
- unsigned int subspace_index;
asection *containing_space;
- int is_space;
struct space_dictionary_record space_dict;
- int is_subspace;
struct subspace_dictionary_record subspace_dict;
};
#define somdata(bfd) ((bfd)->tdata.som_data->a)
+#define obj_som_exec_data(bfd) (somdata(bfd).exec_data)
#define obj_som_file_hdr(bfd) (somdata(bfd).file_hdr)
#define obj_som_copyright_hdr(bfd) (somdata(bfd).copyright_aux_hdr)
#define obj_som_version_hdr(bfd) (somdata(bfd).version_aux_hdr)