Commit eb572e01 authored by Luuk van Dijk's avatar Luuk van Dijk

6l/8l: emit DWARF frame info.

R=rsc, ken2, r
CC=golang-dev
https://golang.org/cl/2151044
parent 8e5f673d
......@@ -95,6 +95,7 @@ struct Prog
Prog* dlink;
Prog* pcond; /* work on this */
vlong pc;
int32 spadj;
int32 line;
short as;
char ft; /* oclass cache */
......@@ -102,7 +103,7 @@ struct Prog
uchar mark; /* work on these */
uchar back;
char width; /* fake for DATA */
char width; /* fake for DATA */
char mode; /* 16, 32, or 64 */
};
struct Auto
......@@ -397,7 +398,7 @@ void buildop(void);
void cflush(void);
void ckoff(Sym*, int32);
Prog* copyp(Prog*);
vlong cpos(void);
vlong cpos(void);
double cputime(void);
void datblk(int32, int32);
void deadcode(void);
......@@ -463,3 +464,9 @@ uint32 machheadr(void);
#pragma varargck type "R" int
#pragma varargck type "A" int
#pragma varargck argpos diag 1
/* Used by ../ld/dwarf.c */
enum
{
DWARFREGSP = 7
};
......@@ -692,7 +692,7 @@ dostkoff(void)
p->from.type = D_INDIR+D_GS;
p->from.offset = tlsoffset+0;
p->to.type = D_CX;
if(debug['K']) {
// 6l -K means check not only for stack
// overflow but stack underflow.
......@@ -843,6 +843,7 @@ dostkoff(void)
p->as = AADJSP;
p->from.type = D_CONST;
p->from.offset = autoffset;
p->spadj = autoffset;
if(q != P)
q->pcond = p;
}
......@@ -903,26 +904,32 @@ dostkoff(void)
case APUSHL:
case APUSHFL:
deltasp += 4;
p->spadj = 4;
continue;
case APUSHQ:
case APUSHFQ:
deltasp += 8;
p->spadj = 8;
continue;
case APUSHW:
case APUSHFW:
deltasp += 2;
p->spadj = 2;
continue;
case APOPL:
case APOPFL:
deltasp -= 4;
p->spadj = -4;
continue;
case APOPQ:
case APOPFQ:
deltasp -= 8;
p->spadj = -8;
continue;
case APOPW:
case APOPFW:
deltasp -= 2;
p->spadj = -2;
continue;
case ARET:
break;
......@@ -937,7 +944,7 @@ dostkoff(void)
p->as = AADJSP;
p->from.type = D_CONST;
p->from.offset = -autoffset;
p->spadj = -autoffset;
p = appendp(p);
p->as = ARET;
}
......@@ -954,6 +961,7 @@ dostkoff(void)
q->from = zprg.from;
q->from.type = D_CONST;
q->from.offset = -autoffset;
q->spadj = -autoffset;
q->to = zprg.to;
continue;
}
......
......@@ -95,6 +95,7 @@ struct Prog
Prog* dlink;
Prog* pcond; /* work on this */
int32 pc;
int32 spadj;
int32 line;
short as;
char width; /* fake for DATA */
......@@ -346,7 +347,7 @@ Prog* brloop(Prog*);
void cflush(void);
void ckoff(Sym*, int32);
Prog* copyp(Prog*);
vlong cpos(void);
vlong cpos(void);
double cputime(void);
void datblk(int32, int32, int32);
void diag(char*, ...);
......@@ -412,3 +413,9 @@ void deadcode(void);
#pragma varargck type "P" Prog*
#pragma varargck type "R" int
#pragma varargck type "A" int
/* Used by ../ld/dwarf.c */
enum
{
DWARFREGSP = 4
};
......@@ -392,10 +392,10 @@ patch(void)
for(p = firstp; p != P; p = p->link) {
if(HEADTYPE == 10) { // Windows
// Convert
// op n(GS), reg
// op n(GS), reg
// to
// MOVL 0x2C(FS), reg
// op n(reg), reg
// op n(reg), reg
// The purpose of this patch is to fix some accesses
// to extern register variables (TLS) on Windows, as
// a different method is used to access them.
......@@ -770,6 +770,7 @@ dostkoff(void)
p->as = AADJSP;
p->from.type = D_CONST;
p->from.offset = autoffset;
p->spadj = autoffset;
if(q != P)
q->pcond = p;
}
......@@ -792,18 +793,22 @@ dostkoff(void)
case APUSHL:
case APUSHFL:
deltasp += 4;
p->spadj = 4;
continue;
case APUSHW:
case APUSHFW:
deltasp += 2;
p->spadj = 2;
continue;
case APOPL:
case APOPFL:
deltasp -= 4;
p->spadj = -4;
continue;
case APOPW:
case APOPFW:
deltasp -= 2;
p->spadj = -2;
continue;
case ARET:
break;
......@@ -822,6 +827,7 @@ dostkoff(void)
q->as = AADJSP;
q->from.type = D_CONST;
q->from.offset = -autoffset;
p->spadj = -autoffset;
}
continue;
......@@ -836,6 +842,7 @@ dostkoff(void)
q->from = zprg.from;
q->from.type = D_CONST;
q->from.offset = -autoffset;
p->spadj = -autoffset;
q->to = zprg.to;
continue;
}
......
This diff is collapsed.
......@@ -452,3 +452,39 @@ enum
DW_MACINFO_end_file = 0x04,
DW_MACINFO_vendor_ext = 0xff,
};
// Table 40.
enum
{ // operand,...
DW_CFA_nop = 0x00,
DW_CFA_set_loc = 0x01, // address
DW_CFA_advance_loc1 = 0x02, // 1-byte delta
DW_CFA_advance_loc2 = 0x03, // 2-byte delta
DW_CFA_advance_loc4 = 0x04, // 4-byte delta
DW_CFA_offset_extended = 0x05, // ULEB128 register, ULEB128 offset
DW_CFA_restore_extended = 0x06, // ULEB128 register
DW_CFA_undefined = 0x07, // ULEB128 register
DW_CFA_same_value = 0x08, // ULEB128 register
DW_CFA_register = 0x09, // ULEB128 register, ULEB128 register
DW_CFA_remember_state = 0x0a,
DW_CFA_restore_state = 0x0b,
DW_CFA_def_cfa = 0x0c, // ULEB128 register, ULEB128 offset
DW_CFA_def_cfa_register = 0x0d, // ULEB128 register
DW_CFA_def_cfa_offset = 0x0e, // ULEB128 offset
DW_CFA_def_cfa_expression = 0x0f, // BLOCK
DW_CFA_expression = 0x10, // ULEB128 register, BLOCK
DW_CFA_offset_extended_sf = 0x11, // ULEB128 register, SLEB128 offset
DW_CFA_def_cfa_sf = 0x12, // ULEB128 register, SLEB128 offset
DW_CFA_def_cfa_offset_sf = 0x13, // SLEB128 offset
DW_CFA_val_offset = 0x14, // ULEB128, ULEB128
DW_CFA_val_offset_sf = 0x15, // ULEB128, SLEB128
DW_CFA_val_expression = 0x16, // ULEB128, BLOCK
DW_CFA_lo_user = 0x1c,
DW_CFA_hi_user = 0x3f,
// Opcodes that take an addend operand.
DW_CFA_advance_loc = 0x1<<6, // +delta
DW_CFA_offset = 0x2<<6, // +register (ULEB128 offset)
DW_CFA_restore = 0x3<<6, // +register
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment