Skip to content

Commit 94538d8

Browse files
committed
std.pie: add missing clobbers on alpha and sparc
Also format all the assembly code in the file.
1 parent 9ab7eec commit 94538d8

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

lib/std/pie.zig

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
5656
\\ .weak _DYNAMIC
5757
\\ .hidden _DYNAMIC
5858
\\ call 1f
59-
\\ 1: pop %[ret]
60-
\\ lea _DYNAMIC-1b(%[ret]), %[ret]
59+
\\1:
60+
\\ pop %[ret]
61+
\\ lea _DYNAMIC - 1b(%[ret]), %[ret]
6162
: [ret] "=r" (-> [*]const elf.Dyn),
6263
),
6364
.x86_64 => asm volatile (
@@ -79,8 +80,9 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
7980
\\ ldr %[ret], 1f
8081
\\ add %[ret], pc
8182
\\ b 2f
82-
\\ 1: .word _DYNAMIC-1b
83-
\\ 2:
83+
\\1:
84+
\\ .word _DYNAMIC-1b
85+
\\2:
8486
: [ret] "=r" (-> [*]const elf.Dyn),
8587
),
8688
// A simple `adr` is not enough as it has a limited offset range
@@ -99,7 +101,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
99101
\\ ldq %[ret], -0x8000($29)
100102
: [ret] "=r" (-> [*]const elf.Dyn),
101103
:
102-
: .{ .r26 = true }),
104+
: .{ .r26 = true, .r29 = true }),
103105
// The CSKY ABI requires the gb register to point to the GOT. Additionally, the first
104106
// entry in the GOT is defined to hold the address of _DYNAMIC.
105107
.csky => asm volatile (
@@ -112,7 +114,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
112114
\\ .hidden _DYNAMIC
113115
\\ jump 1f
114116
\\ .word _DYNAMIC - .
115-
\\ 1:
117+
\\1:
116118
\\ r1 = pc
117119
\\ r1 = add(r1, #-4)
118120
\\ %[ret] = memw(r1)
@@ -198,7 +200,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
198200
\\ .hidden _DYNAMIC
199201
\\ bl 1f
200202
\\ .long _DYNAMIC - .
201-
\\ 1:
203+
\\1:
202204
\\ mflr %[ret]
203205
\\ lwz 4, 0(%[ret])
204206
\\ add %[ret], 4, %[ret]
@@ -210,7 +212,7 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
210212
\\ .hidden _DYNAMIC
211213
\\ bl 1f
212214
\\ .quad _DYNAMIC - .
213-
\\ 1:
215+
\\1:
214216
\\ mflr %[ret]
215217
\\ ld 4, 0(%[ret])
216218
\\ add %[ret], 4, %[ret]
@@ -229,8 +231,9 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
229231
\\ larl %[ret], 1f
230232
\\ ag %[ret], 0(%[ret])
231233
\\ jg 2f
232-
\\ 1: .quad _DYNAMIC - .
233-
\\ 2:
234+
\\1:
235+
\\ .quad _DYNAMIC - .
236+
\\2:
234237
: [ret] "=a" (-> [*]const elf.Dyn),
235238
),
236239
.sh, .sheb => asm volatile (
@@ -252,11 +255,12 @@ inline fn getDynamicSymbol() [*]const elf.Dyn {
252255
.sparc, .sparc64 => asm volatile (
253256
\\ sethi %%hi(_GLOBAL_OFFSET_TABLE_ - 4), %%l7
254257
\\ call 1f
255-
\\ add %%l7, %%lo(_GLOBAL_OFFSET_TABLE_ + 4), %%l7
256-
\\ 1:
258+
\\ add %%l7, %%lo(_GLOBAL_OFFSET_TABLE_ + 4), %%l7
259+
\\1:
257260
\\ add %%l7, %%o7, %[ret]
258261
: [ret] "=r" (-> [*]const elf.Dyn),
259-
),
262+
:
263+
: .{ .l7 = true }),
260264
else => {
261265
@compileError("PIE startup is not yet supported for this target!");
262266
},

0 commit comments

Comments
 (0)