std.os.linux.start_pie: Add m68k support.

This commit is contained in:
Alex Rønne Petersen 2024-07-21 16:56:52 +02:00
parent 1fd45766a7
commit 6fac71ec74
No known key found for this signature in database

View File

@ -8,6 +8,7 @@ const R_386_RELATIVE = 8;
const R_ARM_RELATIVE = 23; const R_ARM_RELATIVE = 23;
const R_AARCH64_RELATIVE = 1027; const R_AARCH64_RELATIVE = 1027;
const R_LARCH_RELATIVE = 3; const R_LARCH_RELATIVE = 3;
const R_68K_RELATIVE = 22;
const R_RISCV_RELATIVE = 3; const R_RISCV_RELATIVE = 3;
const R_SPARC_RELATIVE = 22; const R_SPARC_RELATIVE = 22;
@ -17,6 +18,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
.arm => R_ARM_RELATIVE, .arm => R_ARM_RELATIVE,
.aarch64 => R_AARCH64_RELATIVE, .aarch64 => R_AARCH64_RELATIVE,
.loongarch32, .loongarch64 => R_LARCH_RELATIVE, .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
.m68k => R_68K_RELATIVE,
.riscv64 => R_RISCV_RELATIVE, .riscv64 => R_RISCV_RELATIVE,
else => @compileError("Missing R_RELATIVE definition for this target"), else => @compileError("Missing R_RELATIVE definition for this target"),
}; };
@ -65,6 +67,15 @@ fn getDynamicSymbol() [*]elf.Dyn {
\\ la.local %[ret], _DYNAMIC \\ la.local %[ret], _DYNAMIC
: [ret] "=r" (-> [*]elf.Dyn), : [ret] "=r" (-> [*]elf.Dyn),
), ),
// Note that the - 8 is needed because pc in the second lea instruction points into the
// middle of that instruction. (The first lea is 6 bytes, the second is 4 bytes.)
.m68k => asm volatile (
\\ .weak _DYNAMIC
\\ .hidden _DYNAMIC
\\ lea _DYNAMIC - . - 8, %[ret]
\\ lea (%[ret], %%pc), %[ret]
: [ret] "=r" (-> [*]elf.Dyn),
),
.riscv64 => asm volatile ( .riscv64 => asm volatile (
\\ .weak _DYNAMIC \\ .weak _DYNAMIC
\\ .hidden _DYNAMIC \\ .hidden _DYNAMIC