+Mon Mar 14 11:41:23 1994 Jeffrey A. Law (law@snake.cs.utah.edu)
+
+ * som.c (som_object_setup): Set EXEC_P, D_PAGED, WP_TEXT, and
+ HAS_RELOC based on the object's magic number.
+ (make_unique_section): Delete function. BFD and its users are
+ prepared to handle multiple sections with the same name.
+ (setup_sections): Allocate space on the BFD's obstack to hold
+ section names. Use bfd_make_setion_anyway rather than the
+ obsolete make_unique_section.
+ (som_prep_headers): Choose the correct SOM magic number based
+ on the BFD's flags.
+ (som_bfd_fill_in_ar_symbols): Return false, not NULL on error.
+
Sat Mar 12 09:46:09 1994 Ian Lance Taylor (ian@cygnus.com)
* elf32-ppc.c: Renamed from elf32-powerpc.c.
/* Set BFD flags based on what information is available in the SOM. */
abfd->flags = NO_FLAGS;
- if (! file_hdrp->entry_offset)
- abfd->flags |= HAS_RELOC;
- else
- abfd->flags |= EXEC_P;
if (file_hdrp->symbol_total)
abfd->flags |= HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS;
+ switch (file_hdrp->a_magic)
+ {
+ case DEMAND_MAGIC:
+ abfd->flags |= (D_PAGED | WP_TEXT | EXEC_P);
+ break;
+ case SHARE_MAGIC:
+ abfd->flags |= (WP_TEXT | EXEC_P);
+ break;
+ case EXEC_MAGIC:
+ abfd->flags |= (EXEC_P);
+ break;
+ case RELOC_MAGIC:
+ abfd->flags |= HAS_RELOC;
+ break;
+ default:
+ break;
+ }
+
bfd_get_start_address (abfd) = aux_hdrp->exec_entry;
bfd_default_set_arch_mach (abfd, bfd_arch_hppa, 0);
bfd_get_symcount (abfd) = file_hdrp->symbol_total;
return abfd->xvec;
}
-/* Create a new BFD section for NAME. If NAME already exists, then create a
- new unique name, with NAME as the prefix. This exists because SOM .o files
- may have more than one $CODE$ subspace. */
-
-static asection *
-make_unique_section (abfd, name, num)
- bfd *abfd;
- CONST char *name;
- int num;
-{
- asection *sect;
- char *newname;
- char altname[100];
-
- sect = bfd_make_section (abfd, name);
- while (!sect)
- {
- sprintf (altname, "%s-%d", name, num++);
- sect = bfd_make_section (abfd, altname);
- }
-
- newname = bfd_alloc (abfd, strlen (sect->name) + 1);
- if (!newname)
- {
- bfd_set_error (bfd_error_no_memory);
- return NULL;
- }
- strcpy (newname, sect->name);
-
- sect->name = newname;
- return sect;
-}
-
/* Convert all of the space and subspace info into BFD sections. Each space
contains a number of subspaces, which in turn describe the mapping between
regions of the exec file, and the address space that the program runs in.
struct subspace_dictionary_record subspace, save_subspace;
int subspace_index;
asection *space_asect;
+ char *newname;
/* Read the space dictionary element */
if (bfd_seek (abfd, file_hdr->space_location
space.name.n_name = space.name.n_strx + space_strings;
/* Make a section out of it */
- space_asect = make_unique_section (abfd, space.name.n_name, space_index);
+ newname = bfd_alloc (abfd, strlen (space.name.n_name) + 1);
+ if (!newname)
+ goto error_return;
+ strcpy (newname, space.name.n_name);
+
+ space_asect = bfd_make_section_anyway (abfd, newname);
if (!space_asect)
goto error_return;
/* Setup the subspace name string */
subspace.name.n_name = subspace.name.n_strx + space_strings;
- /* Make a section out of this subspace */
- subspace_asect = make_unique_section (abfd, subspace.name.n_name,
- space.subspace_index + subspace_index);
+ newname = bfd_alloc (abfd, strlen (subspace.name.n_name) + 1);
+ if (!newname)
+ goto error_return;
+ strcpy (newname, subspace.name.n_name);
+ /* Make a section out of this subspace */
+ subspace_asect = bfd_make_section_anyway (abfd, newname);
if (!subspace_asect)
goto error_return;
PA1.1 instructions/registers have been used. */
file_hdr->system_id = CPU_PA_RISC1_0;
- /* FIXME. Only correct for building relocatable objects. */
if (abfd->flags & EXEC_P)
- abort ();
+ {
+ if (abfd->flags & D_PAGED)
+ file_hdr->a_magic = DEMAND_MAGIC;
+ else if (abfd->flags & WP_TEXT)
+ file_hdr->a_magic = SHARE_MAGIC;
+ else
+ file_hdr->a_magic = EXEC_MAGIC;
+ }
else
file_hdr->a_magic = RELOC_MAGIC;
if (strncmp (ar_header.ar_fmag, ARFMAG, 2))
{
bfd_set_error (bfd_error_malformed_archive);
- return NULL;
+ return false;
}
/* How big is the archive symbol table entry? */
if (errno != 0)
{
bfd_set_error (bfd_error_malformed_archive);
- return NULL;
+ return false;
}
/* Save off the file offset of the first real user data. */
if (lst_header.a_magic != LIBMAGIC)
{
bfd_set_error (bfd_error_malformed_archive);
- return NULL;
+ return false;
}
/* Count the number of symbols in the library symbol table. */