Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
a6dcb7d4
Commit
a6dcb7d4
authored
Dec 21, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runtime: Catch signals on altstack, disable splitstack signal blocking.
From-SVN: r182607
parent
e0d2f030
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
11 deletions
+47
-11
libgo/runtime/go-panic.c
+4
-4
libgo/runtime/go-signal.c
+0
-0
libgo/runtime/mem.c
+5
-5
libgo/runtime/proc.c
+21
-0
libgo/runtime/runtime.h
+16
-1
libgo/runtime/sigqueue.goc
+1
-1
No files found.
libgo/runtime/go-panic.c
View file @
a6dcb7d4
...
@@ -24,13 +24,13 @@ __printpanics (struct __go_panic_stack *p)
...
@@ -24,13 +24,13 @@ __printpanics (struct __go_panic_stack *p)
if
(
p
->
__next
!=
NULL
)
if
(
p
->
__next
!=
NULL
)
{
{
__printpanics
(
p
->
__next
);
__printpanics
(
p
->
__next
);
printf
(
"
\t
"
);
fprintf
(
stderr
,
"
\t
"
);
}
}
printf
(
"panic: "
);
fprintf
(
stderr
,
"panic: "
);
printany
(
p
->
__arg
);
printany
(
p
->
__arg
);
if
(
p
->
__was_recovered
)
if
(
p
->
__was_recovered
)
printf
(
" [recovered]"
);
fprintf
(
stderr
,
" [recovered]"
);
putchar
(
'\n'
);
fputc
(
'\n'
,
stderr
);
}
}
/* This implements __go_panic which is used for the panic
/* This implements __go_panic which is used for the panic
...
...
libgo/runtime/go-signal.c
View file @
a6dcb7d4
This diff is collapsed.
Click to expand it.
libgo/runtime/mem.c
View file @
a6dcb7d4
...
@@ -47,7 +47,7 @@ runtime_SysAlloc(uintptr n)
...
@@ -47,7 +47,7 @@ runtime_SysAlloc(uintptr n)
if
(
dev_zero
==
-
1
)
{
if
(
dev_zero
==
-
1
)
{
dev_zero
=
open
(
"/dev/zero"
,
O_RDONLY
);
dev_zero
=
open
(
"/dev/zero"
,
O_RDONLY
);
if
(
dev_zero
<
0
)
{
if
(
dev_zero
<
0
)
{
printf
(
"open /dev/zero: errno=%d
\n
"
,
errno
);
runtime_
printf
(
"open /dev/zero: errno=%d
\n
"
,
errno
);
exit
(
2
);
exit
(
2
);
}
}
}
}
...
@@ -57,8 +57,8 @@ runtime_SysAlloc(uintptr n)
...
@@ -57,8 +57,8 @@ runtime_SysAlloc(uintptr n)
p
=
runtime_mmap
(
nil
,
n
,
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
,
MAP_ANON
|
MAP_PRIVATE
,
fd
,
0
);
p
=
runtime_mmap
(
nil
,
n
,
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
,
MAP_ANON
|
MAP_PRIVATE
,
fd
,
0
);
if
(
p
==
MAP_FAILED
)
{
if
(
p
==
MAP_FAILED
)
{
if
(
errno
==
EACCES
)
{
if
(
errno
==
EACCES
)
{
printf
(
"runtime: mmap: access denied
\n
"
);
runtime_
printf
(
"runtime: mmap: access denied
\n
"
);
printf
(
"if you're running SELinux, enable execmem for this process.
\n
"
);
runtime_
printf
(
"if you're running SELinux, enable execmem for this process.
\n
"
);
exit
(
2
);
exit
(
2
);
}
}
return
nil
;
return
nil
;
...
@@ -97,7 +97,7 @@ runtime_SysReserve(void *v, uintptr n)
...
@@ -97,7 +97,7 @@ runtime_SysReserve(void *v, uintptr n)
if
(
dev_zero
==
-
1
)
{
if
(
dev_zero
==
-
1
)
{
dev_zero
=
open
(
"/dev/zero"
,
O_RDONLY
);
dev_zero
=
open
(
"/dev/zero"
,
O_RDONLY
);
if
(
dev_zero
<
0
)
{
if
(
dev_zero
<
0
)
{
printf
(
"open /dev/zero: errno=%d
\n
"
,
errno
);
runtime_
printf
(
"open /dev/zero: errno=%d
\n
"
,
errno
);
exit
(
2
);
exit
(
2
);
}
}
}
}
...
@@ -123,7 +123,7 @@ runtime_SysMap(void *v, uintptr n)
...
@@ -123,7 +123,7 @@ runtime_SysMap(void *v, uintptr n)
if
(
dev_zero
==
-
1
)
{
if
(
dev_zero
==
-
1
)
{
dev_zero
=
open
(
"/dev/zero"
,
O_RDONLY
);
dev_zero
=
open
(
"/dev/zero"
,
O_RDONLY
);
if
(
dev_zero
<
0
)
{
if
(
dev_zero
<
0
)
{
printf
(
"open /dev/zero: errno=%d
\n
"
,
errno
);
runtime_
printf
(
"open /dev/zero: errno=%d
\n
"
,
errno
);
exit
(
2
);
exit
(
2
);
}
}
}
}
...
...
libgo/runtime/proc.c
View file @
a6dcb7d4
...
@@ -29,6 +29,11 @@ extern void * __splitstack_resetcontext(void *context[10], size_t *);
...
@@ -29,6 +29,11 @@ extern void * __splitstack_resetcontext(void *context[10], size_t *);
extern
void
*
__splitstack_find
(
void
*
,
void
*
,
size_t
*
,
void
**
,
void
**
,
extern
void
*
__splitstack_find
(
void
*
,
void
*
,
size_t
*
,
void
**
,
void
**
,
void
**
);
void
**
);
extern
void
__splitstack_block_signals
(
int
*
,
int
*
);
extern
void
__splitstack_block_signals_context
(
void
*
context
[
10
],
int
*
,
int
*
);
#endif
#endif
#if defined(USING_SPLIT_STACK) && defined(LINKER_SUPPORTS_SPLIT_STACK)
#if defined(USING_SPLIT_STACK) && defined(LINKER_SUPPORTS_SPLIT_STACK)
...
@@ -862,6 +867,14 @@ runtime_mstart(void* mp)
...
@@ -862,6 +867,14 @@ runtime_mstart(void* mp)
*
(
int
*
)
0x21
=
0x21
;
*
(
int
*
)
0x21
=
0x21
;
}
}
runtime_minit
();
runtime_minit
();
#ifdef USING_SPLIT_STACK
{
int
dont_block_signals
=
0
;
__splitstack_block_signals
(
&
dont_block_signals
,
nil
);
}
#endif
schedule
(
nil
);
schedule
(
nil
);
return
nil
;
return
nil
;
}
}
...
@@ -1142,9 +1155,13 @@ runtime_malg(int32 stacksize, byte** ret_stack, size_t* ret_stacksize)
...
@@ -1142,9 +1155,13 @@ runtime_malg(int32 stacksize, byte** ret_stack, size_t* ret_stacksize)
newg
=
runtime_malloc
(
sizeof
(
G
));
newg
=
runtime_malloc
(
sizeof
(
G
));
if
(
stacksize
>=
0
)
{
if
(
stacksize
>=
0
)
{
#if USING_SPLIT_STACK
#if USING_SPLIT_STACK
int
dont_block_signals
=
0
;
*
ret_stack
=
__splitstack_makecontext
(
stacksize
,
*
ret_stack
=
__splitstack_makecontext
(
stacksize
,
&
newg
->
stack_context
[
0
],
&
newg
->
stack_context
[
0
],
ret_stacksize
);
ret_stacksize
);
__splitstack_block_signals_context
(
&
newg
->
stack_context
[
0
],
&
dont_block_signals
,
nil
);
#else
#else
*
ret_stack
=
runtime_mallocgc
(
stacksize
,
FlagNoProfiling
|
FlagNoGC
,
0
,
0
);
*
ret_stack
=
runtime_mallocgc
(
stacksize
,
FlagNoProfiling
|
FlagNoGC
,
0
,
0
);
*
ret_stacksize
=
stacksize
;
*
ret_stacksize
=
stacksize
;
...
@@ -1186,8 +1203,12 @@ __go_go(void (*fn)(void*), void* arg)
...
@@ -1186,8 +1203,12 @@ __go_go(void (*fn)(void*), void* arg)
if
((
newg
=
gfget
())
!=
nil
){
if
((
newg
=
gfget
())
!=
nil
){
#ifdef USING_SPLIT_STACK
#ifdef USING_SPLIT_STACK
int
dont_block_signals
=
0
;
sp
=
__splitstack_resetcontext
(
&
newg
->
stack_context
[
0
],
sp
=
__splitstack_resetcontext
(
&
newg
->
stack_context
[
0
],
&
spsize
);
&
spsize
);
__splitstack_block_signals_context
(
&
newg
->
stack_context
[
0
],
&
dont_block_signals
,
nil
);
#else
#else
sp
=
newg
->
gcinitial_sp
;
sp
=
newg
->
gcinitial_sp
;
spsize
=
newg
->
gcstack_size
;
spsize
=
newg
->
gcstack_size
;
...
...
libgo/runtime/runtime.h
View file @
a6dcb7d4
...
@@ -52,6 +52,7 @@ typedef struct G G;
...
@@ -52,6 +52,7 @@ typedef struct G G;
typedef
union
Lock
Lock
;
typedef
union
Lock
Lock
;
typedef
struct
M
M
;
typedef
struct
M
M
;
typedef
union
Note
Note
;
typedef
union
Note
Note
;
typedef
struct
SigTab
SigTab
;
typedef
struct
MCache
MCache
;
typedef
struct
MCache
MCache
;
typedef
struct
FixAlloc
FixAlloc
;
typedef
struct
FixAlloc
FixAlloc
;
typedef
struct
Hchan
Hchan
;
typedef
struct
Hchan
Hchan
;
...
@@ -179,6 +180,20 @@ struct M
...
@@ -179,6 +180,20 @@ struct M
uint32
waitsemalock
;
uint32
waitsemalock
;
};
};
struct
SigTab
{
int32
sig
;
int32
flags
;
};
enum
{
SigCatch
=
1
<<
0
,
SigIgnore
=
1
<<
1
,
SigRestart
=
1
<<
2
,
SigQueue
=
1
<<
3
,
SigPanic
=
1
<<
4
,
};
/* Macros. */
/* Macros. */
#ifdef __WINDOWS__
#ifdef __WINDOWS__
...
@@ -251,7 +266,7 @@ void runtime_args(int32, byte**);
...
@@ -251,7 +266,7 @@ void runtime_args(int32, byte**);
void
runtime_osinit
();
void
runtime_osinit
();
void
runtime_goargs
(
void
);
void
runtime_goargs
(
void
);
void
runtime_goenvs
(
void
);
void
runtime_goenvs
(
void
);
void
runtime_throw
(
const
char
*
);
void
runtime_throw
(
const
char
*
)
__attribute__
((
noreturn
))
;
void
runtime_panicstring
(
const
char
*
)
__attribute__
((
noreturn
));
void
runtime_panicstring
(
const
char
*
)
__attribute__
((
noreturn
));
void
*
runtime_mal
(
uintptr
);
void
*
runtime_mal
(
uintptr
);
void
runtime_schedinit
(
void
);
void
runtime_schedinit
(
void
);
...
...
libgo/runtime/sigqueue.goc
View file @
a6dcb7d4
...
@@ -110,6 +110,6 @@ func Signame(sig int32) (name String) {
...
@@ -110,6 +110,6 @@ func Signame(sig int32) (name String) {
}
}
func
Siginit
()
{
func
Siginit
()
{
runtime_initsig
(
1
);
runtime_initsig
(
SigQueue
);
sig
.
inuse
=
true
;
//
enable
reception
of
signals
;
cannot
disable
sig
.
inuse
=
true
;
//
enable
reception
of
signals
;
cannot
disable
}
}
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