summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>1999-05-24 23:22:01 +0000
committerespie <espie@openbsd.org>1999-05-24 23:22:01 +0000
commit8b65874a69382a5552124a8a146bb226be32a36f (patch)
treef1faa1aca8d1f2dcd654af407516f4f106b2c0e4
parentOnly do basic work in the ethernet interrupt context, and queue packets to (diff)
downloadwireguard-openbsd-8b65874a69382a5552124a8a146bb226be32a36f.tar.xz
wireguard-openbsd-8b65874a69382a5552124a8a146bb226be32a36f.zip
This patch lets sparc ld handle pic/PIC relocations mix, by simply forcing
everything to fit into pic mode. More extensive changes (like tagging relocs with pic/PIC, sorting, and putting pic nearest the beginning of the GOT) would be needed for full handling pic relocs with a sizeable number of PIC relocs.
-rw-r--r--gnu/usr.bin/ld/ld.c25
-rw-r--r--gnu/usr.bin/ld/sparc/md.h3
2 files changed, 26 insertions, 2 deletions
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c
index 5f8d78142c5..4ee1d71ac31 100644
--- a/gnu/usr.bin/ld/ld.c
+++ b/gnu/usr.bin/ld/ld.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ld.c,v 1.11 1998/11/25 16:39:38 kstailey Exp $ */
+/* $OpenBSD: ld.c,v 1.12 1999/05/24 23:22:01 espie Exp $ */
/* $NetBSD: ld.c,v 1.52 1998/02/20 03:12:51 jonathan Exp $ */
/*-
@@ -2096,6 +2096,9 @@ consider_relocation(entry, dataseg)
struct relocation_info *reloc, *end;
struct localsymbol *lsp;
symbol *sp;
+#ifdef ALLOW_SPARC_MIX
+ static int locked_pic_small = 0;
+#endif
if (dataseg == 0) {
/* Text relocations */
@@ -2161,11 +2164,31 @@ consider_relocation(entry, dataseg)
lsp = &entry->symbols[reloc->r_symbolnum];
alloc_rrs_gotslot(entry, reloc, lsp);
+/* sparc assembler instructions sometimes hold RELOC_22/RELOC_11,
+ even when using the small -fpic model. This should not yield
+ an error though. The linker is still thoroughly unsubtle about it
+ and constrains everything to +/-4096 of the GOT
+ */
+#ifdef ALLOW_SPARC_MIX
+ if (!locked_pic_small) {
+ if (pic_type != PIC_TYPE_NONE &&
+ RELOC_PIC_TYPE(reloc) != pic_type) {
+ warnx("%s: reloc type mix, enforcing pic model",
+ get_file_name(entry));
+ pic_type = PIC_TYPE_SMALL;
+ locked_pic_small = 1;
+ }
+ else
+ pic_type = RELOC_PIC_TYPE(reloc);
+ }
+#else
+ pic_type = RELOC_PIC_TYPE(reloc);
if (pic_type != PIC_TYPE_NONE &&
RELOC_PIC_TYPE(reloc) != pic_type)
errx(1, "%s: illegal reloc type mix",
get_file_name(entry));
pic_type = RELOC_PIC_TYPE(reloc);
+#endif
} else if (RELOC_EXTERN_P(reloc)) {
diff --git a/gnu/usr.bin/ld/sparc/md.h b/gnu/usr.bin/ld/sparc/md.h
index 5753033876a..ee109673d55 100644
--- a/gnu/usr.bin/ld/sparc/md.h
+++ b/gnu/usr.bin/ld/sparc/md.h
@@ -1,4 +1,4 @@
-/* * $OpenBSD: md.h,v 1.4 1999/05/10 16:20:47 espie Exp $*/
+/* * $OpenBSD: md.h,v 1.5 1999/05/24 23:22:02 espie Exp $*/
/*
* Copyright (c) 1993 Paul Kranenburg
* All rights reserved.
@@ -127,6 +127,7 @@
PIC_TYPE_SMALL : \
PIC_TYPE_NONE) )
+#define ALLOW_SPARC_MIX
#define CHECK_GOT_RELOC(r) \
((r)->r_type == RELOC_PC10 || (r)->r_type == RELOC_PC22)