diff --git a/src/Makefile.am b/src/Makefile.am index 281f2f5d..b3fd0433 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -400,14 +400,15 @@ endif libunwind_setjmp_la_SOURCES += arm/siglongjmp.S else if ARCH_IA64 - ia64_mk_Gcursor_i_SOURCES = ia64/mk_Gcursor_i.c - ia64_mk_Lcursor_i_SOURCES = ia64/mk_Lcursor_i.c - noinst_PROGRAMS = ia64/mk_Gcursor_i ia64/mk_Lcursor_i BUILT_SOURCES = Gcursor_i.h Lcursor_i.h -Gcursor_i.h: ia64/mk_Gcursor_i - ia64/mk_Gcursor_i > $@ -Lcursor_i.h: ia64/mk_Lcursor_i - ia64/mk_Lcursor_i > $@ +mk_Gcursor_i.s: ia64/mk_Gcursor_i.c + $(COMPILE) -S ia64/mk_Gcursor_i.c -o mk_Gcursor_i.s +mk_Lcursor_i.s: ia64/mk_Lcursor_i.c + $(COMPILE) -S ia64/mk_Lcursor_i.c -o mk_Lcursor_i.s +Gcursor_i.h: mk_Gcursor_i.s + ia64/mk_cursor_i mk_Gcursor_i.s > Gcursor_i.h +Lcursor_i.h: mk_Lcursor_i.s + ia64/mk_cursor_i mk_Lcursor_i.s > Lcursor_i.h lib_LTLIBRARIES += libunwind-ia64.la libunwind_la_SOURCES = $(libunwind_la_SOURCES_ia64) diff --git a/src/ia64/mk_Gcursor_i.c b/src/ia64/mk_Gcursor_i.c index 51cb0f40..b8f32531 100644 --- a/src/ia64/mk_Gcursor_i.c +++ b/src/ia64/mk_Gcursor_i.c @@ -25,8 +25,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* Utility to generate cursor_i.h. */ -#include - #include "libunwind_i.h" #ifdef offsetof @@ -35,72 +33,33 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define offsetof(type,field) ((char *) &((type *) 0)->field - (char *) 0) -static struct - { - const char name[256]; - unsigned long value; - } -tab[] = - { - { "IP_OFF", offsetof (struct cursor, ip) }, - { "PR_OFF", offsetof (struct cursor, pr) }, - { "BSP_OFF", offsetof (struct cursor, bsp) }, - { "PSP_OFF", offsetof (struct cursor, psp) }, - { "PFS_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_PFS]) }, - { "RNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_RNAT]) }, - { "UNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_UNAT]) }, - { "LC_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_LC]) }, - { "FPSR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_FPSR]) }, - { "B1_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B1]) }, - { "B2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B2]) }, - { "B3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B3]) }, - { "B4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B4]) }, - { "B5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B5]) }, - { "F2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F2]) }, - { "F3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F3]) }, - { "F4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F4]) }, - { "F5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F5]) }, - { "FR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F16]) }, - { "LOC_SIZE", - (offsetof (struct cursor, loc[1]) - offsetof (struct cursor, loc[0])) - }, - { "SIGCONTEXT_ADDR_OFF", offsetof (struct cursor, sigcontext_addr) }, -}; - -static const char *tabs = "\t\t\t\t\t\t\t\t\t\t"; +#define OFFSET(sym, offset) \ + asm volatile("\n->" #sym " %0" : : "i" (offset)) int -main (int argc, char **argv) +main (void) { - const char *space; - int i, num_tabs; - size_t len; - - printf ("#ifndef cursor_i_h\n"); - printf ("#define cursor_i_h\n\n"); - - printf ("/*\n * DO NOT MODIFY\n *\n * This file was generated by " - "%s.\n *\n */\n\n", argv[0]); - - for (i = 0; i < (int) (sizeof (tab) / sizeof (tab[0])); ++i) - { - if (tab[i].name[0] == '\0') - printf ("\n"); - else - { - len = strlen (tab[i].name); - - num_tabs = (40 - len) / 8; - if (num_tabs <= 0) - space = " "; - else - space = strchr(tabs, '\0') - (40 - len) / 8; - - printf ("#define %s%s%lu\t/* 0x%lx */\n", - tab[i].name, space, tab[i].value, tab[i].value); - } - } - - printf ("\n#endif /* cursor_i_h */\n"); + OFFSET("IP_OFF", offsetof (struct cursor, ip)); + OFFSET("PR_OFF", offsetof (struct cursor, pr)); + OFFSET("BSP_OFF", offsetof (struct cursor, bsp)); + OFFSET("PSP_OFF", offsetof (struct cursor, psp)); + OFFSET("PFS_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_PFS])); + OFFSET("RNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_RNAT])); + OFFSET("UNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_UNAT])); + OFFSET("LC_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_LC])); + OFFSET("FPSR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_FPSR])); + OFFSET("B1_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B1])); + OFFSET("B2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B2])); + OFFSET("B3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B3])); + OFFSET("B4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B4])); + OFFSET("B5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B5])); + OFFSET("F2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F2])); + OFFSET("F3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F3])); + OFFSET("F4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F4])); + OFFSET("F5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F5])); + OFFSET("FR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F16])); + OFFSET("LOC_SIZE", + (offsetof (struct cursor, loc[1]) - offsetof (struct cursor, loc[0]))); + OFFSET("SIGCONTEXT_ADDR_OFF", offsetof (struct cursor, sigcontext_addr)); return 0; } diff --git a/src/ia64/mk_cursor_i b/src/ia64/mk_cursor_i new file mode 100755 index 00000000..9211f91b --- /dev/null +++ b/src/ia64/mk_cursor_i @@ -0,0 +1,7 @@ +#!/bin/sh +test -z "$1" && exit 1 +echo "/* GENERATED */" +echo "#ifndef cursor_i_h" +echo "#define cursor_i_h" +sed -ne 's/^->"\(\S*\)" \(\d*\)/#define \1 \2/p' < $1 || exit $? +echo "#endif"