Zero BSS in hello world test
authorAnton Blanchard <anton@linux.ibm.com>
Wed, 8 Jun 2022 05:20:07 +0000 (15:20 +1000)
committerAnton Blanchard <anton@ozlabs.org>
Wed, 8 Jun 2022 05:20:07 +0000 (15:20 +1000)
While trying to reduce U/X state issues, I notice that our BSS is not
being initialised in the hello world test.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
hello_world/head.S
hello_world/hello_world.bin
hello_world/hello_world.elf
hello_world/hello_world.hex
hello_world/powerpc.lds

index 63576063f040c707d307a6c0ea4216e16f3f2da9..15f3494f7799637fc38deaefe1bb551903e0a186 100644 (file)
@@ -60,11 +60,25 @@ _start:
 
 .global boot_entry
 boot_entry:
+       LOAD_IMM64(%r10,__bss_start)
+       LOAD_IMM64(%r11,__bss_end)
+       subf    %r11,%r10,%r11
+       addi    %r11,%r11,63
+       srdi.   %r11,%r11,6
+       beq     2f
+       mtctr   %r11
+1:     dcbz    0,%r10
+       addi    %r10,%r10,64
+       bdnz    1b
+
        /* setup stack */
-       LOAD_IMM64(%r1, STACK_TOP - 0x100)
+2:     LOAD_IMM64(%r1,__stack_top)
+       li      %r0,0
+       stdu    %r0,-32(%r1)
        LOAD_IMM64(%r12, main)
-       mtctr   %r12,
+       mtctr   %r12
        bctrl
+       attn // terminate on exit
        b .
 
 #define EXCEPTION(nr)          \
index e4b14ca6f70843d9d43a149c8d18fb1f22072fe5..a4eb88c26f7c7742bc5d42c1d9c571302a03b69f 100755 (executable)
Binary files a/hello_world/hello_world.bin and b/hello_world/hello_world.bin differ
index 5eeedc452464d33864fa4a2deb5dd10f5eccbfd1..3dc0cc1c1cb753a5fe02cfa05c9860ff01c29675 100755 (executable)
Binary files a/hello_world/hello_world.elf and b/hello_world/hello_world.elf differ
index 763797e40515898838548e23915bda31144e8b57..c0161ad4a52e2cb5fbfb8748492ba9888575889a 100644 (file)
@@ -35,24 +35,24 @@ a64b5a7d14004a39
 a602487d05009f42
 a64b5a7d14004a39
 2402004ca64b7b7d
-3c20000048000004
+3d40000048000004
+794a07c6614a0000
+614a1900654a0000
+616b00003d600000
+656b0000796b07c6
+7d6a5850616b1980
+796bd183396b003f
+7d6903a641820014
+394a00407c0057ec
+3c2000004200fff8
 782107c660210000
-60211f0064210000
-618c00003d800000
-658c0000798c07c6
-7d8903a6618c1014
-480000004e800421
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
+6021398064210000
+f801ffe138000000
+3d8000007c1243a6
+798c07c6618c0000
+618c1000658c0000
+4e8004217d8903a6
+4800000000000200
 0000000000000000
 0000000000000000
 0000000000000000
@@ -510,150 +510,150 @@ a64b5a7d14004a39
 0000000000000000
 0000000000000000
 0000000000000000
-e8010010ebc1fff0
-7c0803a6ebe1fff8
-3c4000014e800020
-7c0802a638429800
-f8010010fbe1fff8
-480001edf821ffd1
-6000000060000000
-4800015538628000
-4800004960000000
-7c7f1b7860000000
-57ff063e5463063e
-60000000480000b9
-4082ffe02c1f000d
-480000a53860000a
-4bffffd060000000
-0100000000000000
-3c40000100000180
-6000000038429800
-6000000089228090
-2c09000039428088
-e92a000041820030
-7c0004ac39290014
-712900017d204eaa
-e86a00004182ffec
-7c601eaa7c0004ac
-4e8000205463063e
-39290010e92a0000
-7d204eea7c0004ac
-4082ffec71290001
-38630008e86a0000
-7c601eea7c0004ac
-000000004bffffd0
-0000000000000000
-384298003c400001
-8922809060000000
-3942808860000000
-4182002c2c090000
-39290014e92a0000
-7d204eaa7c0004ac
-4182ffec71290020
-7c0004ace92a0000
-4e8000207c604faa
-39290010e92a0000
-7d204eea7c0004ac
-4082ffec71290008
-e94a00005469063e
-7d2057ea7c0004ac
-000000004e800020
-0000000000000000
 384298003c400001
 fbe1fff87c0802a6
-3be3fffffbc1fff0
 f821ffd1f8010010
-2c3e00008fdf0001
-3821003040820010
-4bfffe4438600000
-4082000c281e000a
-4bffff453860000d
-4bffff3d7fc3f378
+60000000480001ed
+3862800060000000
+6000000048000155
+6000000048000049
+5463063e7c7f1b78
+480000b957ff063e
+2c1f000d60000000
+3860000a4082ffe0
+60000000480000a5
 000000004bffffd0
-0000028001000000
-386000007c691b78
-2c0a00007d4918ae
-386300014d820020
-000000004bfffff0
-0000000000000000
+0000018001000000
 384298003c400001
-614a00203d40c000
-7c0004ac794a0020
-3d20c0007d4056ea
-61290008794a0600
-7c0004ac79290020
-712900207d204eea
-3d20c00041820018
-7929002061290040
-7d204eea7c0004ac
-3d00c0007929f804
-6108200079290fc3
-6000000079080020
-3d00001cf9028088
-7d4a439261082000
-6000000041820084
-9922809039200001
-6108200c3d00c000
-790800203920ff80
-7d2047aa7c0004ac
-7c0004ace9228088
-e92280887d404faa
-39290004794ac202
-7d404faa7c0004ac
-39400003e9228088
-7c0004ac3929000c
-e92280887d404faa
+8922810860000000
+3942810060000000
+418200302c090000
+39290014e92a0000
+7d204eaa7c0004ac
+4182ffec71290001
+7c0004ace86a0000
+5463063e7c601eaa
+e92a00004e800020
 7c0004ac39290010
-e92280887d404faa
-3929000839400007
-7d404faa7c0004ac
-600000004e800020
-99228090394affff
-612920183d20c000
-7c0004ac79290020
-4e8000207d404fea
+712900017d204eea
+e86a00004082ffec
+7c0004ac38630008
+4bffffd07c601eea
 0000000000000000
 3c40000100000000
 6000000038429800
-2c24000089228090
-600000002f890000
-419e0030e9228088
-3940000241820024
-418200082c230000
-39290004614a0001
+6000000089228108
+2c09000039428100
+e92a00004182002c
+7c0004ac39290014
+712900207d204eaa
+e92a00004182ffec
+7c604faa7c0004ac
+e92a00004e800020
+7c0004ac39290010
+712900087d204eea
+5469063e4082ffec
+7c0004ace94a0000
+4e8000207d2057ea
+0000000000000000
+3c40000100000000
+7c0802a638429800
+fbc1fff0fbe1fff8
+f80100103be3ffff
+8fdf0001f821ffd1
+408200102c3e0000
+3860000038210030
+281e000a480001e8
+3860000d4082000c
+7fc3f3784bffff45
+4bffffd04bffff3d
+0100000000000000
+7c691b7800000280
+7d4918ae38600000
+4d8200202c0a0000
+4bfffff038630001
+0000000000000000
+3c40000100000000
+3d40c00038429800
+794a0020614a0020
+7d4056ea7c0004ac
+794a06003d20c000
+7929002061290008
+7d204eea7c0004ac
+4182001871290020
+612900403d20c000
+7c0004ac79290020
+7929f8047d204eea
+79290fc33d00c000
+7908002061082000
+f902810060000000
+610820003d00001c
+418200847d4a4392
+3920000160000000
+3d00c00099228108
+3920ff806108200c
+7c0004ac79080020
+e92281007d2047aa
 7d404faa7c0004ac
-394000004e800020
-418200084bffffe0
+794ac202e9228100
+7c0004ac39290004
+e92281007d404faa
+3929000c39400003
+7d404faa7c0004ac
+39290010e9228100
+7d404faa7c0004ac
+39400007e9228100
+7c0004ac39290008
+4e8000207d404faa
+394affff60000000
+3d20c00099228108
+7929002061292018
+7d404fea7c0004ac
+000000004e800020
+0000000000000000
+384298003c400001
+8922810860000000
+600000002c090000
+41820024e9228100
+78840e282c230000
+6084000141820008
+7c0004ac39290004
+4e8000207c804faa
+418200082c240000
 3929002060630002
 7c604fea7c0004ac
 000000004e800020
 0000000000000000
-0000000000000010
-0141780400527a01
-0000001800010c1b
-fffffc4800000018
-300e460000000070
-000000019f7e4111
-0000000000000010
-0141780400527a01
-0000001000010c1b
-fffffc8800000018
-0000000000000084
-0000002c00000010
-00000080fffffcf8
-0000002800000000
-fffffd6400000040
-4109450000000060
-300e43029e019f00
-42000e0a447e4111
-0000000b4106dedf
-0000006c00000010
-00000028fffffd98
+e8010010ebc1fff0
+7c0803a6ebe1fff8
+000000104e800020
+00527a0100000000
+00010c1b01417804
+0000001800000018
+00000070fffffc40
+9f7e4111300e4600
+0000001000000001
+00527a0100000000
+00010c1b01417804
+0000001800000010
+00000084fffffc80
+0000001000000000
+fffffcf00000002c
+0000000000000080
+0000004000000028
+00000060fffffd5c
+9e019f0041094500
+447e4111300e4302
+4106dedf42000e0a
+000000100000000b
+fffffd900000006c
+0000000000000028
+0000008000000010
+0000012cfffffda4
 0000001000000000
-fffffdac00000080
-000000000000012c
-0000009400000010
-00000074fffffec4
+fffffebc00000094
+0000000000000068
+0000000000000000
 0000000000000000
 0000000000000000
 0000000000000000
index 96bc6b9b16120335e73f6e90c29b3573d2c55e59..1e218c7a431debd3cbd4f1f8bed6392ce288e882 100644 (file)
@@ -1,13 +1,27 @@
 SECTIONS
 {
-       _start = .;
        . = 0;
+       _start = .;
        .head : {
                KEEP(*(.head))
-       }
+       }
        . = 0x1000;
-       .text : { *(.text) }
+       .text : { *(.text) *(.text.*) *(.rodata) *(.rodata.*) }
        . = 0x1800;
-       .data : { *(.data) }
-       .bss : { *(.bss) }
+       .data : { *(.data) *(.data.*) *(.got) *(.toc) }
+       . = ALIGN(0x80);
+       __bss_start = .;
+       .bss : {
+               *(.dynsbss)
+               *(.sbss)
+               *(.scommon)
+               *(.dynbss)
+               *(.bss)
+               *(.common)
+               *(.bss.*)
+       }
+       . = ALIGN(0x80);
+       __bss_end = .;
+       . = . + 0x2000;
+       __stack_top = .;
 }