1232950Stheraven/* 2232950Stheraven * Copyright 2010-2011 PathScale, Inc. All rights reserved. 3232950Stheraven * 4232950Stheraven * Redistribution and use in source and binary forms, with or without 5232950Stheraven * modification, are permitted provided that the following conditions are met: 6232950Stheraven * 7232950Stheraven * 1. Redistributions of source code must retain the above copyright notice, 8232950Stheraven * this list of conditions and the following disclaimer. 9232950Stheraven * 10232950Stheraven * 2. Redistributions in binary form must reproduce the above copyright notice, 11232950Stheraven * this list of conditions and the following disclaimer in the documentation 12232950Stheraven * and/or other materials provided with the distribution. 13232950Stheraven * 14232950Stheraven * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS 15232950Stheraven * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 16232950Stheraven * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17232950Stheraven * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 18232950Stheraven * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19232950Stheraven * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20232950Stheraven * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 21232950Stheraven * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22232950Stheraven * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23232950Stheraven * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 24232950Stheraven * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25232950Stheraven */ 26227825Stheraven/** 27227825Stheraven * dwarf_eh.h - Defines some helper functions for parsing DWARF exception 28227825Stheraven * handling tables. 29227825Stheraven * 30227825Stheraven * This file contains various helper functions that are independent of the 31227825Stheraven * language-specific code. It can be used in any personality function for the 32227825Stheraven * Itanium ABI. 33227825Stheraven */ 34227825Stheraven#include <assert.h> 35227825Stheraven 36227825Stheraven// TODO: Factor out Itanium / ARM differences. We probably want an itanium.h 37227825Stheraven// and arm.h that can be included by this file depending on the target ABI. 38227825Stheraven 39227825Stheraven// _GNU_SOURCE must be defined for unwind.h to expose some of the functions 40227825Stheraven// that we want. If it isn't, then we define it and undefine it to make sure 41227825Stheraven// that it doesn't impact the rest of the program. 42227825Stheraven#ifndef _GNU_SOURCE 43227825Stheraven# define _GNU_SOURCE 1 44227972Stheraven# include "unwind.h" 45227825Stheraven# undef _GNU_SOURCE 46227825Stheraven#else 47227972Stheraven# include "unwind.h" 48227825Stheraven#endif 49227825Stheraven 50227825Stheraven#include <stdint.h> 51227825Stheraven 52227825Stheraven/// Type used for pointers into DWARF data 53227825Stheraventypedef unsigned char *dw_eh_ptr_t; 54227825Stheraven 55227825Stheraven// Flag indicating a signed quantity 56227825Stheraven#define DW_EH_PE_signed 0x08 57227825Stheraven/// DWARF data encoding types. 58227825Stheravenenum dwarf_data_encoding 59227825Stheraven{ 60253159Stheraven /// Absolute pointer value 61253159Stheraven DW_EH_PE_absptr = 0x00, 62227825Stheraven /// Unsigned, little-endian, base 128-encoded (variable length). 63227825Stheraven DW_EH_PE_uleb128 = 0x01, 64227825Stheraven /// Unsigned 16-bit integer. 65227825Stheraven DW_EH_PE_udata2 = 0x02, 66227825Stheraven /// Unsigned 32-bit integer. 67227825Stheraven DW_EH_PE_udata4 = 0x03, 68227825Stheraven /// Unsigned 64-bit integer. 69227825Stheraven DW_EH_PE_udata8 = 0x04, 70227825Stheraven /// Signed, little-endian, base 128-encoded (variable length) 71227825Stheraven DW_EH_PE_sleb128 = DW_EH_PE_uleb128 | DW_EH_PE_signed, 72227825Stheraven /// Signed 16-bit integer. 73227825Stheraven DW_EH_PE_sdata2 = DW_EH_PE_udata2 | DW_EH_PE_signed, 74227825Stheraven /// Signed 32-bit integer. 75227825Stheraven DW_EH_PE_sdata4 = DW_EH_PE_udata4 | DW_EH_PE_signed, 76227825Stheraven /// Signed 32-bit integer. 77227825Stheraven DW_EH_PE_sdata8 = DW_EH_PE_udata8 | DW_EH_PE_signed 78227825Stheraven}; 79227825Stheraven 80227825Stheraven/** 81227825Stheraven * Returns the encoding for a DWARF EH table entry. The encoding is stored in 82227825Stheraven * the low four of an octet. The high four bits store the addressing mode. 83227825Stheraven */ 84227825Stheravenstatic inline enum dwarf_data_encoding get_encoding(unsigned char x) 85227825Stheraven{ 86227825Stheraven return (enum dwarf_data_encoding)(x & 0xf); 87227825Stheraven} 88227825Stheraven 89227825Stheraven/** 90227825Stheraven * DWARF addressing mode constants. When reading a pointer value from a DWARF 91227825Stheraven * exception table, you must know how it is stored and what the addressing mode 92227825Stheraven * is. The low four bits tell you the encoding, allowing you to decode a 93227825Stheraven * number. The high four bits tell you the addressing mode, allowing you to 94227825Stheraven * turn that number into an address in memory. 95227825Stheraven */ 96227825Stheravenenum dwarf_data_relative 97227825Stheraven{ 98227825Stheraven /// Value is omitted 99227825Stheraven DW_EH_PE_omit = 0xff, 100227825Stheraven /// Value relative to program counter 101227825Stheraven DW_EH_PE_pcrel = 0x10, 102227825Stheraven /// Value relative to the text segment 103227825Stheraven DW_EH_PE_textrel = 0x20, 104227825Stheraven /// Value relative to the data segment 105227825Stheraven DW_EH_PE_datarel = 0x30, 106227825Stheraven /// Value relative to the start of the function 107227825Stheraven DW_EH_PE_funcrel = 0x40, 108227825Stheraven /// Aligned pointer (Not supported yet - are they actually used?) 109227825Stheraven DW_EH_PE_aligned = 0x50, 110227825Stheraven /// Pointer points to address of real value 111227825Stheraven DW_EH_PE_indirect = 0x80 112227825Stheraven}; 113227825Stheraven/** 114227825Stheraven * Returns the addressing mode component of this encoding. 115227825Stheraven */ 116227825Stheravenstatic inline enum dwarf_data_relative get_base(unsigned char x) 117227825Stheraven{ 118227825Stheraven return (enum dwarf_data_relative)(x & 0x70); 119227825Stheraven} 120227825Stheraven/** 121227825Stheraven * Returns whether an encoding represents an indirect address. 122227825Stheraven */ 123227825Stheravenstatic int is_indirect(unsigned char x) 124227825Stheraven{ 125227825Stheraven return ((x & DW_EH_PE_indirect) == DW_EH_PE_indirect); 126227825Stheraven} 127227825Stheraven 128227825Stheraven/** 129227825Stheraven * Returns the size of a fixed-size encoding. This function will abort if 130227825Stheraven * called with a value that is not a fixed-size encoding. 131227825Stheraven */ 132227825Stheravenstatic inline int dwarf_size_of_fixed_size_field(unsigned char type) 133227825Stheraven{ 134227825Stheraven switch (get_encoding(type)) 135227825Stheraven { 136227825Stheraven default: abort(); 137227825Stheraven case DW_EH_PE_sdata2: 138227825Stheraven case DW_EH_PE_udata2: return 2; 139227825Stheraven case DW_EH_PE_sdata4: 140227825Stheraven case DW_EH_PE_udata4: return 4; 141227825Stheraven case DW_EH_PE_sdata8: 142227825Stheraven case DW_EH_PE_udata8: return 8; 143227825Stheraven case DW_EH_PE_absptr: return sizeof(void*); 144227825Stheraven } 145227825Stheraven} 146227825Stheraven 147227825Stheraven/** 148227825Stheraven * Read an unsigned, little-endian, base-128, DWARF value. Updates *data to 149227825Stheraven * point to the end of the value. Stores the number of bits read in the value 150227825Stheraven * pointed to by b, allowing you to determine the value of the highest bit, and 151227825Stheraven * therefore the sign of a signed value. 152227825Stheraven * 153227825Stheraven * This function is not intended to be called directly. Use read_sleb128() or 154227825Stheraven * read_uleb128() for reading signed and unsigned versions, respectively. 155227825Stheraven */ 156227825Stheravenstatic uint64_t read_leb128(dw_eh_ptr_t *data, int *b) 157227825Stheraven{ 158227825Stheraven uint64_t uleb = 0; 159227825Stheraven unsigned int bit = 0; 160227825Stheraven unsigned char digit = 0; 161227825Stheraven // We have to read at least one octet, and keep reading until we get to one 162227825Stheraven // with the high bit unset 163227825Stheraven do 164227825Stheraven { 165227825Stheraven // This check is a bit too strict - we should also check the highest 166227825Stheraven // bit of the digit. 167227825Stheraven assert(bit < sizeof(uint64_t) * 8); 168227825Stheraven // Get the base 128 digit 169227825Stheraven digit = (**data) & 0x7f; 170227825Stheraven // Add it to the current value 171227825Stheraven uleb += digit << bit; 172227825Stheraven // Increase the shift value 173227825Stheraven bit += 7; 174227825Stheraven // Proceed to the next octet 175227825Stheraven (*data)++; 176227825Stheraven // Terminate when we reach a value that does not have the high bit set 177227825Stheraven // (i.e. which was not modified when we mask it with 0x7f) 178227825Stheraven } while ((*(*data - 1)) != digit); 179227825Stheraven *b = bit; 180227825Stheraven 181227825Stheraven return uleb; 182227825Stheraven} 183227825Stheraven 184227825Stheraven/** 185227825Stheraven * Reads an unsigned little-endian base-128 value starting at the address 186227825Stheraven * pointed to by *data. Updates *data to point to the next byte after the end 187227825Stheraven * of the variable-length value. 188227825Stheraven */ 189227825Stheravenstatic int64_t read_uleb128(dw_eh_ptr_t *data) 190227825Stheraven{ 191227825Stheraven int b; 192227825Stheraven return read_leb128(data, &b); 193227825Stheraven} 194227825Stheraven 195227825Stheraven/** 196227825Stheraven * Reads a signed little-endian base-128 value starting at the address pointed 197227825Stheraven * to by *data. Updates *data to point to the next byte after the end of the 198227825Stheraven * variable-length value. 199227825Stheraven */ 200227825Stheravenstatic int64_t read_sleb128(dw_eh_ptr_t *data) 201227825Stheraven{ 202227825Stheraven int bits; 203227825Stheraven // Read as if it's signed 204227825Stheraven uint64_t uleb = read_leb128(data, &bits); 205227825Stheraven // If the most significant bit read is 1, then we need to sign extend it 206227825Stheraven if ((uleb >> (bits-1)) == 1) 207227825Stheraven { 208227825Stheraven // Sign extend by setting all bits in front of it to 1 209227825Stheraven uleb |= ((int64_t)-1) << bits; 210227825Stheraven } 211227825Stheraven return (int64_t)uleb; 212227825Stheraven} 213227825Stheraven/** 214227825Stheraven * Reads a value using the specified encoding from the address pointed to by 215227825Stheraven * *data. Updates the value of *data to point to the next byte after the end 216227825Stheraven * of the data. 217227825Stheraven */ 218227825Stheravenstatic uint64_t read_value(char encoding, dw_eh_ptr_t *data) 219227825Stheraven{ 220227825Stheraven enum dwarf_data_encoding type = get_encoding(encoding); 221227825Stheraven uint64_t v; 222227825Stheraven switch (type) 223227825Stheraven { 224227825Stheraven // Read fixed-length types 225227825Stheraven#define READ(dwarf, type) \ 226227825Stheraven case dwarf:\ 227227825Stheraven v = (uint64_t)(*(type*)(*data));\ 228227825Stheraven *data += sizeof(type);\ 229227825Stheraven break; 230227825Stheraven READ(DW_EH_PE_udata2, uint16_t) 231227825Stheraven READ(DW_EH_PE_udata4, uint32_t) 232227825Stheraven READ(DW_EH_PE_udata8, uint64_t) 233227825Stheraven READ(DW_EH_PE_sdata2, int16_t) 234227825Stheraven READ(DW_EH_PE_sdata4, int32_t) 235227825Stheraven READ(DW_EH_PE_sdata8, int64_t) 236227825Stheraven READ(DW_EH_PE_absptr, intptr_t) 237227825Stheraven#undef READ 238227825Stheraven // Read variable-length types 239227825Stheraven case DW_EH_PE_sleb128: 240227825Stheraven v = read_sleb128(data); 241227825Stheraven break; 242227825Stheraven case DW_EH_PE_uleb128: 243227825Stheraven v = read_uleb128(data); 244227825Stheraven break; 245227825Stheraven default: abort(); 246227825Stheraven } 247227825Stheraven 248227825Stheraven return v; 249227825Stheraven} 250227825Stheraven 251227825Stheraven/** 252227825Stheraven * Resolves an indirect value. This expects an unwind context, an encoding, a 253227825Stheraven * decoded value, and the start of the region as arguments. The returned value 254227825Stheraven * is a pointer to the address identified by the encoded value. 255227825Stheraven * 256227825Stheraven * If the encoding does not specify an indirect value, then this returns v. 257227825Stheraven */ 258227825Stheravenstatic uint64_t resolve_indirect_value(_Unwind_Context *c, 259227825Stheraven unsigned char encoding, 260227825Stheraven int64_t v, 261227825Stheraven dw_eh_ptr_t start) 262227825Stheraven{ 263227825Stheraven switch (get_base(encoding)) 264227825Stheraven { 265227825Stheraven case DW_EH_PE_pcrel: 266227825Stheraven v += (uint64_t)start; 267227825Stheraven break; 268227825Stheraven case DW_EH_PE_textrel: 269227825Stheraven v += (uint64_t)_Unwind_GetTextRelBase(c); 270227825Stheraven break; 271227825Stheraven case DW_EH_PE_datarel: 272227825Stheraven v += (uint64_t)_Unwind_GetDataRelBase(c); 273227825Stheraven break; 274227825Stheraven case DW_EH_PE_funcrel: 275227825Stheraven v += (uint64_t)_Unwind_GetRegionStart(c); 276227825Stheraven default: 277227825Stheraven break; 278227825Stheraven } 279227825Stheraven // If this is an indirect value, then it is really the address of the real 280227825Stheraven // value 281227825Stheraven // TODO: Check whether this should really always be a pointer - it seems to 282227825Stheraven // be a GCC extensions, so not properly documented... 283227825Stheraven if (is_indirect(encoding)) 284227825Stheraven { 285227825Stheraven v = (uint64_t)(uintptr_t)*(void**)v; 286227825Stheraven } 287227825Stheraven return v; 288227825Stheraven} 289227825Stheraven 290227825Stheraven 291227825Stheraven/** 292227825Stheraven * Reads an encoding and a value, updating *data to point to the next byte. 293227825Stheraven */ 294227825Stheravenstatic inline void read_value_with_encoding(_Unwind_Context *context, 295227825Stheraven dw_eh_ptr_t *data, 296227825Stheraven uint64_t *out) 297227825Stheraven{ 298227825Stheraven dw_eh_ptr_t start = *data; 299227825Stheraven unsigned char encoding = *((*data)++); 300227825Stheraven // If this value is omitted, skip it and don't touch the output value 301227825Stheraven if (encoding == DW_EH_PE_omit) { return; } 302227825Stheraven 303227825Stheraven *out = read_value(encoding, data); 304227825Stheraven *out = resolve_indirect_value(context, encoding, *out, start); 305227825Stheraven} 306227825Stheraven 307227825Stheraven/** 308227825Stheraven * Structure storing a decoded language-specific data area. Use parse_lsda() 309227825Stheraven * to generate an instance of this structure from the address returned by the 310227825Stheraven * generic unwind library. 311227825Stheraven * 312227825Stheraven * You should not need to inspect the fields of this structure directly if you 313227825Stheraven * are just using this header. The structure stores the locations of the 314227825Stheraven * various tables used for unwinding exceptions and is used by the functions 315227825Stheraven * for reading values from these tables. 316227825Stheraven */ 317227825Stheravenstruct dwarf_eh_lsda 318227825Stheraven{ 319227825Stheraven /// The start of the region. This is a cache of the value returned by 320227825Stheraven /// _Unwind_GetRegionStart(). 321227825Stheraven dw_eh_ptr_t region_start; 322227825Stheraven /// The start of the landing pads table. 323227825Stheraven dw_eh_ptr_t landing_pads; 324227825Stheraven /// The start of the type table. 325227825Stheraven dw_eh_ptr_t type_table; 326227825Stheraven /// The encoding used for entries in the type tables. 327227825Stheraven unsigned char type_table_encoding; 328227825Stheraven /// The location of the call-site table. 329227825Stheraven dw_eh_ptr_t call_site_table; 330227825Stheraven /// The location of the action table. 331227825Stheraven dw_eh_ptr_t action_table; 332227825Stheraven /// The encoding used for entries in the call-site table. 333227825Stheraven unsigned char callsite_encoding; 334227825Stheraven}; 335227825Stheraven 336227825Stheraven/** 337227825Stheraven * Parse the header on the language-specific data area and return a structure 338227825Stheraven * containing the addresses and encodings of the various tables. 339227825Stheraven */ 340227825Stheravenstatic inline struct dwarf_eh_lsda parse_lsda(_Unwind_Context *context, 341227825Stheraven unsigned char *data) 342227825Stheraven{ 343227825Stheraven struct dwarf_eh_lsda lsda; 344227825Stheraven 345227825Stheraven lsda.region_start = (dw_eh_ptr_t)(uintptr_t)_Unwind_GetRegionStart(context); 346227825Stheraven 347227825Stheraven // If the landing pads are relative to anything other than the start of 348227825Stheraven // this region, find out where. This is @LPStart in the spec, although the 349227825Stheraven // encoding that GCC uses does not quite match the spec. 350227825Stheraven uint64_t v = (uint64_t)(uintptr_t)lsda.region_start; 351227825Stheraven read_value_with_encoding(context, &data, &v); 352227825Stheraven lsda.landing_pads = (dw_eh_ptr_t)(uintptr_t)v; 353227825Stheraven 354227825Stheraven // If there is a type table, find out where it is. This is @TTBase in the 355227825Stheraven // spec. Note: we find whether there is a type table pointer by checking 356227825Stheraven // whether the leading byte is DW_EH_PE_omit (0xff), which is not what the 357227825Stheraven // spec says, but does seem to be how G++ indicates this. 358227825Stheraven lsda.type_table = 0; 359227825Stheraven lsda.type_table_encoding = *data++; 360227825Stheraven if (lsda.type_table_encoding != DW_EH_PE_omit) 361227825Stheraven { 362227825Stheraven v = read_uleb128(&data); 363227825Stheraven dw_eh_ptr_t type_table = data; 364227825Stheraven type_table += v; 365227825Stheraven lsda.type_table = type_table; 366227825Stheraven //lsda.type_table = (uintptr_t*)(data + v); 367227825Stheraven } 368227972Stheraven#if __arm__ 369227972Stheraven lsda.type_table_encoding = (DW_EH_PE_pcrel | DW_EH_PE_indirect); 370227972Stheraven#endif 371227825Stheraven 372227825Stheraven lsda.callsite_encoding = (enum dwarf_data_encoding)(*(data++)); 373227825Stheraven 374227825Stheraven // Action table is immediately after the call site table 375227825Stheraven lsda.action_table = data; 376227825Stheraven uintptr_t callsite_size = (uintptr_t)read_uleb128(&data); 377227825Stheraven lsda.action_table = data + callsite_size; 378227825Stheraven // Call site table is immediately after the header 379227825Stheraven lsda.call_site_table = (dw_eh_ptr_t)data; 380227825Stheraven 381227825Stheraven 382227825Stheraven return lsda; 383227825Stheraven} 384227825Stheraven 385227825Stheraven/** 386227825Stheraven * Structure representing an action to be performed while unwinding. This 387227825Stheraven * contains the address that should be unwound to and the action record that 388227825Stheraven * provoked this action. 389227825Stheraven */ 390227825Stheravenstruct dwarf_eh_action 391227825Stheraven{ 392227825Stheraven /** 393227825Stheraven * The address that this action directs should be the new program counter 394227825Stheraven * value after unwinding. 395227825Stheraven */ 396227825Stheraven dw_eh_ptr_t landing_pad; 397227825Stheraven /// The address of the action record. 398227825Stheraven dw_eh_ptr_t action_record; 399227825Stheraven}; 400227825Stheraven 401227825Stheraven/** 402227825Stheraven * Look up the landing pad that corresponds to the current invoke. 403227825Stheraven * Returns true if record exists. The context is provided by the generic 404227825Stheraven * unwind library and the lsda should be the result of a call to parse_lsda(). 405227825Stheraven * 406227825Stheraven * The action record is returned via the result parameter. 407227825Stheraven */ 408227825Stheravenstatic bool dwarf_eh_find_callsite(struct _Unwind_Context *context, 409227825Stheraven struct dwarf_eh_lsda *lsda, 410227825Stheraven struct dwarf_eh_action *result) 411227825Stheraven{ 412227825Stheraven result->action_record = 0; 413227825Stheraven result->landing_pad = 0; 414227825Stheraven // The current instruction pointer offset within the region 415227825Stheraven uint64_t ip = _Unwind_GetIP(context) - _Unwind_GetRegionStart(context); 416227825Stheraven unsigned char *callsite_table = (unsigned char*)lsda->call_site_table; 417227825Stheraven 418227825Stheraven while (callsite_table <= lsda->action_table) 419227825Stheraven { 420227825Stheraven // Once again, the layout deviates from the spec. 421227825Stheraven uint64_t call_site_start, call_site_size, landing_pad, action; 422227825Stheraven call_site_start = read_value(lsda->callsite_encoding, &callsite_table); 423227825Stheraven call_site_size = read_value(lsda->callsite_encoding, &callsite_table); 424227825Stheraven 425227825Stheraven // Call site entries are sorted, so if we find a call site that's after 426227825Stheraven // the current instruction pointer then there is no action associated 427227825Stheraven // with this call and we should unwind straight through this frame 428227825Stheraven // without doing anything. 429227825Stheraven if (call_site_start > ip) { break; } 430227825Stheraven 431227825Stheraven // Read the address of the landing pad and the action from the call 432227825Stheraven // site table. 433227825Stheraven landing_pad = read_value(lsda->callsite_encoding, &callsite_table); 434227825Stheraven action = read_uleb128(&callsite_table); 435227825Stheraven 436227825Stheraven // We should not include the call_site_start (beginning of the region) 437227825Stheraven // address in the ip range. For each call site: 438227825Stheraven // 439227825Stheraven // address1: call proc 440227825Stheraven // address2: next instruction 441227825Stheraven // 442227825Stheraven // The call stack contains address2 and not address1, address1 can be 443227825Stheraven // at the end of another EH region. 444227825Stheraven if (call_site_start < ip && ip <= call_site_start + call_site_size) 445227825Stheraven { 446227825Stheraven if (action) 447227825Stheraven { 448227825Stheraven // Action records are 1-biased so both no-record and zeroth 449227825Stheraven // record can be stored. 450227825Stheraven result->action_record = lsda->action_table + action - 1; 451227825Stheraven } 452227825Stheraven // No landing pad means keep unwinding. 453227825Stheraven if (landing_pad) 454227825Stheraven { 455227825Stheraven // Landing pad is the offset from the value in the header 456227825Stheraven result->landing_pad = lsda->landing_pads + landing_pad; 457227825Stheraven } 458227825Stheraven return true; 459227825Stheraven } 460227825Stheraven } 461227825Stheraven return false; 462227825Stheraven} 463227825Stheraven 464227825Stheraven/// Defines an exception class from 8 bytes (endian independent) 465227825Stheraven#define EXCEPTION_CLASS(a,b,c,d,e,f,g,h) \ 466227825Stheraven (((uint64_t)a << 56) +\ 467227825Stheraven ((uint64_t)b << 48) +\ 468227825Stheraven ((uint64_t)c << 40) +\ 469227825Stheraven ((uint64_t)d << 32) +\ 470227825Stheraven ((uint64_t)e << 24) +\ 471227825Stheraven ((uint64_t)f << 16) +\ 472227825Stheraven ((uint64_t)g << 8) +\ 473227825Stheraven ((uint64_t)h)) 474227825Stheraven 475227825Stheraven#define GENERIC_EXCEPTION_CLASS(e,f,g,h) \ 476227825Stheraven ((uint32_t)e << 24) +\ 477227825Stheraven ((uint32_t)f << 16) +\ 478227825Stheraven ((uint32_t)g << 8) +\ 479227825Stheraven ((uint32_t)h) 480