diff -ur /q/8.x/src/sys/amd64/include/asm.h src/sys/amd64/include/asm.h --- /q/8.x/src/sys/amd64/include/asm.h 2007-10-16 17:57:25.000000000 +0000 +++ src/sys/amd64/include/asm.h 2007-12-29 13:21:42.000000000 +0000 @@ -83,7 +83,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) \ + .section set_srcid,"a",@progbits; \ + .p2align 0; \ + .asciz #s; \ + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ Only in src/sys/amd64/include: asm.h.orig Only in src/sys/arm/compile: KB920X diff -ur /q/8.x/src/sys/arm/include/asm.h src/sys/arm/include/asm.h --- /q/8.x/src/sys/arm/include/asm.h 2007-10-16 17:57:27.000000000 +0000 +++ src/sys/arm/include/asm.h 2007-12-29 14:50:00.000000000 +0000 @@ -104,7 +104,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) \ + .section "set_srcid","a",%progbits; \ + .p2align 0; \ + .asciz #s; \ + .previous #else #define __FBSDID(s) /* nothing */ #endif Only in src/sys/arm/include: asm.h.orig diff -ur /q/8.x/src/sys/i386/include/asm.h src/sys/i386/include/asm.h --- /q/8.x/src/sys/i386/include/asm.h 2007-10-16 17:59:39.000000000 +0000 +++ src/sys/i386/include/asm.h 2007-12-29 13:21:42.000000000 +0000 @@ -93,7 +93,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) \ + .section set_srcid,"a",@progbits; \ + .p2align 0; \ + .asciz #s; \ + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ Only in src/sys/i386/include: asm.h.orig Only in src/sys/ia64/compile: GENERIC diff -ur /q/8.x/src/sys/ia64/include/asm.h src/sys/ia64/include/asm.h --- /q/8.x/src/sys/ia64/include/asm.h 2005-02-03 03:46:11.000000000 +0000 +++ src/sys/ia64/include/asm.h 2007-12-29 13:21:42.000000000 +0000 @@ -182,7 +182,11 @@ * ID tag macros */ #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) \ + .section set_srcid,"a",@progbits; \ + .p2align 0; \ + .asciz #s; \ + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ Only in src/sys/ia64/include: asm.h.orig diff -ur /q/8.x/src/sys/kern/kern_mib.c src/sys/kern/kern_mib.c --- /q/8.x/src/sys/kern/kern_mib.c 2007-12-10 03:22:00.000000000 +0000 +++ src/sys/kern/kern_mib.c 2007-12-29 13:21:42.000000000 +0000 @@ -38,6 +38,7 @@ #include __FBSDID("$FreeBSD: src/sys/kern/kern_mib.c,v 1.85 2007/12/04 12:28:07 kib Exp $"); +#include "opt_ddb.h" #include "opt_posix.h" #include "opt_config.h" @@ -308,6 +309,106 @@ CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_PRISON, 0, 0, sysctl_kern_securelvl, "I", "Current secure level"); +/* + * If STRIP_FBSDID is defined it means we should save as much as + * possible in terms of the kernel size. Handle "kern.srcids" and "show + * srcids" DDB command only in !STRIP_FBSDID case. Otherwise, we'd need + * at least one thing lying in the srcid magic section so that we + * wouldn't be getting an error about __(start|stop)_set_srcid being + * undefined due to non-existent .srcid section; and it all would be + * just to get useless output.. + */ +#ifndef STRIP_FBSDID + +/* + * Based on __FBSDID format, skip common parts that bring no valueable + * information in this context. + */ +static void __unused +srcid_fname(char *id, char **ret, int *retlen) +{ + char *p = NULL; + int l = 0; + + KASSERT(id != NULL, ("id == NULL")); + KASSERT(ret != NULL, ("p == NULL")); + KASSERT(retlen != NULL, ("len == NULL")); + + p = strstr(id, "$FreeBSD: "); + if (p != NULL) + id += strlen("$FreeBSD: "); + l = strlen(id); + p = strstr(id, " Exp $"); + if (p != NULL) + l = p - id; + *ret = id; + *retlen = l; +} + + +/* + * Magic generated by the gcc(1) to mark the section ranges with special + * variable names. + */ +extern char __start_set_srcid[]; +extern char __stop_set_srcid[]; + +#define FBSDID_BEGIN (&__start_set_srcid[0]) +#define FBSDID_END (&__stop_set_srcid[0]) + +/* + * Return all __FBSDID tags. The output is huge. + */ +static int +sysctl_kern_srcids(SYSCTL_HANDLER_ARGS) +{ + char *bid = FBSDID_BEGIN; + char *eid = FBSDID_END; + char *s; + int idlen; + char *id; + int error = 0; + + for (s = bid; s < eid; s++) { + srcid_fname(s, &id, &idlen); + error = sysctl_handle_opaque(oidp, "\n", 1, req); + if (error) + break; + error = sysctl_handle_opaque(oidp, id, idlen, req); + if (error) + break; + s += strlen(s); + } + error = sysctl_handle_opaque(oidp, "\0", 1, req); + if (error) + return (error); + return (error); +} +SYSCTL_PROC(_kern, OID_AUTO, srcids, CTLTYPE_STRING|CTLFLAG_RD, 0, 0, + sysctl_kern_srcids, "A", "Revision control tags for kernel sources"); + +#ifdef DDB +#include + +DB_SHOW_COMMAND(srcids, db_srcid_list) +{ + char *bid = FBSDID_BEGIN; + char *eid = FBSDID_END; + char *s; + int slen; + int idlen; + char *id; + + for (s = bid; s < eid; s++) { + srcid_fname(s, &id, &idlen); + db_printf("%.*s\n", idlen, id); + slen = strlen(s); + s += slen; + } +} +#endif +#endif /* STRIP_FBSDID */ + #ifdef INCLUDE_CONFIG_FILE /* Actual kernel configuration options. */ extern char kernconfstring[]; Only in src/sys/kern: kern_mib.c.orig diff -ur /q/8.x/src/sys/powerpc/include/asm.h src/sys/powerpc/include/asm.h --- /q/8.x/src/sys/powerpc/include/asm.h 2005-01-09 04:04:30.000000000 +0000 +++ src/sys/powerpc/include/asm.h 2007-12-29 13:21:42.000000000 +0000 @@ -79,7 +79,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) \ + .section set_srcid,"a",@progbits; \ + .p2align 0; \ + .asciz #s; \ + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ Only in src/sys/powerpc/include: asm.h.orig diff -ur /q/8.x/src/sys/sparc64/include/asm.h src/sys/sparc64/include/asm.h --- /q/8.x/src/sys/sparc64/include/asm.h 2004-04-09 16:30:01.000000000 +0000 +++ src/sys/sparc64/include/asm.h 2007-12-29 13:21:42.000000000 +0000 @@ -101,7 +101,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) \ + .section set_srcid,"a",@progbits; \ + .p2align 0; \ + .asciz #s; \ + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ Only in src/sys/sparc64/include: asm.h.orig diff -ur /q/8.x/src/sys/sun4v/include/asm.h src/sys/sun4v/include/asm.h --- /q/8.x/src/sys/sun4v/include/asm.h 2006-11-23 02:25:16.000000000 +0000 +++ src/sys/sun4v/include/asm.h 2007-12-29 13:21:42.000000000 +0000 @@ -108,7 +108,11 @@ #undef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) .ident s +#define __FBSDID(s) \ + .section set_srcid,"a",@progbits; \ + .p2align 0; \ + .asciz #s; \ + .previous #else #define __FBSDID(s) /* nothing */ #endif /* not lint and not STRIP_FBSDID */ Only in src/sys/sun4v/include: asm.h.orig diff -ur /q/8.x/src/sys/sys/cdefs.h src/sys/sys/cdefs.h --- /q/8.x/src/sys/sys/cdefs.h 2007-12-10 03:23:00.000000000 +0000 +++ src/sys/sys/cdefs.h 2007-12-29 14:21:00.000000000 +0000 @@ -403,11 +403,32 @@ */ #ifndef __FBSDID #if !defined(lint) && !defined(STRIP_FBSDID) -#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s) + +/* + * ARM is somehow special.. + */ +#ifdef __arm__ +#define FBSDID_SECTYPE "%progbits" #else -#define __FBSDID(s) struct __hack +#define FBSDID_SECTYPE "@progbits" #endif + +#if !defined(__i386__) && !defined (__amd64__) && !defined (__ia64__) +#define FBSDID_SECTION() \ + __asm__(".section \"set_srcid\",\"a\"," FBSDID_SECTYPE) +#else /* otherwise, for __i386__, __amd64__ or __ia64__ we have: */ +#define FBSDID_SECTION() \ + __asm__(".section set_srcid,\"a\"," FBSDID_SECTYPE) +#endif +#define __FBSDID(s) \ + FBSDID_SECTION(); \ + __asm__(".p2align 0"); \ + __asm__(".asciz " #s); \ + __asm__(".previous"); +#else /* defined(line) || defined(STRIP_FBSDID) */ +#define __FBSDID(s) struct __hack #endif +#endif /* __FBSDID */ #ifndef __RCSID #ifndef NO__RCSID Only in src/sys/sys: cdefs.h.orig