Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
30edda69
Commit
30edda69
authored
14 years ago
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ld: share asmlc
R=ken2 CC=golang-dev
https://golang.org/cl/2373043
parent
8d130f5d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
243 deletions
+84
-243
src/cmd/5l/asm.c
src/cmd/5l/asm.c
+0
-82
src/cmd/5l/l.h
src/cmd/5l/l.h
+1
-0
src/cmd/6l/span.c
src/cmd/6l/span.c
+0
-80
src/cmd/8l/span.c
src/cmd/8l/span.c
+0
-80
src/cmd/ld/lib.c
src/cmd/ld/lib.c
+82
-1
src/cmd/ld/lib.h
src/cmd/ld/lib.h
+1
-0
No files found.
src/cmd/5l/asm.c
View file @
30edda69
...
...
@@ -1126,88 +1126,6 @@ putsymb(char *s, int t, int32 v, int ver)
}
}
#define MINLC 4
void
asmlc
(
void
)
{
int32
oldpc
,
oldlc
;
Prog
*
p
;
int32
v
,
s
;
oldpc
=
INITTEXT
;
oldlc
=
0
;
for
(
p
=
firstp
;
p
!=
P
;
p
=
p
->
link
)
{
setarch
(
p
);
if
(
p
->
line
==
oldlc
||
p
->
as
==
ATEXT
||
p
->
as
==
ANOP
)
{
if
(
p
->
as
==
ATEXT
)
curtext
=
p
;
if
(
debug
[
'L'
])
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
continue
;
}
if
(
debug
[
'L'
])
Bprint
(
&
bso
,
"
\t\t
%6ld"
,
lcsize
);
v
=
(
p
->
pc
-
oldpc
)
/
MINLC
;
while
(
v
)
{
s
=
127
;
if
(
v
<
127
)
s
=
v
;
cput
(
s
+
128
);
/* 129-255 +pc */
if
(
debug
[
'L'
])
Bprint
(
&
bso
,
" pc+%ld*%d(%ld)"
,
s
,
MINLC
,
s
+
128
);
v
-=
s
;
lcsize
++
;
}
s
=
p
->
line
-
oldlc
;
oldlc
=
p
->
line
;
oldpc
=
p
->
pc
+
MINLC
;
if
(
s
>
64
||
s
<
-
64
)
{
cput
(
0
);
/* 0 vv +lc */
cput
(
s
>>
24
);
cput
(
s
>>
16
);
cput
(
s
>>
8
);
cput
(
s
);
if
(
debug
[
'L'
])
{
if
(
s
>
0
)
Bprint
(
&
bso
,
" lc+%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
else
Bprint
(
&
bso
,
" lc%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
}
lcsize
+=
5
;
continue
;
}
if
(
s
>
0
)
{
cput
(
0
+
s
);
/* 1-64 +lc */
if
(
debug
[
'L'
])
{
Bprint
(
&
bso
,
" lc+%ld(%ld)
\n
"
,
s
,
0
+
s
);
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
}
}
else
{
cput
(
64
-
s
);
/* 65-128 -lc */
if
(
debug
[
'L'
])
{
Bprint
(
&
bso
,
" lc%ld(%ld)
\n
"
,
s
,
64
-
s
);
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
}
}
lcsize
++
;
}
while
(
lcsize
&
1
)
{
s
=
129
;
cput
(
s
);
lcsize
++
;
}
if
(
debug
[
'v'
]
||
debug
[
'L'
])
Bprint
(
&
bso
,
"lcsize = %ld
\n
"
,
lcsize
);
Bflush
(
&
bso
);
}
static
void
outt
(
int32
f
,
int32
l
)
{
...
...
This diff is collapsed.
Click to expand it.
src/cmd/5l/l.h
View file @
30edda69
...
...
@@ -279,6 +279,7 @@ enum
NENT
=
100
,
MAXIO
=
8192
,
MAXHIST
=
20
,
/* limit of path elements for history symbols */
MINLC
=
4
,
Roffset
=
22
,
/* no. bits for offset in relocation address */
Rindex
=
10
,
/* no. bits for index in relocation address */
...
...
This diff is collapsed.
Click to expand it.
src/cmd/6l/span.c
View file @
30edda69
...
...
@@ -407,86 +407,6 @@ asmelfsym(void)
genasmsym
(
putelfsymb
);
}
void
asmlc
(
void
)
{
vlong
oldpc
;
Prog
*
p
;
int32
oldlc
,
v
,
s
;
oldpc
=
INITTEXT
;
oldlc
=
0
;
for
(
p
=
firstp
;
p
!=
P
;
p
=
p
->
link
)
{
if
(
p
->
line
==
oldlc
||
p
->
as
==
ATEXT
||
p
->
as
==
ANOP
)
{
if
(
p
->
as
==
ATEXT
)
curtext
=
p
;
if
(
debug
[
'O'
])
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
continue
;
}
if
(
debug
[
'O'
])
Bprint
(
&
bso
,
"
\t\t
%6ld"
,
lcsize
);
v
=
(
p
->
pc
-
oldpc
)
/
MINLC
;
while
(
v
)
{
s
=
127
;
if
(
v
<
127
)
s
=
v
;
cput
(
s
+
128
);
/* 129-255 +pc */
if
(
debug
[
'O'
])
Bprint
(
&
bso
,
" pc+%ld*%d(%ld)"
,
s
,
MINLC
,
s
+
128
);
v
-=
s
;
lcsize
++
;
}
s
=
p
->
line
-
oldlc
;
oldlc
=
p
->
line
;
oldpc
=
p
->
pc
+
MINLC
;
if
(
s
>
64
||
s
<
-
64
)
{
cput
(
0
);
/* 0 vv +lc */
cput
(
s
>>
24
);
cput
(
s
>>
16
);
cput
(
s
>>
8
);
cput
(
s
);
if
(
debug
[
'O'
])
{
if
(
s
>
0
)
Bprint
(
&
bso
,
" lc+%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
else
Bprint
(
&
bso
,
" lc%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
}
lcsize
+=
5
;
continue
;
}
if
(
s
>
0
)
{
cput
(
0
+
s
);
/* 1-64 +lc */
if
(
debug
[
'O'
])
{
Bprint
(
&
bso
,
" lc+%ld(%ld)
\n
"
,
s
,
0
+
s
);
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
}
}
else
{
cput
(
64
-
s
);
/* 65-128 -lc */
if
(
debug
[
'O'
])
{
Bprint
(
&
bso
,
" lc%ld(%ld)
\n
"
,
s
,
64
-
s
);
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
}
}
lcsize
++
;
}
while
(
lcsize
&
1
)
{
s
=
129
;
cput
(
s
);
lcsize
++
;
}
if
(
debug
[
'v'
]
||
debug
[
'O'
])
Bprint
(
&
bso
,
"lcsize = %ld
\n
"
,
lcsize
);
Bflush
(
&
bso
);
}
int
prefixof
(
Adr
*
a
)
{
...
...
This diff is collapsed.
Click to expand it.
src/cmd/8l/span.c
View file @
30edda69
...
...
@@ -334,86 +334,6 @@ asmsym(void)
Bflush
(
&
bso
);
}
void
asmlc
(
void
)
{
int32
oldpc
,
oldlc
;
Prog
*
p
;
int32
v
,
s
;
oldpc
=
INITTEXT
;
oldlc
=
0
;
for
(
p
=
firstp
;
p
!=
P
;
p
=
p
->
link
)
{
if
(
p
->
line
==
oldlc
||
p
->
as
==
ATEXT
||
p
->
as
==
ANOP
)
{
if
(
p
->
as
==
ATEXT
)
curtext
=
p
;
if
(
debug
[
'L'
])
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
continue
;
}
if
(
debug
[
'L'
])
Bprint
(
&
bso
,
"
\t\t
%6ld"
,
lcsize
);
v
=
(
p
->
pc
-
oldpc
)
/
MINLC
;
while
(
v
)
{
s
=
127
;
if
(
v
<
127
)
s
=
v
;
cput
(
s
+
128
);
/* 129-255 +pc */
if
(
debug
[
'L'
])
Bprint
(
&
bso
,
" pc+%ld*%d(%ld)"
,
s
,
MINLC
,
s
+
128
);
v
-=
s
;
lcsize
++
;
}
s
=
p
->
line
-
oldlc
;
oldlc
=
p
->
line
;
oldpc
=
p
->
pc
+
MINLC
;
if
(
s
>
64
||
s
<
-
64
)
{
cput
(
0
);
/* 0 vv +lc */
cput
(
s
>>
24
);
cput
(
s
>>
16
);
cput
(
s
>>
8
);
cput
(
s
);
if
(
debug
[
'L'
])
{
if
(
s
>
0
)
Bprint
(
&
bso
,
" lc+%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
else
Bprint
(
&
bso
,
" lc%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
}
lcsize
+=
5
;
continue
;
}
if
(
s
>
0
)
{
cput
(
0
+
s
);
/* 1-64 +lc */
if
(
debug
[
'L'
])
{
Bprint
(
&
bso
,
" lc+%ld(%ld)
\n
"
,
s
,
0
+
s
);
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
}
}
else
{
cput
(
64
-
s
);
/* 65-128 -lc */
if
(
debug
[
'L'
])
{
Bprint
(
&
bso
,
" lc%ld(%ld)
\n
"
,
s
,
64
-
s
);
Bprint
(
&
bso
,
"%6lux %P
\n
"
,
p
->
pc
,
p
);
}
}
lcsize
++
;
}
while
(
lcsize
&
1
)
{
s
=
129
;
cput
(
s
);
lcsize
++
;
}
if
(
debug
[
'v'
]
||
debug
[
'L'
])
Bprint
(
&
bso
,
"lcsize = %ld
\n
"
,
lcsize
);
Bflush
(
&
bso
);
}
int
prefixof
(
Adr
*
a
)
{
...
...
This diff is collapsed.
Click to expand it.
src/cmd/ld/lib.c
View file @
30edda69
// Derived from Inferno utils/6l/obj.c
// Derived from Inferno utils/6l/obj.c
and utils/6l/span.c
// http://code.google.com/p/inferno-os/source/browse/utils/6l/obj.c
// http://code.google.com/p/inferno-os/source/browse/utils/6l/span.c
//
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
...
...
@@ -933,3 +934,83 @@ ewrite(int fd, void *buf, int n)
errorexit
();
}
}
void
asmlc
(
void
)
{
vlong
oldpc
;
Prog
*
p
;
int32
oldlc
,
v
,
s
;
oldpc
=
INITTEXT
;
oldlc
=
0
;
for
(
p
=
firstp
;
p
!=
P
;
p
=
p
->
link
)
{
if
(
p
->
line
==
oldlc
||
p
->
as
==
ATEXT
||
p
->
as
==
ANOP
)
{
if
(
p
->
as
==
ATEXT
)
curtext
=
p
;
if
(
debug
[
'O'
])
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
continue
;
}
if
(
debug
[
'O'
])
Bprint
(
&
bso
,
"
\t\t
%6ld"
,
lcsize
);
v
=
(
p
->
pc
-
oldpc
)
/
MINLC
;
while
(
v
)
{
s
=
127
;
if
(
v
<
127
)
s
=
v
;
cput
(
s
+
128
);
/* 129-255 +pc */
if
(
debug
[
'O'
])
Bprint
(
&
bso
,
" pc+%ld*%d(%ld)"
,
s
,
MINLC
,
s
+
128
);
v
-=
s
;
lcsize
++
;
}
s
=
p
->
line
-
oldlc
;
oldlc
=
p
->
line
;
oldpc
=
p
->
pc
+
MINLC
;
if
(
s
>
64
||
s
<
-
64
)
{
cput
(
0
);
/* 0 vv +lc */
cput
(
s
>>
24
);
cput
(
s
>>
16
);
cput
(
s
>>
8
);
cput
(
s
);
if
(
debug
[
'O'
])
{
if
(
s
>
0
)
Bprint
(
&
bso
,
" lc+%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
else
Bprint
(
&
bso
,
" lc%ld(%d,%ld)
\n
"
,
s
,
0
,
s
);
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
}
lcsize
+=
5
;
continue
;
}
if
(
s
>
0
)
{
cput
(
0
+
s
);
/* 1-64 +lc */
if
(
debug
[
'O'
])
{
Bprint
(
&
bso
,
" lc+%ld(%ld)
\n
"
,
s
,
0
+
s
);
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
}
}
else
{
cput
(
64
-
s
);
/* 65-128 -lc */
if
(
debug
[
'O'
])
{
Bprint
(
&
bso
,
" lc%ld(%ld)
\n
"
,
s
,
64
-
s
);
Bprint
(
&
bso
,
"%6llux %P
\n
"
,
p
->
pc
,
p
);
}
}
lcsize
++
;
}
while
(
lcsize
&
1
)
{
s
=
129
;
cput
(
s
);
lcsize
++
;
}
if
(
debug
[
'v'
]
||
debug
[
'O'
])
Bprint
(
&
bso
,
"lcsize = %ld
\n
"
,
lcsize
);
Bflush
(
&
bso
);
}
This diff is collapsed.
Click to expand it.
src/cmd/ld/lib.h
View file @
30edda69
...
...
@@ -103,6 +103,7 @@ void addlibpath(char *srcref, char *objref, char *file, char *pkg);
Section
*
addsection
(
Segment
*
,
char
*
,
int
);
void
copyhistfrog
(
char
*
buf
,
int
nbuf
);
void
addhist
(
int32
line
,
int
type
);
void
asmlc
(
void
);
void
histtoauto
(
void
);
void
collapsefrog
(
Sym
*
s
);
Sym
*
lookup
(
char
*
symb
,
int
v
);
...
...
This diff is collapsed.
Click to expand it.
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