Moved global variables from .text section to .bss in ppc/linux startup code, improves position independency

git-svn-id: trunk@16210 -
This commit is contained in:
tom_at_work 2010-10-23 20:07:36 +00:00
parent e787e263c8
commit 7f9dedec99
2 changed files with 67 additions and 44 deletions

View File

@ -74,8 +74,8 @@ main_stub:
lis 11, operatingsystem_parameter_envp@ha
stw 5, operatingsystem_parameter_envp@l(11);
lis 11,__stkptr@ha
stw 1,__stkptr@l(11);
lis 11,__stkptr@ha
stw 1,__stkptr@l(11);
lis 11, ___fpc_ret@ha
stw 1, ___fpc_ret@l(11)
@ -110,11 +110,22 @@ data_start:
___fpc_ret: /* return address to libc */
.long 0
.text
.comm __stkptr, 4
.section ".bss"
.type __stkptr, @object
.size __stkptr, 8
.global __stkptr
__stkptr:
.skip 4
.comm operatingsystem_parameter_envp, 4
.comm operatingsystem_parameter_argc, 4
.comm operatingsystem_parameter_argv, 4
.type operatingsystem_parameters, @object
.size operatingsystem_parameters, 12
operatingsystem_parameters:
.skip 3 * 4
.global operatingsystem_parameter_argc
.global operatingsystem_parameter_argv
.global operatingsystem_parameter_envp
.set operatingsystem_parameter_argc, operatingsystem_parameters+0
.set operatingsystem_parameter_argv, operatingsystem_parameters+4
.set operatingsystem_parameter_envp, operatingsystem_parameters+8
.section .note.GNU-stack,"",%progbits

View File

@ -17,55 +17,67 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
.section ".text"
.globl _start
.section ".text"
.globl _start
_start:
mr 26,1
/* Set up an initial stack frame, and clear the LR. */
clrrwi 1,1,4
li 0,0
stwu 1,-16(1)
mtlr 0
stw 0,0(1)
lwz 3,0(26) /* get argc */
lis 11,operatingsystem_parameter_argc@ha
stw 3,operatingsystem_parameter_argc@l(11);
mr 26,1
/* Set up an initial stack frame, and clear the LR. */
clrrwi 1,1,4
li 0,0
stwu 1,-16(1)
mtlr 0
stw 0,0(1)
lwz 3,0(26) /* get argc */
lis 11,operatingsystem_parameter_argc@ha
stw 3,operatingsystem_parameter_argc@l(11);
addi 4,26,4 /* get argv */
lis 11,operatingsystem_parameter_argv@ha
stw 4,operatingsystem_parameter_argv@l(11);
addi 4,26,4 /* get argv */
lis 11,operatingsystem_parameter_argv@ha
stw 4,operatingsystem_parameter_argv@l(11);
addi 27,3,1 /* calculate argc + 1 into r27 */
slwi 27,27,2 /* calculate (argc + 1) * sizeof(char *) into r27 */
add 5,4,27 /* get address of env[0] */
lis 11,operatingsystem_parameter_envp@ha
stw 5,operatingsystem_parameter_envp@l(11);
addi 27,3,1 /* calculate argc + 1 into r27 */
slwi 27,27,2 /* calculate (argc + 1) * sizeof(char *) into r27 */
add 5,4,27 /* get address of env[0] */
lis 11,operatingsystem_parameter_envp@ha
stw 5,operatingsystem_parameter_envp@l(11);
lis 11,__stkptr@ha
stw 1,__stkptr@l(11);
lis 11,__stkptr@ha
stw 1,__stkptr@l(11);
bl PASCALMAIN
bl PASCALMAIN
b _haltproc
b _haltproc
.globl _haltproc
.type _haltproc,@function
.globl _haltproc
.type _haltproc,@function
_haltproc:
li 0,1 /* exit call */
sc
b _haltproc
li 0,1 /* exit call */
sc
b _haltproc
/* Define a symbol for the first piece of initialized data. */
.section ".data"
.globl __data_start
/* Define a symbol for the first piece of initialized data. */
.section ".data"
.globl __data_start
__data_start:
data_start:
.text
.comm __stkptr,4
.section ".bss"
.comm operatingsystem_parameter_envp,4
.comm operatingsystem_parameter_argc,4
.comm operatingsystem_parameter_argv,4
.type __stkptr, @object
.size __stkptr, 4
.global __stkptr
__stkptr:
.skip 4
.type operatingsystem_parameters, @object
.size operatingsystem_parameters, 12
operatingsystem_parameters:
.skip 3 * 4
.global operatingsystem_parameter_argc
.global operatingsystem_parameter_argv
.global operatingsystem_parameter_envp
.set operatingsystem_parameter_argc, operatingsystem_parameters+0
.set operatingsystem_parameter_argv, operatingsystem_parameters+4
.set operatingsystem_parameter_envp, operatingsystem_parameters+8
.section .note.GNU-stack,"",%progbits