Sun Nov 8 00:57:09 2015 UTC ()
Pull up following revision(s) (requested by christos in ticket #1019):
	sys/kern/exec_elf.c: revision 1.79
	sys/sys/exec_elf.h: revision 1.150
	sys/sys/exec_elf.h: revision 1.151
	sys/kern/exec_elf.c: revision 1.80
Ignore the ancient 01.01 tag that gnuc used to put in old NetBSD binaries.
Add buildid Go note


(riz)
diff -r1.69.2.2 -r1.69.2.3 src/sys/kern/exec_elf.c
diff -r1.141 -r1.141.2.1 src/sys/sys/exec_elf.h

cvs diff -r1.69.2.2 -r1.69.2.3 src/sys/kern/exec_elf.c (expand / switch to unified diff)

--- src/sys/kern/exec_elf.c 2015/03/29 09:07:55 1.69.2.2
+++ src/sys/kern/exec_elf.c 2015/11/08 00:57:09 1.69.2.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: exec_elf.c,v 1.69.2.2 2015/03/29 09:07:55 martin Exp $ */ 1/* $NetBSD: exec_elf.c,v 1.69.2.3 2015/11/08 00:57:09 riz Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc. 4 * Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 47 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 48 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 49 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 50 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 51 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 52 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 53 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 54 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
56 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 56 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 */ 57 */
58 58
59#include <sys/cdefs.h> 59#include <sys/cdefs.h>
60__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.69.2.2 2015/03/29 09:07:55 martin Exp $"); 60__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.69.2.3 2015/11/08 00:57:09 riz Exp $");
61 61
62#ifdef _KERNEL_OPT 62#ifdef _KERNEL_OPT
63#include "opt_pax.h" 63#include "opt_pax.h"
64#endif /* _KERNEL_OPT */ 64#endif /* _KERNEL_OPT */
65 65
66#include <sys/param.h> 66#include <sys/param.h>
67#include <sys/proc.h> 67#include <sys/proc.h>
68#include <sys/kmem.h> 68#include <sys/kmem.h>
69#include <sys/namei.h> 69#include <sys/namei.h>
70#include <sys/vnode.h> 70#include <sys/vnode.h>
71#include <sys/exec.h> 71#include <sys/exec.h>
72#include <sys/exec_elf.h> 72#include <sys/exec_elf.h>
73#include <sys/syscall.h> 73#include <sys/syscall.h>
@@ -929,33 +929,40 @@ netbsd_elf_signature(struct lwp *l, stru @@ -929,33 +929,40 @@ netbsd_elf_signature(struct lwp *l, stru
929 case ELF_NOTE_TYPE_NETBSD_TAG: 929 case ELF_NOTE_TYPE_NETBSD_TAG:
930 /* It is us */ 930 /* It is us */
931 if (np->n_namesz == ELF_NOTE_NETBSD_NAMESZ && 931 if (np->n_namesz == ELF_NOTE_NETBSD_NAMESZ &&
932 np->n_descsz == ELF_NOTE_NETBSD_DESCSZ && 932 np->n_descsz == ELF_NOTE_NETBSD_DESCSZ &&
933 memcmp(ndata, ELF_NOTE_NETBSD_NAME, 933 memcmp(ndata, ELF_NOTE_NETBSD_NAME,
934 ELF_NOTE_NETBSD_NAMESZ) == 0) { 934 ELF_NOTE_NETBSD_NAMESZ) == 0) {
935 memcpy(&epp->ep_osversion, ndesc, 935 memcpy(&epp->ep_osversion, ndesc,
936 ELF_NOTE_NETBSD_DESCSZ); 936 ELF_NOTE_NETBSD_DESCSZ);
937 isnetbsd = 1; 937 isnetbsd = 1;
938 break; 938 break;
939 } 939 }
940 940
941 /* 941 /*
942 * Ignore SuSE tags; SuSE's n_type is the same as NetBSD's 942 * Ignore SuSE tags; SuSE's n_type is the same the
943 * one. 943 * NetBSD one.
944 */ 944 */
945 if (np->n_namesz == ELF_NOTE_SUSE_NAMESZ && 945 if (np->n_namesz == ELF_NOTE_SUSE_NAMESZ &&
946 memcmp(ndata, ELF_NOTE_SUSE_NAME, 946 memcmp(ndata, ELF_NOTE_SUSE_NAME,
947 ELF_NOTE_SUSE_NAMESZ) == 0) 947 ELF_NOTE_SUSE_NAMESZ) == 0)
948 break; 948 break;
 949 /*
 950 * Ignore old GCC
 951 */
 952 if (np->n_namesz == ELF_NOTE_OGCC_NAMESZ &&
 953 memcmp(ndata, ELF_NOTE_OGCC_NAME,
 954 ELF_NOTE_OGCC_NAMESZ) == 0)
 955 break;
949 BADNOTE("NetBSD tag"); 956 BADNOTE("NetBSD tag");
950 goto bad; 957 goto bad;
951 958
952 case ELF_NOTE_TYPE_PAX_TAG: 959 case ELF_NOTE_TYPE_PAX_TAG:
953 if (np->n_namesz == ELF_NOTE_PAX_NAMESZ && 960 if (np->n_namesz == ELF_NOTE_PAX_NAMESZ &&
954 np->n_descsz == ELF_NOTE_PAX_DESCSZ && 961 np->n_descsz == ELF_NOTE_PAX_DESCSZ &&
955 memcmp(ndata, ELF_NOTE_PAX_NAME, 962 memcmp(ndata, ELF_NOTE_PAX_NAME,
956 ELF_NOTE_PAX_NAMESZ) == 0) { 963 ELF_NOTE_PAX_NAMESZ) == 0) {
957 memcpy(&epp->ep_pax_flags, ndesc, 964 memcpy(&epp->ep_pax_flags, ndesc,
958 sizeof(epp->ep_pax_flags)); 965 sizeof(epp->ep_pax_flags));
959 break; 966 break;
960 } 967 }
961 BADNOTE("PaX tag"); 968 BADNOTE("PaX tag");
@@ -994,26 +1001,29 @@ netbsd_elf_signature(struct lwp *l, stru @@ -994,26 +1001,29 @@ netbsd_elf_signature(struct lwp *l, stru
994 && memcmp(ndata, ELF_NOTE_MCMODEL_NAME, 1001 && memcmp(ndata, ELF_NOTE_MCMODEL_NAME,
995 ELF_NOTE_MCMODEL_NAMESZ) == 0) { 1002 ELF_NOTE_MCMODEL_NAMESZ) == 0) {
996 ELF_MD_MCMODEL_CHECK(epp, ndesc, np->n_descsz); 1003 ELF_MD_MCMODEL_CHECK(epp, ndesc, np->n_descsz);
997 break; 1004 break;
998 } 1005 }
999 BADNOTE("mcmodel tag"); 1006 BADNOTE("mcmodel tag");
1000 goto bad; 1007 goto bad;
1001#endif 1008#endif
1002 break; 1009 break;
1003 1010
1004 case ELF_NOTE_TYPE_SUSE_VERSION_TAG: 1011 case ELF_NOTE_TYPE_SUSE_VERSION_TAG:
1005 break; 1012 break;
1006 1013
 1014 case ELF_NOTE_TYPE_GO_BUILDID_TAG:
 1015 break;
 1016
1007 default: 1017 default:
1008 BADNOTE("unknown tag"); 1018 BADNOTE("unknown tag");
1009bad: 1019bad:
1010#ifdef DIAGNOSTIC 1020#ifdef DIAGNOSTIC
1011 /* Ignore GNU tags */ 1021 /* Ignore GNU tags */
1012 if (np->n_namesz == ELF_NOTE_GNU_NAMESZ && 1022 if (np->n_namesz == ELF_NOTE_GNU_NAMESZ &&
1013 memcmp(ndata, ELF_NOTE_GNU_NAME, 1023 memcmp(ndata, ELF_NOTE_GNU_NAME,
1014 ELF_NOTE_GNU_NAMESZ) == 0) 1024 ELF_NOTE_GNU_NAMESZ) == 0)
1015 break; 1025 break;
1016 1026
1017 int ns = MIN(np->n_namesz, shp->sh_size - sizeof(*np)); 1027 int ns = MIN(np->n_namesz, shp->sh_size - sizeof(*np));
1018 printf("%s: Unknown elf note type %d (%s): " 1028 printf("%s: Unknown elf note type %d (%s): "
1019 "[namesz=%d, descsz=%d name=%-*.*s]\n", 1029 "[namesz=%d, descsz=%d name=%-*.*s]\n",

cvs diff -r1.141 -r1.141.2.1 src/sys/sys/exec_elf.h (expand / switch to unified diff)

--- src/sys/sys/exec_elf.h 2014/07/08 17:16:25 1.141
+++ src/sys/sys/exec_elf.h 2015/11/08 00:57:09 1.141.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: exec_elf.h,v 1.141 2014/07/08 17:16:25 maxv Exp $ */ 1/* $NetBSD: exec_elf.h,v 1.141.2.1 2015/11/08 00:57:09 riz Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1994 The NetBSD Foundation, Inc. 4 * Copyright (c) 1994 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -812,26 +812,31 @@ typedef struct { @@ -812,26 +812,31 @@ typedef struct {
812 */ 812 */
813/* GNU-specific note name and description sizes */ 813/* GNU-specific note name and description sizes */
814#define ELF_NOTE_TYPE_ABI_TAG 1 814#define ELF_NOTE_TYPE_ABI_TAG 1
815#define ELF_NOTE_ABI_NAME ELF_NOTE_GNU_NAME 815#define ELF_NOTE_ABI_NAME ELF_NOTE_GNU_NAME
816#define ELF_NOTE_ABI_NAMESZ ELF_NOTE_GNU_NAMESZ 816#define ELF_NOTE_ABI_NAMESZ ELF_NOTE_GNU_NAMESZ
817#define ELF_NOTE_ABI_DESCSZ 16 817#define ELF_NOTE_ABI_DESCSZ 16
818/* GNU-specific OS/version value stuff */ 818/* GNU-specific OS/version value stuff */
819#define ELF_NOTE_ABI_OS_LINUX 0 819#define ELF_NOTE_ABI_OS_LINUX 0
820#define ELF_NOTE_ABI_OS_HURD 1 820#define ELF_NOTE_ABI_OS_HURD 1
821#define ELF_NOTE_ABI_OS_SOLARIS 2 821#define ELF_NOTE_ABI_OS_SOLARIS 2
822#define ELF_NOTE_ABI_OS_KFREEBSD 3 822#define ELF_NOTE_ABI_OS_KFREEBSD 3
823#define ELF_NOTE_ABI_OS_KNETBSD 4 823#define ELF_NOTE_ABI_OS_KNETBSD 4
824 824
 825/* Old gcc style, under the ABI tag */
 826#define ELF_NOTE_OGCC_NAMESZ 8
 827#define ELF_NOTE_OGCC_NAME "01.01\0\0\0\0"
 828#define ELF_NOTE_OGCC_DESCSZ 0
 829
825/* 830/*
826 * GNU-specific note type: Hardware capabilities 831 * GNU-specific note type: Hardware capabilities
827 * name: GNU\0 832 * name: GNU\0
828 * namesz: 4 833 * namesz: 4
829 * desc: 834 * desc:
830 * word[0]: Number of entries 835 * word[0]: Number of entries
831 * word[1]: Bitmask of enabled entries 836 * word[1]: Bitmask of enabled entries
832 * Followed by a byte id, and a NUL terminated string per entry 837 * Followed by a byte id, and a NUL terminated string per entry
833 * descsz: variable 838 * descsz: variable
834 */ 839 */
835#define ELF_NOTE_TYPE_GNU_HWCAP 2 840#define ELF_NOTE_TYPE_GNU_HWCAP 2
836 841
837/* 842/*
@@ -871,26 +876,38 @@ typedef struct { @@ -871,26 +876,38 @@ typedef struct {
871 * V = version of following data 876 * V = version of following data
872 * T = product type: [box, sles, nld, whatever] 877 * T = product type: [box, sles, nld, whatever]
873 * M = product major version 878 * M = product major version
874 * m = product minor version 879 * m = product minor version
875 * descsz: 8 880 * descsz: 8
876 */ 881 */
877#define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553 /* SuSE in LE */ 882#define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553 /* SuSE in LE */
878/* SuSE-specific note name and description sizes */ 883/* SuSE-specific note name and description sizes */
879#define ELF_NOTE_SUSE_VERSION_NAMESZ 8 884#define ELF_NOTE_SUSE_VERSION_NAMESZ 8
880#define ELF_NOTE_SUSE_VERSION_DESCSZ 8 885#define ELF_NOTE_SUSE_VERSION_DESCSZ 8
881/* SuSE-specific note name */ 886/* SuSE-specific note name */
882#define ELF_NOTE_SUSE_VERSION_NAME "SuSE\0\0\0\0" 887#define ELF_NOTE_SUSE_VERSION_NAME "SuSE\0\0\0\0"
883 888
 889/* Go-specific note type: buildid
 890 * name: Go\0\0
 891 * namesz: 4
 892 * desc:
 893 * words[10]
 894 * descsz: 40
 895 */
 896#define ELF_NOTE_TYPE_GO_BUILDID_TAG 4
 897#define ELF_NOTE_GO_BUILDID_NAMESZ 4
 898#define ELF_NOTE_GO_BUILDID_DESCSZ 40
 899#define ELF_NOTE_GO_BUILDID_NAME "Go\0\0"
 900
884/* NetBSD-specific note type: Emulation name. 901/* NetBSD-specific note type: Emulation name.
885 * name: NetBSD\0\0 902 * name: NetBSD\0\0
886 * namesz: 8 903 * namesz: 8
887 * desc:  904 * desc:
888 * word[0]: MMmmrrpp00 905 * word[0]: MMmmrrpp00
889 * 906 *
890 * M = major version 907 * M = major version
891 * m = minor version 908 * m = minor version
892 * r = release ["",A-Z,Z[A-Z] but numeric] 909 * r = release ["",A-Z,Z[A-Z] but numeric]
893 * p = patchlevel 910 * p = patchlevel
894 * descsz: 4 911 * descsz: 4
895 */ 912 */
896#define ELF_NOTE_TYPE_NETBSD_TAG 1 913#define ELF_NOTE_TYPE_NETBSD_TAG 1