From 36c62e1d1fbd560ac1ea78dd8b31f4c63cea2d72 Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 22 Sep 2010 21:46:22 +0000 Subject: [PATCH] Set symbol versions and fix symbol visibility. Add some extra space for future extensibility. Don't crash when doing dynamic stack allocation before a stack split. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/split@164538 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/libgcc-std.ver | 8 +++++ libgcc/config/i386/morestack.S | 5 +++- libgcc/generic-morestack.c | 68 +++++++++++++++++++++++++++++------------- 3 files changed, 59 insertions(+), 22 deletions(-) diff --git a/gcc/libgcc-std.ver b/gcc/libgcc-std.ver index 1f24f1771e8..e3ea30e228b 100644 --- a/gcc/libgcc-std.ver +++ b/gcc/libgcc-std.ver @@ -1915,3 +1915,11 @@ GCC_4.5.0 { %inherit GCC_4.6.0 GCC_4.5.0 GCC_4.6.0 { } + +%inherit GCC_4.6.0 GCC_4.4.0 +GCC_4.6.0 { + __morestack_segments + __morestack_current_segment + __morestack_initial_sp + __splitstack_find +} diff --git a/libgcc/config/i386/morestack.S b/libgcc/config/i386/morestack.S index 0022ef75847..79abba3ead1 100644 --- a/libgcc/config/i386/morestack.S +++ b/libgcc/config/i386/morestack.S @@ -89,6 +89,7 @@ # requested stack space by 16K. .global __morestack_non_split + .hidden __morestack_non_split #ifdef __ELF__ .type __morestack_non_split,@function @@ -112,6 +113,7 @@ __morestack_non_split: # The __morestack function. .global __morestack + .hidden __morestack #ifdef __ELF__ .type __morestack,@function @@ -466,7 +468,7 @@ __morestack: .LLSDACSE1: - .globl __gcc_personality_v0 + .global __gcc_personality_v0 #ifdef __PIC__ # Build a position independent reference to the basic # personality function. @@ -493,6 +495,7 @@ DW.ref.__gcc_personality_v0: .text .global __stack_split_initialize + .hidden __stack_split_initialize #ifdef __ELF__ .type __stack_split_initialize, @function diff --git a/libgcc/generic-morestack.c b/libgcc/generic-morestack.c index 7f96f04c1cb..f6bcb73a84e 100644 --- a/libgcc/generic-morestack.c +++ b/libgcc/generic-morestack.c @@ -50,10 +50,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -fsplit-stack. */ /* Declare functions to avoid warnings--there is no header file for - these internal functions. We give these functions the flatten - attribute in order to minimize their stack usage--here we must - minimize stack usage even at the cost of code size, and in general - inlining everything will do that. */ + these internal functions. We give most of these functions the + flatten attribute in order to minimize their stack usage--here we + must minimize stack usage even at the cost of code size, and in + general inlining everything will do that. */ extern void __generic_morestack_set_initial_sp (void *sp, size_t len) @@ -75,17 +75,21 @@ extern void __morestack_unblock_signals (void) __attribute__ ((no_split_stack, flatten, visibility ("hidden"))); -extern void * -__morestack_allocate_stack_space (size_t) - __attribute__ ((visibility ("default"))); - extern size_t __generic_findstack (void *stack) __attribute__ ((no_split_stack, flatten, visibility ("hidden"))); extern void __morestack_load_mmap (void) - __attribute__ ((no_split_stack)); + __attribute__ ((no_split_stack, visibility ("hidden"))); + +extern void * +__morestack_allocate_stack_space (size_t size) + __attribute__ ((visibility ("hidden"))); + +/* This is a function which -fsplit-stack code can call to get a list + of the stacks. Since it is not called only by the compiler, it is + not hidden. */ extern void * __splitstack_find (void *, void *, size_t *, void **, void **, void **) @@ -113,6 +117,28 @@ struct stack_segment struct dynamic_allocation_blocks *dynamic_allocation; /* A list of dynamic memory blocks no longer needed. */ struct dynamic_allocation_blocks *free_dynamic_allocation; + /* An extra pointer in case we need some more information some + day. */ + void *extra; +}; + +/* This structure holds the (approximate) initial stack pointer and + size for the system supplied stack for a thread. This is set when + the thread is created. We also store a sigset_t here to hold the + signal mask while splitting the stack, since we don't want to store + that on the stack. */ + +struct initial_sp +{ + /* The initial stack pointer. */ + void *sp; + /* The stack length. */ + size_t len; + /* A signal mask, put here so that the thread can use it without + needing stack space. */ + sigset_t mask; + /* Some extra space for later extensibility. */ + void *extra[5]; }; /* A list of memory blocks allocated by dynamic stack allocation. @@ -129,6 +155,16 @@ struct dynamic_allocation_blocks void *block; }; +/* These thread local global variables must be shared by all split + stack code across shared library boundaries. Therefore, they have + default visibility. They have extensibility fields if needed for + new versions. If more radical changes are needed, new code can be + written using new variable names, while still using the existing + variables in a backward compatible manner. Symbol versioning is + also used, although, since these variables are only referenced by + code in this file and generic-morestack-thread.c, it is likely that + simply using new names will suffice. */ + /* The first stack segment allocated for this thread. */ __thread struct stack_segment *__morestack_segments @@ -142,18 +178,7 @@ __thread struct stack_segment *__morestack_segments __thread struct stack_segment *__morestack_current_segment __attribute__ ((visibility ("default"))); -/* The (approximate) initial stack pointer and size for this thread on - the system supplied stack. This is set when the thread is created. - We also store a sigset_t here to hold the signal mask while - splitting the stack, since we don't want to store that on the - stack. */ - -struct initial_sp -{ - void *sp; - size_t len; - sigset_t mask; -}; +/* The initial stack pointer and size for this thread. */ __thread struct initial_sp __morestack_initial_sp __attribute__ ((visibility ("default"))); @@ -318,6 +343,7 @@ allocate_segment (size_t frame_size) pss->size = allocate - overhead; pss->dynamic_allocation = NULL; pss->free_dynamic_allocation = NULL; + pss->extra = NULL; if (__morestack_current_segment != NULL) __morestack_current_segment->next = pss; -- 2.11.4.GIT