| ... | ... | @@ -7,7 +7,10 @@ const R_AMD64_RELATIVE = 8; |
| 7 | 7 | const R_386_RELATIVE = 8; |
| 8 | 8 | const R_ARM_RELATIVE = 23; |
| 9 | 9 | const R_AARCH64_RELATIVE = 1027; |
| 10 | const R_LARCH_RELATIVE = 3; |
| 11 | const R_68K_RELATIVE = 22; |
| 10 | 12 | const R_RISCV_RELATIVE = 3; |
| 13 | const R_390_RELATIVE = 12; |
| 11 | 14 | const R_SPARC_RELATIVE = 22; |
| 12 | 15 | |
| 13 | 16 | const R_RELATIVE = switch (builtin.cpu.arch) { |
| ... | ... | @@ -15,7 +18,10 @@ const R_RELATIVE = switch (builtin.cpu.arch) { |
| 15 | 18 | .x86_64 => R_AMD64_RELATIVE, |
| 16 | 19 | .arm => R_ARM_RELATIVE, |
| 17 | 20 | .aarch64 => R_AARCH64_RELATIVE, |
| 21 | .loongarch32, .loongarch64 => R_LARCH_RELATIVE, |
| 22 | .m68k => R_68K_RELATIVE, |
| 18 | 23 | .riscv64 => R_RISCV_RELATIVE, |
| 24 | .s390x => R_390_RELATIVE, |
| 19 | 25 | else => @compileError("Missing R_RELATIVE definition for this target"), |
| 20 | 26 | }; |
| 21 | 27 | |
| ... | ... | @@ -57,12 +63,37 @@ fn getDynamicSymbol() [*]elf.Dyn { |
| 57 | 63 | \\ add %[ret], %[ret], #:lo12:_DYNAMIC |
| 58 | 64 | : [ret] "=r" (-> [*]elf.Dyn), |
| 59 | 65 | ), |
| 66 | .loongarch32, .loongarch64 => asm volatile ( |
| 67 | \\ .weak _DYNAMIC |
| 68 | \\ .hidden _DYNAMIC |
| 69 | \\ la.local %[ret], _DYNAMIC |
| 70 | : [ret] "=r" (-> [*]elf.Dyn), |
| 71 | ), |
| 72 | // Note that the - 8 is needed because pc in the second lea instruction points into the |
| 73 | // middle of that instruction. (The first lea is 6 bytes, the second is 4 bytes.) |
| 74 | .m68k => asm volatile ( |
| 75 | \\ .weak _DYNAMIC |
| 76 | \\ .hidden _DYNAMIC |
| 77 | \\ lea _DYNAMIC - . - 8, %[ret] |
| 78 | \\ lea (%[ret], %%pc), %[ret] |
| 79 | : [ret] "=r" (-> [*]elf.Dyn), |
| 80 | ), |
| 60 | 81 | .riscv64 => asm volatile ( |
| 61 | 82 | \\ .weak _DYNAMIC |
| 62 | 83 | \\ .hidden _DYNAMIC |
| 63 | 84 | \\ lla %[ret], _DYNAMIC |
| 64 | 85 | : [ret] "=r" (-> [*]elf.Dyn), |
| 65 | 86 | ), |
| 87 | .s390x => asm volatile ( |
| 88 | \\ .weak _DYNAMIC |
| 89 | \\ .hidden _DYNAMIC |
| 90 | \\ larl %[ret], 1f |
| 91 | \\ agf %[ret], 0(%[ret]) |
| 92 | \\ b 2f |
| 93 | \\ 1: .long _DYNAMIC - . |
| 94 | \\ 2: |
| 95 | : [ret] "=r" (-> [*]elf.Dyn), |
| 96 | ), |
| 66 | 97 | else => { |
| 67 | 98 | @compileError("PIE startup is not yet supported for this target!"); |
| 68 | 99 | }, |