aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-01-23 19:26:01 +0000
committerIan Lance Taylor <ian@airs.com>1996-01-23 19:26:01 +0000
commit5eb83edeab1c240df741cb3eb5c3533ae12e482d (patch)
tree46631aaf37ac419d6b57995f250dee44858a0103
parent38aa863c90c26886ddf0de41ef634c4a2ceef8e5 (diff)
downloadgdb-5eb83edeab1c240df741cb3eb5c3533ae12e482d.zip
gdb-5eb83edeab1c240df741cb3eb5c3533ae12e482d.tar.gz
gdb-5eb83edeab1c240df741cb3eb5c3533ae12e482d.tar.bz2
* coffcode.h (coff_set_section_contents): Fix the handling of the
.lib section to work even if the entire section contents are written at once. From Gvran Uddeborg <gvran@uddeborg.pp.se> and Robert Lipe <robertl@arnet.com>.
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/coffcode.h44
2 files changed, 45 insertions, 6 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5b99212..66953c0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+Tue Jan 23 14:22:45 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * coffcode.h (coff_set_section_contents): Fix the handling of the
+ .lib section to work even if the entire section contents are
+ written at once. From Gvran Uddeborg <gvran@uddeborg.pp.se> and
+ Robert Lipe <robertl@arnet.com>.
+
Mon Jan 22 18:45:51 1996 Michael Meissner <meissner@tiktok.cygnus.com>
* elflink.h (elf_finish_pointer_linker_section): Don't allocate
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 069acda..152846f 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -2682,12 +2682,44 @@ coff_set_section_contents (abfd, section, location, offset, count)
coff_compute_section_file_positions (abfd);
#ifdef _LIB
- /* If this is a .lib section, bump the vma address so that it
- winds up being the number of .lib sections output. This is
- right for SVR3.2. Shared libraries should probably get more
- generic support. Ian Taylor <ian@cygnus.com>. */
- if (strcmp (section->name, _LIB) == 0)
- ++section->lma;
+
+ /* The physical address field of a .lib section is used to hold the
+ number of shared libraries in the section. This code counts the
+ number of sections being written, and increments the lma field
+ with the number.
+
+ I have found no documentation on the contents of this section.
+ Experimentation indicates that the section contains zero or more
+ records, each of which has the following structure:
+
+ - a (four byte) word holding the length of this record, in words,
+ - a word that always seems to be set to "2",
+ - the path to a shared library, null-terminated and then padded
+ to a whole word boundary.
+
+ bfd_assert calls have been added to alert if an attempt is made
+ to write a section which doesn't follow these assumptions. The
+ code has been tested on ISC 4.1 by me, and on SCO by Robert Lipe
+ <robertl@arnet.com> (Thanks!).
+
+ Gvran Uddeborg <gvran@uddeborg.pp.se> */
+
+ if (strcmp (section->name, _LIB) == 0)
+ {
+ bfd_byte *rec, *recend;
+
+ rec = (bfd_byte *) location;
+ recend = rec + count;
+ while (rec < recend)
+ {
+ BFD_ASSERT (bfd_get_32 (abfd, rec + 4) == 2);
+ ++section->lma;
+ rec += bfd_get_32 (abfd, rec) / 4;
+ }
+
+ BFD_ASSERT (rec == recend);
+ }
+
#endif
/* Don't write out bss sections - one way to do this is to