Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
ddba96ae
Commit
ddba96ae
authored
Jun 19, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stack offset
SVN=123521
parent
f997bc6e
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
116 additions
and
26 deletions
+116
-26
6.out.h
src/cmd/6l/6.out.h
+1
-1
asm.c
src/cmd/6l/asm.c
+1
-2
l.h
src/cmd/6l/l.h
+1
-1
obj.c
src/cmd/6l/obj.c
+4
-3
optab.c
src/cmd/6l/optab.c
+1
-1
pass.c
src/cmd/6l/pass.c
+107
-0
span.c
src/cmd/6l/span.c
+1
-18
No files found.
src/cmd/6l/6.out.h
View file @
ddba96ae
...
...
@@ -32,7 +32,7 @@
#define NSNAME 8
#define NOPROF (1<<0)
#define DUPOK (1<<1)
#define SOFmark
(11)
#define SOFmark
"\xa7\xf1\xd9\x2a\x82\xc8\xd8\xfe"
/*
* amd64
...
...
src/cmd/6l/asm.c
View file @
ddba96ae
...
...
@@ -138,8 +138,7 @@ asmb(void)
for
(
p
=
firstp
;
p
!=
P
;
p
=
p
->
link
)
{
if
(
p
->
as
==
ATEXT
)
curtext
=
p
;
if
(
p
->
pc
!=
pc
)
if
(
p
->
as
!=
ATEXT
||
p
->
pc
!=
pc
+
SOFmark
)
{
if
(
p
->
pc
!=
pc
)
{
if
(
!
debug
[
'a'
])
print
(
"%P
\n
"
,
curp
);
diag
(
"phase error %llux sb %llux in %s"
,
p
->
pc
,
pc
,
TNAME
);
...
...
src/cmd/6l/l.h
View file @
ddba96ae
...
...
@@ -217,7 +217,6 @@ enum
Zaut_r
,
Zo_m
,
Zo_m64
,
Ztext
,
Zpseudo
,
Zr_m
,
Zr_m_xm
,
...
...
@@ -388,6 +387,7 @@ void export(void);
int
find1
(
long
,
int
);
int
find2
(
long
,
int
);
void
follow
(
void
);
void
addstachmark
(
void
);
void
gethunk
(
void
);
void
histtoauto
(
void
);
double
ieeedtod
(
Ieee
*
);
...
...
src/cmd/6l/obj.c
View file @
ddba96ae
...
...
@@ -400,6 +400,7 @@ main(int argc, char *argv[])
doprof1
();
else
doprof2
();
addstackmark
();
span
();
doinit
();
asmb
();
...
...
@@ -925,9 +926,9 @@ loop:
sig
=
1729
;
if
(
sig
!=
0
){
if
(
s
->
sig
!=
0
&&
s
->
sig
!=
sig
)
diag
(
"incompatible type signatures
%lux(%s)
"
"
and %lux(%s) for %s"
,
s
->
sig
,
filen
[
s
->
file
],
sig
,
pn
,
s
->
name
);
diag
(
"incompatible type signatures"
"
%lux(%s) and %lux(%s) for %s"
,
s
->
sig
,
filen
[
s
->
file
],
sig
,
pn
,
s
->
name
);
s
->
sig
=
sig
;
s
->
file
=
files
-
1
;
}
...
...
src/cmd/6l/optab.c
View file @
ddba96ae
...
...
@@ -37,7 +37,7 @@ uchar ynone[] =
};
uchar
ytext
[]
=
{
Ymb
,
Yi32
,
Z
text
,
1
,
Ymb
,
Yi32
,
Z
pseudo
,
1
,
0
};
uchar
ynop
[]
=
...
...
src/cmd/6l/pass.c
View file @
ddba96ae
...
...
@@ -281,6 +281,112 @@ loop:
goto
loop
;
}
Prog
*
byteq
(
int
v
)
{
Prog
*
p
;
p
=
prg
();
p
->
as
=
ABYTE
;
p
->
from
.
type
=
D_CONST
;
p
->
from
.
offset
=
v
&
0xff
;
return
p
;
}
void
markstk
(
Prog
*
l
)
{
Prog
*
p0
,
*
p
,
*
q
,
*
r
;
long
i
,
n
,
line
;
Sym
*
s
;
version
++
;
s
=
lookup
(
l
->
from
.
sym
->
name
,
version
);
s
->
type
=
STEXT
;
line
=
l
->
line
;
// start with fake copy of ATEXT
p0
=
prg
();
p
=
p0
;
*
p
=
*
l
;
// note this gets p->pcond and p->line
p
->
from
.
type
=
D_STATIC
;
p
->
from
.
sym
=
s
;
p
->
to
.
offset
=
0
;
// put out magic sequence
n
=
strlen
(
SOFmark
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
q
=
byteq
(
SOFmark
[
i
]);
q
->
line
=
line
;
p
->
link
=
q
;
p
=
q
;
}
// put out stack offset
n
=
l
->
to
.
offset
;
if
(
n
<
0
)
n
=
0
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
q
=
byteq
(
n
);
q
->
line
=
line
;
p
->
link
=
q
;
p
=
q
;
n
=
n
>>
8
;
}
// put out null terminated name
for
(
i
=
0
;;
i
++
)
{
n
=
s
->
name
[
i
];
q
=
byteq
(
n
);
q
->
line
=
line
;
p
->
link
=
q
;
p
=
q
;
if
(
n
==
0
)
break
;
}
// put out return instruction
q
=
prg
();
q
->
as
=
ARET
;
q
->
line
=
line
;
p
->
link
=
q
;
p
=
q
;
r
=
l
->
pcond
;
l
->
pcond
=
p0
;
p
->
link
=
r
;
p0
->
pcond
=
r
;
// hard part is linking end of
// the text body to my fake ATEXT
for
(
p
=
l
;;
p
=
q
)
{
q
=
p
->
link
;
if
(
q
==
r
)
{
p
->
link
=
p0
;
return
;
}
}
}
void
addstackmark
(
void
)
{
Prog
*
p
;
if
(
debug
[
'v'
])
Bprint
(
&
bso
,
"%5.2f stkmark
\n
"
,
cputime
());
Bflush
(
&
bso
);
for
(
p
=
textp
;
p
!=
P
;
p
=
p
->
pcond
)
{
markstk
(
p
);
// splice in new body
p
=
p
->
pcond
;
// skip the one we just put in
}
// for(p=textp; p!=P; p=p->pcond)
// print("%P\n", p);
}
int
relinv
(
int
a
)
{
...
...
@@ -344,6 +450,7 @@ patch(void)
if
(
debug
[
'v'
])
Bprint
(
&
bso
,
"%5.2f patch
\n
"
,
cputime
());
Bflush
(
&
bso
);
s
=
lookup
(
"exit"
,
0
);
vexit
=
s
->
value
;
for
(
p
=
firstp
;
p
!=
P
;
p
=
p
->
link
)
{
...
...
src/cmd/6l/span.c
View file @
ddba96ae
...
...
@@ -83,8 +83,6 @@ start:
p
->
pc
=
c
;
asmins
(
p
);
p
->
pc
=
c
;
if
(
p
->
as
==
ATEXT
)
p
->
pc
+=
SOFmark
;
// skip the stack marker
m
=
andptr
-
and
;
p
->
mark
=
m
;
c
+=
m
;
...
...
@@ -115,8 +113,6 @@ loop:
}
}
p
->
pc
=
c
;
if
(
p
->
as
==
ATEXT
)
p
->
pc
+=
SOFmark
;
// skip the stack marker
c
+=
p
->
mark
;
}
if
(
again
)
{
...
...
@@ -273,7 +269,7 @@ asmlc(void)
Prog
*
p
;
long
oldlc
,
v
,
s
;
oldpc
=
INITTEXT
+
SOFmark
;
oldpc
=
INITTEXT
;
oldlc
=
0
;
for
(
p
=
firstp
;
p
!=
P
;
p
=
p
->
link
)
{
if
(
p
->
line
==
oldlc
||
p
->
as
==
ATEXT
||
p
->
as
==
ANOP
)
{
...
...
@@ -1124,19 +1120,6 @@ found:
diag
(
"asmins: unknown z %d %P"
,
t
[
2
],
p
);
return
;
case
Ztext
:
v
=
p
->
to
.
offset
;
if
(
v
<
0
)
v
=
0
;
// eleven bytes of buried stack offset
*
andptr
++
=
v
>>
3
;
*
andptr
++
=
v
>>
11
;
*
andptr
++
=
v
>>
19
;
for
(
v
=
0
;
v
<
SOFmark
-
3
;
v
++
)
*
andptr
++
=
"
\xa7\xf1\xd9\x2a\x82\xc8\xd8\xfe
"
[
v
];
break
;
case
Zpseudo
:
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment