Commit a83cc09f by Michael Meissner

Support for .sdata/.sbss/.sdata2/.sbss2

From-SVN: r10968
parent 3c0f5ae6
...@@ -50,27 +50,50 @@ __GOT_START__: ...@@ -50,27 +50,50 @@ __GOT_START__:
_GLOBAL_OFFSET_TABLE_: _GLOBAL_OFFSET_TABLE_:
_SDA_BASE_: _SDA_BASE_:
.section ".got1","w" .section ".got1","aw"
.globl __GOT1_START__ .globl __GOT1_START__
.type __GOT1_START__,@object .type __GOT1_START__,@object
__GOT1_START__: __GOT1_START__:
.section ".got2","w" .section ".got2","aw"
.globl __GOT2_START__ .globl __GOT2_START__
.type __GOT2_START__,@object .type __GOT2_START__,@object
__GOT2_START__: __GOT2_START__:
.section ".fixup","w" .section ".fixup","aw"
.globl __FIXUP_START__ .globl __FIXUP_START__
.type __FIXUP_START__,@object .type __FIXUP_START__,@object
__FIXUP_START__: __FIXUP_START__:
.section ".ctors","w" .section ".ctors","aw"
.globl __CTOR_LIST__ .globl __CTOR_LIST__
.type __CTOR_LIST__,@object .type __CTOR_LIST__,@object
__CTOR_LIST__: __CTOR_LIST__:
.section ".dtors","w" .section ".dtors","aw"
.globl __DTOR_LIST__ .globl __DTOR_LIST__
.type __DTOR_LIST__,@object .type __DTOR_LIST__,@object
__DTOR_LIST__: __DTOR_LIST__:
.section ".sdata","aw"
.globl __SDATA_START__
.type __SDATA_START__,@object
__SDATA_START__:
.section ".sbss","aw"
.globl __SBSS_START__
.type __SBSS_START__,@object
__SBSS_START__:
.section ".sdata2","aw"
.globl _SDA2_BASE_
.type _SDA2_BASE_,@object
.globl __SDATA2_START__
.type __SDATA2_START__,@object
__SDATA2_START__:
_SDA2_BASE_ = .+32768
.section ".sbss2","aw"
.globl __SBSS2_START__
.type __SBSS2_START__,@object
__SBSS2_START__:
...@@ -39,32 +39,59 @@ ...@@ -39,32 +39,59 @@
.file "crtn.s" .file "crtn.s"
.ident "GNU C crtn.s" .ident "GNU C crtn.s"
.section ".got","w" .section ".got","aw"
.globl __GOT_END__ .globl __GOT_END__
.type __GOT_END__,@object .type __GOT_END__,@object
__GOT_END__: __GOT_END__:
.section ".got1","w" .section ".got1","aw"
.globl __GOT1_END__ .globl __GOT1_END__
.type __GOT1_END__,@object .type __GOT1_END__,@object
__GOT1_END__: __GOT1_END__:
.section ".got2","w" .section ".got2","aw"
.globl __GOT2_END__ .globl __GOT2_END__
.type __GOT2_END__,@object .type __GOT2_END__,@object
__GOT2_END__: __GOT2_END__:
.section ".fixup","w" .section ".fixup","aw"
.globl __FIXUP_END__ .globl __FIXUP_END__
.type __FIXUP_END__,@object .type __FIXUP_END__,@object
__FIXUP_END__: __FIXUP_END__:
.section ".ctors","w" .section ".ctors","aw"
.globl __CTOR_END__ .globl __CTOR_END__
.type __CTOR_END__,@object .type __CTOR_END__,@object
__CTOR_END__: __CTOR_END__:
.section ".dtors","w" .section ".dtors","aw"
.globl __DTOR_END__ .globl __DTOR_END__
.type __DTOR_END__,@object .type __DTOR_END__,@object
__DTOR_END__: __DTOR_END__:
# Put a blrl instruction in the special .got.blrl section, which
# the GNU linker puts at _GLOBAL_OFFSET_TABLE-4, so that a program
# can find the _GLOBAL_OFFSET_TABLE_ address in a painless fashion.
.section ".got.blrl","awx"
blrl
.section ".sdata","aw"
.globl __SDATA_END__
.type __SDATA_END__,@object
__SDATA_END__:
.section ".sbss","aw"
.globl __SBSS_END__
.type __SBSS_END__,@object
__SBSS_END__:
.section ".sdata2","aw"
.globl __SDATA2_END__
.type __SDATA2_END__,@object
__SDATA2_END__:
.section ".sbss2","aw"
.globl __SBSS2_END__
.type __SBSS2_END__,@object
__SBSS2_END__:
...@@ -48,14 +48,23 @@ ...@@ -48,14 +48,23 @@
.Ltable = .-.LCTOC1 .Ltable = .-.LCTOC1
.long .LCTOC1 /* address we are really at */ .long .LCTOC1 /* address we are really at */
.Lgot = .-.LCTOC1 .Lsda = .-.LCTOC1
.long _GLOBAL_OFFSET_TABLE_ /* normal GOT address */ .long _SDA_BASE_ /* address of the first small data area */
.Lgots = .-.LCTOC1 .Lsdas = .-.LCTOC1
.long __GOT_START__ /* start of .got section */ .long __SDATA_START__ /* start of .sdata/.sbss section */
.Lgote = .-.LCTOC1 .Lsdae = .-.LCTOC1
.long __GOT_END__ /* end of .got section */ .long __SBSS_END__ /* end of .sdata/.sbss section */
.Lsda2 = .-.LCTOC1
.long _SDA2_BASE_ /* address of the second small data area */
.Lsda2s = .-.LCTOC1
.long __SDATA2_START__ /* start of .sdata2/.sbss2 section */
.Lsda2e = .-.LCTOC1
.long __SBSS2_END__ /* end of .sdata2/.sbss2 section */
.Lgot2s = .-.LCTOC1 .Lgot2s = .-.LCTOC1
.long __GOT2_START__ /* -mrelocatable GOT pointers start */ .long __GOT2_START__ /* -mrelocatable GOT pointers start */
...@@ -110,20 +119,27 @@ FUNC_START(__eabi) ...@@ -110,20 +119,27 @@ FUNC_START(__eabi)
stwx 1,10,12 /* store a non-zero value in the done flag */ stwx 1,10,12 /* store a non-zero value in the done flag */
bne 0,.Lreloc /* skip if we need to relocate */ bne 0,.Lreloc /* skip if we need to relocate */
/* Only load up register 2 if there is a .got section */ /* Only load up register 13 if there is a .sdata and/or .sbss section */
lwz 3,.Lgots(11) /* start of .got section */ lwz 3,.Lsdas(11) /* start of .sdata/.sbss section */
lwz 4,.Lgote(11) /* end of .got section */ lwz 4,.Lsdae(11) /* end of .sdata/.sbss section */
cmpw 1,3,4 /* .got section non-empty? */ cmpw 1,3,4 /* .sdata/.sbss section non-empty? */
bc 12,6,.Ldone beq 1,.Lsda2l /* skip loading r13 */
lwz 13,.Lsda(11) /* load r13 with _SDA_BASE address */
/* Only load up register 2 if there is a .sdata2 and/or .sbss2 section */
/* Normal program, load up register 2 */ .Lsda2l:
lwz 3,.Lsda2s(11) /* start of .sdata/.sbss section */
lwz 4,.Lsda2e(11) /* end of .sdata/.sbss section */
cmpw 1,3,4 /* .sdata/.sbss section non-empty? */
beq 1,.Ldone /* skip loading r2 */
lwz 2,.Lgot(11) /* normal GOT address (obsolete in register 2) */ lwz 2,.Lsda2(11) /* load r2 with _SDA2_BASE address */
mr 13,2 /* also same as _SDA_BASE_ (V.4 small data ptr) */
b FUNC_NAME(__do_global_ctors) /* do any C++ global constructors (which returns to caller) */ b FUNC_NAME(__do_global_ctors) /* do any C++ global constructors (which returns to caller) */
/* We need to relocate the .got2 pointers. Don't load register 2 */ /* We need to relocate the .got2 pointers. Don't load registers 2 or 13 */
.Lreloc: .Lreloc:
lwz 3,.Lgot2s(11) /* GOT pointers start */ lwz 3,.Lgot2s(11) /* GOT pointers start */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment