Use "nm | awk ..." instead of genassym(1) to generate symbol value headers.
Symbol values are now represented using array sizes (4 arrays per symbol so that 16-bit machines can represent 64-bit values) instead of being raw binary values. Reviewed by: marcel
This commit is contained in:
parent
5263356d9d
commit
6a53c4176e
@ -138,7 +138,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile}
|
||||
.endfor
|
||||
|
||||
kernel-clean:
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs genassym \
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs \
|
||||
${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \
|
||||
setdef[01].c setdefs.h tags \
|
||||
vers.c vnode_if.c vnode_if.h \
|
||||
@ -176,8 +176,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o
|
||||
# this rule stops ./assym.s in .depend from causing problems
|
||||
./assym.s: assym.s
|
||||
|
||||
assym.s: genassym.o
|
||||
genassym genassym.o >assym.s
|
||||
assym.s: $S/kern/genassym.sh genassym.o
|
||||
sh $S/kern/genassym.sh genassym.o > ${.TARGET}
|
||||
|
||||
genassym.o: $S/$M/$M/genassym.c
|
||||
${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
|
||||
|
@ -138,7 +138,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile}
|
||||
.endfor
|
||||
|
||||
kernel-clean:
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs genassym \
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs \
|
||||
${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \
|
||||
setdef[01].c setdefs.h tags \
|
||||
vers.c vnode_if.c vnode_if.h \
|
||||
@ -176,8 +176,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o
|
||||
# this rule stops ./assym.s in .depend from causing problems
|
||||
./assym.s: assym.s
|
||||
|
||||
assym.s: genassym.o
|
||||
genassym genassym.o >assym.s
|
||||
assym.s: $S/kern/genassym.sh genassym.o
|
||||
sh $S/kern/genassym.sh genassym.o > ${.TARGET}
|
||||
|
||||
genassym.o: $S/$M/$M/genassym.c
|
||||
${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
|
||||
|
@ -142,7 +142,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile}
|
||||
.endfor
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs genassym \
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs \
|
||||
${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \
|
||||
setdef[01].c setdefs.h tags \
|
||||
vers.c vnode_if.c vnode_if.h \
|
||||
@ -183,8 +183,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o
|
||||
# this rule stops ./assym.s in .depend from causing problems
|
||||
./assym.s: assym.s
|
||||
|
||||
assym.s: genassym.o
|
||||
genassym genassym.o >assym.s
|
||||
assym.s: $S/kern/genassym.sh genassym.o
|
||||
sh $S/kern/genassym.sh genassym.o > ${.TARGET}
|
||||
|
||||
genassym.o: $S/$M/$M/genassym.c
|
||||
rm -f ./machine ; ln -s $S/$M/include ./machine
|
||||
|
@ -138,7 +138,7 @@ ${mfile:T:S/.m$/.h/}: ${mfile}
|
||||
.endfor
|
||||
|
||||
kernel-clean:
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs genassym \
|
||||
rm -f *.o *.so *.So *.ko *.s eddep errs \
|
||||
${FULLKERNEL} ${KERNEL} linterrs makelinks param.c \
|
||||
setdef[01].c setdefs.h tags \
|
||||
vers.c vnode_if.c vnode_if.h \
|
||||
@ -176,8 +176,8 @@ setdef0.c setdef1.c setdefs.h: ${OBJS} param.o
|
||||
# this rule stops ./assym.s in .depend from causing problems
|
||||
./assym.s: assym.s
|
||||
|
||||
assym.s: genassym.o
|
||||
genassym genassym.o >assym.s
|
||||
assym.s: $S/kern/genassym.sh genassym.o
|
||||
sh $S/kern/genassym.sh genassym.o > ${.TARGET}
|
||||
|
||||
genassym.o: $S/$M/$M/genassym.c
|
||||
${CC} -c ${CFLAGS} $S/$M/$M/genassym.c
|
||||
|
@ -20,14 +20,14 @@ svr4_genassym.o optional compat_svr4 \
|
||||
clean "svr4_genassym.o"
|
||||
#
|
||||
linux_assym.h optional compat_linux \
|
||||
dependency "linux_genassym.o" \
|
||||
compile-with "genassym linux_genassym.o > ${.TARGET}" \
|
||||
dependency "$S/kern/genassym.sh linux_genassym.o" \
|
||||
compile-with "sh $S/kern/genassym.sh linux_genassym.o > ${.TARGET}" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "linux_assym.h"
|
||||
#
|
||||
svr4_assym.h optional compat_svr4 \
|
||||
dependency "svr4_genassym.o" \
|
||||
compile-with "genassym svr4_genassym.o > ${.TARGET}" \
|
||||
dependency "$S/kern/genassym.sh svr4_genassym.o" \
|
||||
compile-with "sh $S/kern/genassym.sh svr4_genassym.o > ${.TARGET}" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "svr4_assym.h"
|
||||
#
|
||||
|
@ -22,14 +22,14 @@ svr4_genassym.o optional compat_svr4 \
|
||||
clean "svr4_genassym.o"
|
||||
#
|
||||
linux_assym.h optional compat_linux \
|
||||
dependency "linux_genassym.o" \
|
||||
compile-with "genassym linux_genassym.o > ${.TARGET}" \
|
||||
dependency "$S/kern/genassym.sh linux_genassym.o" \
|
||||
compile-with "sh $S/kern/genassym.sh linux_genassym.o > ${.TARGET}" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "linux_assym.h"
|
||||
#
|
||||
svr4_assym.h optional compat_svr4 \
|
||||
dependency "svr4_genassym.o" \
|
||||
compile-with "genassym svr4_genassym.o > ${.TARGET}" \
|
||||
dependency "$S/kern/genassym.sh svr4_genassym.o" \
|
||||
compile-with "sh $S/kern/genassym.sh svr4_genassym.o > ${.TARGET}" \
|
||||
no-obj no-implicit-rule before-depend \
|
||||
clean "svr4_assym.h"
|
||||
#
|
||||
|
53
sys/kern/genassym.sh
Normal file
53
sys/kern/genassym.sh
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
# Grrr, this should use stdin and stdout, but is encrufted for compatibility.
|
||||
|
||||
usage() {
|
||||
echo "usage: genassym [-o outfile] objfile"
|
||||
exit 1
|
||||
}
|
||||
|
||||
outfile=/dev/stdout
|
||||
while getopts "o:" option
|
||||
do
|
||||
case "$option" in
|
||||
o) outfile="$OPTARG";;
|
||||
*) usage;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
case $# in
|
||||
1) ;;
|
||||
*) usage;;
|
||||
esac
|
||||
|
||||
nm "$1" | awk '
|
||||
/ C .*sign$/ {
|
||||
sign = substr($1, length($1) - 3, 4)
|
||||
sub("^0*", "", sign)
|
||||
if (sign != "")
|
||||
sign = "-"
|
||||
}
|
||||
/ C .*w0$/ {
|
||||
w0 = substr($1, length($1) - 3, 4)
|
||||
}
|
||||
/ C .*w1$/ {
|
||||
w1 = substr($1, length($1) - 3, 4)
|
||||
}
|
||||
/ C .*w2$/ {
|
||||
w2 = substr($1, length($1) - 3, 4)
|
||||
}
|
||||
/ C .*w3$/ {
|
||||
w3 = substr($1, length($1) - 3, 4)
|
||||
w = w3 w2 w1 w0
|
||||
sub("^0*", "", w)
|
||||
if (w == "")
|
||||
w = "0"
|
||||
sub("w3$", "", $3)
|
||||
# This still has minor problems representing INT_MIN, etc. E.g.,
|
||||
# with 32-bit 2''s complement ints, this prints -0x80000000, which
|
||||
# has the wrong type (unsigned int).
|
||||
printf("#define\t%s\t%s0x%s\n", $3, sign, w)
|
||||
}
|
||||
' 3>"$outfile" >&3 3>&-
|
@ -31,17 +31,13 @@
|
||||
#ifndef _SYS_ASSYM_H_
|
||||
#define _SYS_ASSYM_H_
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(t, m) (&((t *)0)->m)
|
||||
#endif
|
||||
#define ASSYM_ABS(value) ((value) < 0 ? -((value) + 1) + 1ULL : (value))
|
||||
|
||||
#ifndef __assym
|
||||
#define __assym(sym, v) unsigned long sym = (unsigned long)v
|
||||
#endif
|
||||
|
||||
#define ASSYM(sym, v) __assym(assym_##sym, v)
|
||||
|
||||
#define ASSYM_SELF(sym) ASSYM(sym, sym)
|
||||
#define ASSYM_OFFSET(sym, s, m) ASSYM(sym, offsetof(s, m))
|
||||
#define ASSYM(name, value) \
|
||||
char name ## sign[(value) < 0 ? 1 : 0]; \
|
||||
char name ## w0[ASSYM_ABS(value) & 0xFFFFU]; \
|
||||
char name ## w1[(ASSYM_ABS(value) & 0xFFFF0000UL) >> 16]; \
|
||||
char name ## w2[(ASSYM_ABS(value) & 0xFFFF00000000ULL) >> 32]; \
|
||||
char name ## w3[(ASSYM_ABS(value) & 0xFFFF000000000000ULL) >> 48]
|
||||
|
||||
#endif /* !_SYS_ASSYM_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user