summaryrefslogtreecommitdiff
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>1999-05-24 23:22:03 +0000
committerMarc Espie <espie@cvs.openbsd.org>1999-05-24 23:22:03 +0000
commit171a683b4e3efc156c28e1be57ec85921249d939 (patch)
tree1d7f444c7d0152e1c01f6f9eb2263f72c564860f /gnu/usr.bin
parent8337fe0f9b1f07061deb94b937c2bc9ef840c067 (diff)
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.
Diffstat (limited to 'gnu/usr.bin')
-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)