From: Ian Lance Taylor Date: Tue, 23 Jan 1996 19:26:01 +0000 (+0000) Subject: * coffcode.h (coff_set_section_contents): Fix the handling of the X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5eb83edeab1c240df741cb3eb5c3533ae12e482d;p=binutils-gdb.git * 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 and Robert Lipe . --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 5b992124398..66953c0d463 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +Tue Jan 23 14:22:45 1996 Ian Lance Taylor + + * 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 and + Robert Lipe . + Mon Jan 22 18:45:51 1996 Michael Meissner * elflink.h (elf_finish_pointer_linker_section): Don't allocate diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 069acda5b67..152846fa892 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 . */ - 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 + (Thanks!). + + Gvran Uddeborg */ + + 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