PC relative segment relocations don't need to be looked at at run-time (such

relocations occur on the ns32k).
Dump <strings.h> from header files.
This commit is contained in:
pk 1994-04-07 19:41:17 +00:00
parent bbcbd9ca18
commit 12f28a9ba6
8 changed files with 68 additions and 90 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ld.h,v 1.8 1994/01/28 20:56:24 pk Exp $ * $Id: ld.h,v 1.9 1994/04/07 19:41:21 pk Exp $
*/ */
/*- /*-
* This code is derived from software copyrighted by the Free Software * This code is derived from software copyrighted by the Free Software
@ -31,6 +31,10 @@
#define alloca __builtin_alloca #define alloca __builtin_alloca
#endif #endif
#ifdef __FreeBSD__
#define FreeBSD
#endif
#include "md.h" #include "md.h"
#include "link.h" #include "link.h"
@ -53,6 +57,7 @@ char *progname;
#ifndef DEFAULT_MAGIC #ifndef DEFAULT_MAGIC
#ifdef FreeBSD #ifdef FreeBSD
#define DEFAULT_MAGIC QMAGIC #define DEFAULT_MAGIC QMAGIC
extern int netzmagic;
#else #else
#define DEFAULT_MAGIC ZMAGIC #define DEFAULT_MAGIC ZMAGIC
#endif #endif

View File

@ -32,27 +32,27 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
Set, indirect, and warning symbol features added by Randy Smith. */ Set, indirect, and warning symbol features added by Randy Smith. */
/* /*
* $Id: ld.c,v 1.21 1994/03/31 14:17:29 pk Exp $ * $Id: ld.c,v 1.22 1994/04/07 19:41:17 pk Exp $
*/ */
/* Define how to initialize system-dependent header fields. */ /* Define how to initialize system-dependent header fields. */
#include <sys/param.h> #include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <ar.h> #include <ar.h>
#include <ranlib.h> #include <ranlib.h>
#include <a.out.h> #include <a.out.h>
#include <stab.h> #include <stab.h>
#include <string.h>
#include <strings.h>
#include "ld.h" #include "ld.h"
@ -116,7 +116,7 @@ int rrs_data_start; /* Location of above */
int set_sect_start; /* start of set element vectors */ int set_sect_start; /* start of set element vectors */
int set_sect_size; /* size of above */ int set_sect_size; /* size of above */
int link_mode; /* Current link mode */ int link_mode; /* Current link mode */
/* /*
* When loading the text and data, we can avoid doing a close * When loading the text and data, we can avoid doing a close
@ -138,14 +138,16 @@ int magic; /* Output file magic. */
int oldmagic; int oldmagic;
int relocatable_output; /* `-r'-ed output */ int relocatable_output; /* `-r'-ed output */
symbol *entry_symbol; symbol *entry_symbol; /* specified by `-e' */
int entry_offset; int entry_offset; /* program entry if no `-e' given */
int page_size; /* Size of a page (machine dependent) */ int page_size; /* Size of a page (machine dependent) */
/* Keep a list of any symbols referenced from the command line (so /*
that error messages for these guys can be generated). This list is * Keep a list of any symbols referenced from the command line (so
zero terminated. */ * that error messages for these guys can be generated). This list is
* zero terminated.
*/
struct glosym **cmdline_references; struct glosym **cmdline_references;
int cl_refs_allocated; int cl_refs_allocated;
@ -756,10 +758,16 @@ decode_option(swt, arg)
case 'z': case 'z':
magic = ZMAGIC; magic = ZMAGIC;
oldmagic = 0; oldmagic = 0;
#ifdef FreeBSD
netzmagic = 1;
#endif
return; return;
case 'Z': case 'Z':
magic = oldmagic = ZMAGIC; magic = oldmagic = ZMAGIC;
#ifdef FreeBSD
netzmagic = 0;
#endif
return; return;
default: default:
@ -1935,7 +1943,7 @@ consider_relocation (entry, dataseg)
* Prepare an RRS relocation as these are load * Prepare an RRS relocation as these are load
* address dependent. * address dependent.
*/ */
if (building_shared_object) { if (building_shared_object && !RELOC_PCREL_P(reloc)) {
alloc_rrs_segment_reloc(entry, reloc); alloc_rrs_segment_reloc(entry, reloc);
} }
} }
@ -2624,32 +2632,17 @@ perform_relocation(data, data_size, reloc, nreloc, entry, dataseg)
* run-time. The r_address field is updated * run-time. The r_address field is updated
* to reflect the changed position in the * to reflect the changed position in the
* output file. * output file.
*
* In case the symbol is defined in a shared
* object as N_TEXT or N_DATA, an appropriate
* jmpslot or copy relocation is generated.
*/ */
switch (sp->so_defined) { if (sp->jmpslot_offset != -1) {
case N_TEXT+N_EXT:
/* /*
* Claim a jmpslot if one was * Claim a jmpslot if one was
* allocated (dependent on * allocated (dependent on
* `force_alias_flag'). * `force_alias_flag').
*/ */
if (sp->jmpslot_offset == -1)
goto undefined;
relocation = addend + relocation = addend +
claim_rrs_jmpslot(entry, r, claim_rrs_jmpslot(entry, r,
sp, addend); sp, addend);
break; } else {
case N_DATA+N_EXT:
/*FALLTHROUGH*/
case 0:
undefined:
r->r_address += dataseg? r->r_address += dataseg?
entry->data_start_address: entry->data_start_address:
entry->text_start_address; entry->text_start_address;
@ -2657,15 +2650,6 @@ perform_relocation(data, data_size, reloc, nreloc, entry, dataseg)
if (claim_rrs_reloc(entry, r, if (claim_rrs_reloc(entry, r,
sp, &relocation)) sp, &relocation))
continue; continue;
break;
case N_BSS+N_EXT:
printf("%s: BSS found in so_defined\n", sp->name);
/*break;*/
default:
fatal("%s: shobj symbol with unknown type %#x", sp->name, sp->so_defined);
break;
} }
} }
@ -2717,7 +2701,7 @@ printf("%s: BSS found in so_defined\n", sp->name);
* relocations need a "load address relative" * relocations need a "load address relative"
* RRS fixup. * RRS fixup.
*/ */
if (building_shared_object) { if (building_shared_object && !RELOC_PCREL_P(r)) {
r->r_address += dataseg? r->r_address += dataseg?
entry->data_start_address: entry->data_start_address:
entry->text_start_address; entry->text_start_address;
@ -3391,7 +3375,7 @@ mywrite (buf, count, eltsize, desc)
while (bytes > 0) { while (bytes > 0) {
val = write (desc, buf, bytes); val = write (desc, buf, bytes);
if (val <= 0) if (val <= 0)
perror(output_filename); fatal("%s: %s", output_filename, strerror(errno));
buf += val; buf += val;
bytes -= val; bytes -= val;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ld.h,v 1.8 1994/01/28 20:56:24 pk Exp $ * $Id: ld.h,v 1.9 1994/04/07 19:41:21 pk Exp $
*/ */
/*- /*-
* This code is derived from software copyrighted by the Free Software * This code is derived from software copyrighted by the Free Software
@ -31,6 +31,10 @@
#define alloca __builtin_alloca #define alloca __builtin_alloca
#endif #endif
#ifdef __FreeBSD__
#define FreeBSD
#endif
#include "md.h" #include "md.h"
#include "link.h" #include "link.h"
@ -53,6 +57,7 @@ char *progname;
#ifndef DEFAULT_MAGIC #ifndef DEFAULT_MAGIC
#ifdef FreeBSD #ifdef FreeBSD
#define DEFAULT_MAGIC QMAGIC #define DEFAULT_MAGIC QMAGIC
extern int netzmagic;
#else #else
#define DEFAULT_MAGIC ZMAGIC #define DEFAULT_MAGIC ZMAGIC
#endif #endif

View File

@ -32,27 +32,27 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91";
Set, indirect, and warning symbol features added by Randy Smith. */ Set, indirect, and warning symbol features added by Randy Smith. */
/* /*
* $Id: ld.c,v 1.21 1994/03/31 14:17:29 pk Exp $ * $Id: ld.c,v 1.22 1994/04/07 19:41:17 pk Exp $
*/ */
/* Define how to initialize system-dependent header fields. */ /* Define how to initialize system-dependent header fields. */
#include <sys/param.h> #include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <ar.h> #include <ar.h>
#include <ranlib.h> #include <ranlib.h>
#include <a.out.h> #include <a.out.h>
#include <stab.h> #include <stab.h>
#include <string.h>
#include <strings.h>
#include "ld.h" #include "ld.h"
@ -116,7 +116,7 @@ int rrs_data_start; /* Location of above */
int set_sect_start; /* start of set element vectors */ int set_sect_start; /* start of set element vectors */
int set_sect_size; /* size of above */ int set_sect_size; /* size of above */
int link_mode; /* Current link mode */ int link_mode; /* Current link mode */
/* /*
* When loading the text and data, we can avoid doing a close * When loading the text and data, we can avoid doing a close
@ -138,14 +138,16 @@ int magic; /* Output file magic. */
int oldmagic; int oldmagic;
int relocatable_output; /* `-r'-ed output */ int relocatable_output; /* `-r'-ed output */
symbol *entry_symbol; symbol *entry_symbol; /* specified by `-e' */
int entry_offset; int entry_offset; /* program entry if no `-e' given */
int page_size; /* Size of a page (machine dependent) */ int page_size; /* Size of a page (machine dependent) */
/* Keep a list of any symbols referenced from the command line (so /*
that error messages for these guys can be generated). This list is * Keep a list of any symbols referenced from the command line (so
zero terminated. */ * that error messages for these guys can be generated). This list is
* zero terminated.
*/
struct glosym **cmdline_references; struct glosym **cmdline_references;
int cl_refs_allocated; int cl_refs_allocated;
@ -756,10 +758,16 @@ decode_option(swt, arg)
case 'z': case 'z':
magic = ZMAGIC; magic = ZMAGIC;
oldmagic = 0; oldmagic = 0;
#ifdef FreeBSD
netzmagic = 1;
#endif
return; return;
case 'Z': case 'Z':
magic = oldmagic = ZMAGIC; magic = oldmagic = ZMAGIC;
#ifdef FreeBSD
netzmagic = 0;
#endif
return; return;
default: default:
@ -1935,7 +1943,7 @@ consider_relocation (entry, dataseg)
* Prepare an RRS relocation as these are load * Prepare an RRS relocation as these are load
* address dependent. * address dependent.
*/ */
if (building_shared_object) { if (building_shared_object && !RELOC_PCREL_P(reloc)) {
alloc_rrs_segment_reloc(entry, reloc); alloc_rrs_segment_reloc(entry, reloc);
} }
} }
@ -2624,32 +2632,17 @@ perform_relocation(data, data_size, reloc, nreloc, entry, dataseg)
* run-time. The r_address field is updated * run-time. The r_address field is updated
* to reflect the changed position in the * to reflect the changed position in the
* output file. * output file.
*
* In case the symbol is defined in a shared
* object as N_TEXT or N_DATA, an appropriate
* jmpslot or copy relocation is generated.
*/ */
switch (sp->so_defined) { if (sp->jmpslot_offset != -1) {
case N_TEXT+N_EXT:
/* /*
* Claim a jmpslot if one was * Claim a jmpslot if one was
* allocated (dependent on * allocated (dependent on
* `force_alias_flag'). * `force_alias_flag').
*/ */
if (sp->jmpslot_offset == -1)
goto undefined;
relocation = addend + relocation = addend +
claim_rrs_jmpslot(entry, r, claim_rrs_jmpslot(entry, r,
sp, addend); sp, addend);
break; } else {
case N_DATA+N_EXT:
/*FALLTHROUGH*/
case 0:
undefined:
r->r_address += dataseg? r->r_address += dataseg?
entry->data_start_address: entry->data_start_address:
entry->text_start_address; entry->text_start_address;
@ -2657,15 +2650,6 @@ perform_relocation(data, data_size, reloc, nreloc, entry, dataseg)
if (claim_rrs_reloc(entry, r, if (claim_rrs_reloc(entry, r,
sp, &relocation)) sp, &relocation))
continue; continue;
break;
case N_BSS+N_EXT:
printf("%s: BSS found in so_defined\n", sp->name);
/*break;*/
default:
fatal("%s: shobj symbol with unknown type %#x", sp->name, sp->so_defined);
break;
} }
} }
@ -2717,7 +2701,7 @@ printf("%s: BSS found in so_defined\n", sp->name);
* relocations need a "load address relative" * relocations need a "load address relative"
* RRS fixup. * RRS fixup.
*/ */
if (building_shared_object) { if (building_shared_object && !RELOC_PCREL_P(r)) {
r->r_address += dataseg? r->r_address += dataseg?
entry->data_start_address: entry->data_start_address:
entry->text_start_address; entry->text_start_address;
@ -3391,7 +3375,7 @@ mywrite (buf, count, eltsize, desc)
while (bytes > 0) { while (bytes > 0) {
val = write (desc, buf, bytes); val = write (desc, buf, bytes);
if (val <= 0) if (val <= 0)
perror(output_filename); fatal("%s: %s", output_filename, strerror(errno));
buf += val; buf += val;
bytes -= val; bytes -= val;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lib.c,v 1.11 1994/04/03 18:38:02 pk Exp $ - library routines * $Id: lib.c,v 1.12 1994/04/07 19:41:22 pk Exp $ - library routines
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -17,6 +17,7 @@
#include <stab.h> #include <stab.h>
#include <string.h> #include <string.h>
#include <dirent.h> #include <dirent.h>
#include <ctype.h>
#include "ld.h" #include "ld.h"

View File

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: rrs.c,v 1.10 1994/03/31 14:17:39 pk Exp $ * $Id: rrs.c,v 1.11 1994/04/07 19:41:23 pk Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -45,7 +45,6 @@
#include <a.out.h> #include <a.out.h>
#include <stab.h> #include <stab.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include "ld.h" #include "ld.h"

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lib.c,v 1.11 1994/04/03 18:38:02 pk Exp $ - library routines * $Id: lib.c,v 1.12 1994/04/07 19:41:22 pk Exp $ - library routines
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -17,6 +17,7 @@
#include <stab.h> #include <stab.h>
#include <string.h> #include <string.h>
#include <dirent.h> #include <dirent.h>
#include <ctype.h>
#include "ld.h" #include "ld.h"

View File

@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: rrs.c,v 1.10 1994/03/31 14:17:39 pk Exp $ * $Id: rrs.c,v 1.11 1994/04/07 19:41:23 pk Exp $
*/ */
#include <sys/param.h> #include <sys/param.h>
@ -45,7 +45,6 @@
#include <a.out.h> #include <a.out.h>
#include <stab.h> #include <stab.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include "ld.h" #include "ld.h"