aboutsummaryrefslogtreecommitdiff
path: root/bfd/som.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>1995-10-01 07:38:03 +0000
committerJeff Law <law@redhat.com>1995-10-01 07:38:03 +0000
commit709af562b8a817b2bb11abb117f8ae67b9cb5b5f (patch)
tree375ce091da2b2815f5648ff31b6f51a01986599d /bfd/som.c
parent130f53ae7adb5a5488a0003ff4503c97b836b473 (diff)
downloadgdb-709af562b8a817b2bb11abb117f8ae67b9cb5b5f.zip
gdb-709af562b8a817b2bb11abb117f8ae67b9cb5b5f.tar.gz
gdb-709af562b8a817b2bb11abb117f8ae67b9cb5b5f.tar.bz2
* som.c (som_begin_writing): Don't write the symbol table or
symbol strings. (som_finish_writing): Write them here. Place them after the subspace data, but before the relocs. Works around a truely stupid bug in the hpux8/hpux9 linker. Fixes all known link-time problems with -mlinker-opt.
Diffstat (limited to 'bfd/som.c')
-rw-r--r--bfd/som.c85
1 files changed, 47 insertions, 38 deletions
diff --git a/bfd/som.c b/bfd/som.c
index 2587b84..3aa44c1 100644
--- a/bfd/som.c
+++ b/bfd/som.c
@@ -2987,9 +2987,8 @@ som_begin_writing (abfd)
unsigned long current_offset = 0;
int strings_size = 0;
unsigned int total_reloc_size = 0;
- unsigned long num_spaces, num_subspaces, num_syms, i;
+ unsigned long num_spaces, num_subspaces, i;
asection *section;
- asymbol **syms = bfd_get_outsymbols (abfd);
unsigned int total_subspaces = 0;
struct som_exec_auxhdr *exec_header = NULL;
@@ -3121,37 +3120,6 @@ som_begin_writing (abfd)
obj_som_file_hdr (abfd)->space_strings_size = strings_size;
current_offset += strings_size;
- /* Next is the symbol table. These are fixed length records.
-
- Count the number of symbols to determine how much room is needed
- in the object file for the symbol table.
-
- The names of the symbols are stored in a separate string table,
- and the index for each symbol name into the string table is computed
- below. Therefore, it is not possible to write the symobl table
- at this time. */
- num_syms = bfd_get_symcount (abfd);
- obj_som_file_hdr (abfd)->symbol_location = current_offset;
- obj_som_file_hdr (abfd)->symbol_total = num_syms;
- current_offset += num_syms * sizeof (struct symbol_dictionary_record);
-
- /* Next are the symbol strings.
- Align them to a word boundary. */
- if (current_offset % 4)
- current_offset += (4 - (current_offset % 4));
- obj_som_file_hdr (abfd)->symbol_strings_location = current_offset;
-
- /* Scribble out the symbol strings. */
- if (som_write_symbol_strings (abfd, current_offset, syms,
- num_syms, &strings_size)
- == false)
- return false;
-
- /* Record total string table size in header and update the
- current offset. */
- obj_som_file_hdr (abfd)->symbol_strings_size = strings_size;
- current_offset += strings_size;
-
/* Next is the compiler records. We do not use these. */
obj_som_file_hdr (abfd)->compiler_location = current_offset;
obj_som_file_hdr (abfd)->compiler_total = 0;
@@ -3362,20 +3330,60 @@ som_finish_writing (abfd)
bfd *abfd;
{
int num_spaces = som_count_spaces (abfd);
- int i;
+ asymbol **syms = bfd_get_outsymbols (abfd);
+ int i, num_syms, strings_size;
int subspace_index = 0;
file_ptr location;
asection *section;
unsigned long current_offset;
unsigned int total_reloc_size;
+ /* Next is the symbol table. These are fixed length records.
+
+ Count the number of symbols to determine how much room is needed
+ in the object file for the symbol table.
+
+ The names of the symbols are stored in a separate string table,
+ and the index for each symbol name into the string table is computed
+ below. Therefore, it is not possible to write the symbol table
+ at this time.
+
+ These used to be output before the subspace contents, but they
+ were moved here to work around a stupid bug in the hpux linker
+ (fixed in hpux10). */
+ current_offset = obj_som_file_hdr (abfd)->som_length;
+
+ /* Make sure we're on a word boundary. */
+ if (current_offset % 4)
+ current_offset += (4 - (current_offset % 4));
+
+ num_syms = bfd_get_symcount (abfd);
+ obj_som_file_hdr (abfd)->symbol_location = current_offset;
+ obj_som_file_hdr (abfd)->symbol_total = num_syms;
+ current_offset += num_syms * sizeof (struct symbol_dictionary_record);
+
+ /* Next are the symbol strings.
+ Align them to a word boundary. */
+ if (current_offset % 4)
+ current_offset += (4 - (current_offset % 4));
+ obj_som_file_hdr (abfd)->symbol_strings_location = current_offset;
+
+ /* Scribble out the symbol strings. */
+ if (som_write_symbol_strings (abfd, current_offset, syms,
+ num_syms, &strings_size)
+ == false)
+ return false;
+
+ /* Record total string table size in header and update the
+ current offset. */
+ obj_som_file_hdr (abfd)->symbol_strings_size = strings_size;
+ current_offset += strings_size;
+
/* Do prep work before handling fixups. */
som_prep_for_fixups (abfd,
bfd_get_outsymbols (abfd),
bfd_get_symcount (abfd));
- current_offset = obj_som_file_hdr (abfd)->som_length;
-
/* At the end of the file is the fixup stream which starts on a
word boundary. */
if (current_offset % 4)
@@ -3390,7 +3398,8 @@ som_finish_writing (abfd)
/* Record the total size of the fixup stream in the file header. */
obj_som_file_hdr (abfd)->fixup_request_total = total_reloc_size;
- obj_som_file_hdr (abfd)->som_length += total_reloc_size;
+ /* Done. Store the total size of the SOM. */
+ obj_som_file_hdr (abfd)->som_length = current_offset + total_reloc_size;
/* Now that the symbol table information is complete, build and
write the symbol table. */
@@ -4976,7 +4985,7 @@ som_sizeof_headers (abfd, reloc)
bfd *abfd;
boolean reloc;
{
- fprintf (stderr, "som_sizeof_headers unimplemented\n");
+ (*_bfd_error_handler) ("som_sizeof_headers unimplemented");
fflush (stderr);
abort ();
return (0);