Date: Tue, 19 Dec 2000 23:05:39 -0800 From: Marcel Moolenaar <marcel@cup.hp.com> To: arch@FreeBSD.org Subject: gensetdefs using sh(1),sed(1),grep(1) and awk(1) Message-ID: <3A405A43.5C10697C@cup.hp.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Read and weep :-)
It takes roughly 11 seconds on a 750 Athlon for this script to process
all the object files. Not exactly quick...
I think it can do better if we can avoid the "system()" calls...
--
Marcel Moolenaar
mail: marcel@cup.hp.com / marcel@FreeBSD.org
tel: (408) 447-4222
[-- Attachment #2 --]
#!/bin/sh
#
# Generate setdefs.h
#
(for obj in $*; do
${OBJDUMP:=objdump} -h $obj | fgrep '.set.' | sed -e 's/2\*\*/1<</g' | \
awk '{ printf "%s %s ", $2, system(sprintf("exit $((%s))", $7)); \
system(sprintf("echo 16 i %s p | dc", toupper($3))) } \
' | sed -e 's/^.set.//g'
done) | sort | awk 'function emit(name, size, align) \
{ printf "DEFINE_SET(%s, %d);\n", name, size/align } \
BEGIN { name = "" } \
END { if (name != "") emit(name, size, align) } \
$1 == name { size += $3 } \
$1 != name { if (name != "") emit(name, size, align); \
name = $1; size = $3; align = $2 } \
' > setdefs.h
#
# generate setdef0.c
#
cat <<EOF > setdef0.c
/* THIS FILE IS GENERATED, DO NOT EDIT. */
#define DEFINE_SET(set, count) \\
__asm__(".section .set." #set ",\"aw\""); \\
__asm__(".globl " #set); \\
__asm__(".type " #set ",@object"); \\
__asm__(".p2align 3"); \\
__asm__(#set ":"); \\
__asm__(".quad " #count); \\
__asm__(".previous")
#include "setdefs.h"
EOF
#
# generate setdef1.c
#
cat <<EOF > setdef1.c
/* THIS FILE IS GENERATED, DO NOT EDIT. */
#define DEFINE_SET(set, count) \\
__asm__(".section .set." #set ",\"aw\""); \\
__asm__(".quad 0"); \\
__asm__(".previous")
#include "setdefs.h"
EOF
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A405A43.5C10697C>
