authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-25 01:31:42+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-30 01:26:09+02:00
log5633767b20b1e2c9a650bdf6045c260ec4ce42ef
treecfdcf0e162f2abd615672849023d3bda4a14fc93
parentadfbd8a98b2525dbd5fa9891968794f7ace31cd6
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux.start_pie: Add powerpc and powerpc64 support.

Closes #20305.

1 files changed, 28 insertions(+), 0 deletions(-)

lib/std/os/linux/start_pie.zig+28
......@@ -13,6 +13,7 @@ const R_HEXAGON_RELATIVE = 35;
1313const R_LARCH_RELATIVE = 3;
1414const R_68K_RELATIVE = 22;
1515const R_MIPS_RELATIVE = 128;
16const R_PPC_RELATIVE = 22;
1617const R_RISCV_RELATIVE = 3;
1718const R_390_RELATIVE = 12;
1819const R_SPARC_RELATIVE = 22;
......@@ -28,6 +29,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
2829 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
2930 .m68k => R_68K_RELATIVE,
3031 .mips, .mipsel, .mips64, .mips64el => R_MIPS_RELATIVE,
32 .powerpc, .powerpcle, .powerpc64, .powerpc64le => R_PPC_RELATIVE,
3133 .riscv32, .riscv64 => R_RISCV_RELATIVE,
3234 .s390x => R_390_RELATIVE,
3335 else => @compileError("Missing R_RELATIVE definition for this target"),
......@@ -138,6 +140,32 @@ fn getDynamicSymbol() [*]elf.Dyn {
138140 :
139141 : "lr"
140142 ),
143 .powerpc, .powerpcle => asm volatile (
144 \\ .weak _DYNAMIC
145 \\ .hidden _DYNAMIC
146 \\ bl 1f
147 \\ .long _DYNAMIC - .
148 \\ 1:
149 \\ mflr %[ret]
150 \\ lwz 4, 0(%[ret])
151 \\ add %[ret], 4, %[ret]
152 : [ret] "=r" (-> [*]elf.Dyn),
153 :
154 : "lr", "r4"
155 ),
156 .powerpc64, .powerpc64le => asm volatile (
157 \\ .weak _DYNAMIC
158 \\ .hidden _DYNAMIC
159 \\ bl 1f
160 \\ .quad _DYNAMIC - .
161 \\ 1:
162 \\ mflr %[ret]
163 \\ ld 4, 0(%[ret])
164 \\ add %[ret], 4, %[ret]
165 : [ret] "=r" (-> [*]elf.Dyn),
166 :
167 : "lr", "r4"
168 ),
141169 .riscv32, .riscv64 => asm volatile (
142170 \\ .weak _DYNAMIC
143171 \\ .hidden _DYNAMIC