aboutsummaryrefslogtreecommitdiff
path: root/bfd/coffcode.h
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 /bfd/coffcode.h
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>.
Diffstat (limited to 'bfd/coffcode.h')
-rw-r--r--bfd/coffcode.h44
1 files changed, 38 insertions, 6 deletions
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