Add Symbols.map to explicitly define the ABIs, hiding linker defined symbols.
authorguenther <guenther@openbsd.org>
Thu, 14 Dec 2017 17:06:33 +0000 (17:06 +0000)
committerguenther <guenther@openbsd.org>
Thu, 14 Dec 2017 17:06:33 +0000 (17:06 +0000)
Use hidden aliases for internal invocations of exported symbols to avoid PLT.

ok deraadt@ kettenis@ jca@

lib/libkvm/Makefile
lib/libkvm/Symbols.map [new file with mode: 0644]
lib/libkvm/kvm.c
lib/libkvm/kvm_private.h
lib/libkvm/shlib_version

index 7284c60..6009836 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile,v 1.18 2016/03/30 06:38:42 jmc Exp $
+#      $OpenBSD: Makefile,v 1.19 2017/12/14 17:06:33 guenther Exp $
 #      $NetBSD: Makefile,v 1.11 1996/03/18 22:33:07 thorpej Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/4/93
 
@@ -18,6 +18,8 @@ SRCS= kvm_${MACHINE_CPU}.c
 .endif
 .endif
 
+VERSION_SCRIPT=        ${.CURDIR}/Symbols.map
+
 CFLAGS+= -D_LIBKVM
 SRCS+= kvm.c kvm_file2.c kvm_getloadavg.c kvm_proc.c kvm_proc2.c \
        kvm_cd9660.c kvm_udf.c kvm_ntfs.c
diff --git a/lib/libkvm/Symbols.map b/lib/libkvm/Symbols.map
new file mode 100644 (file)
index 0000000..76cf4f2
--- /dev/null
@@ -0,0 +1,21 @@
+{
+       global:
+               kvm_close;
+               kvm_dump_inval;
+               kvm_dump_mkheader;
+               kvm_dump_wrtheader;
+               kvm_getargv;
+               kvm_getenvv;
+               kvm_geterr;
+               kvm_getfiles;
+               kvm_getloadavg;
+               kvm_getprocs;
+               kvm_nlist;
+               kvm_open;
+               kvm_openfiles;
+               kvm_read;
+               kvm_write;
+
+       local:
+               *;
+};
index 5247cff..dce4359 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kvm.c,v 1.62 2016/07/10 23:06:48 tedu Exp $ */
+/*     $OpenBSD: kvm.c,v 1.63 2017/12/14 17:06:33 guenther Exp $ */
 /*     $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $     */
 
 /*-
@@ -664,6 +664,7 @@ kvm_close(kvm_t *kd)
 
        return (error);
 }
+DEF(kvm_close);
 
 /*
  * Set up state necessary to do queries on the kernel namelist
@@ -802,6 +803,7 @@ kvm_nlist(kvm_t *kd, struct nlist *nl)
         */
        return ((p - nl) - nvalid);
 }
+DEF(kvm_nlist);
 
 int
 kvm_dump_inval(kvm_t *kd)
@@ -894,6 +896,7 @@ kvm_read(kvm_t *kd, u_long kva, void *buf, size_t len)
        }
        /* NOTREACHED */
 }
+DEF(kvm_read);
 
 ssize_t
 kvm_write(kvm_t *kd, u_long kva, const void *buf, size_t len)
index b42634b..3fe186e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kvm_private.h,v 1.24 2015/09/04 02:55:09 dlg Exp $ */
+/*     $OpenBSD: kvm_private.h,v 1.25 2017/12/14 17:06:33 guenther Exp $ */
 /*     $NetBSD: kvm_private.h,v 1.7 1996/05/05 04:32:15 gwr Exp $      */
 
 /*-
@@ -106,3 +106,11 @@ void        _kvm_syserr(kvm_t *kd, const char *program, const char *fmt, ...)
 ssize_t         _kvm_pread(kvm_t *, int, void *, size_t, off_t);
 ssize_t         _kvm_pwrite(kvm_t *, int, const void *, size_t, off_t);
 __END_HIDDEN_DECLS
+
+
+#define        PROTO(x)        __dso_hidden typeof(x) x asm("__"#x)
+#define        DEF(x)          __strong_alias(x, __##x)
+
+PROTO(kvm_close);
+PROTO(kvm_nlist);
+PROTO(kvm_read);
index cd2907e..ffdd3d2 100644 (file)
@@ -1,2 +1,2 @@
-major=16
-minor=2
+major=17
+minor=0