| ... | @@ -22,6 +22,7 @@ const R_RISCV_RELATIVE = 3; | ... | @@ -22,6 +22,7 @@ const R_RISCV_RELATIVE = 3; |
| 22 | const R_390_RELATIVE = 12; | 22 | const R_390_RELATIVE = 12; |
| 23 | const R_SH_RELATIVE = 165; | 23 | const R_SH_RELATIVE = 165; |
| 24 | const R_SPARC_RELATIVE = 22; | 24 | const R_SPARC_RELATIVE = 22; |
| | 25 | const R_XTENSA_RELATIVE = 5; |
| 25 | | 26 | |
| 26 | const R_RELATIVE = switch (builtin.cpu.arch) { | 27 | const R_RELATIVE = switch (builtin.cpu.arch) { |
| 27 | .x86 => R_386_RELATIVE, | 28 | .x86 => R_386_RELATIVE, |
| ... | @@ -43,6 +44,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) { | ... | @@ -43,6 +44,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) { |
| 43 | .s390x => R_390_RELATIVE, | 44 | .s390x => R_390_RELATIVE, |
| 44 | .sh, .sheb => R_SH_RELATIVE, | 45 | .sh, .sheb => R_SH_RELATIVE, |
| 45 | .sparc, .sparc64 => R_SPARC_RELATIVE, | 46 | .sparc, .sparc64 => R_SPARC_RELATIVE, |
| | 47 | .xtensa, .xtensaeb => R_XTENSA_RELATIVE, |
| 46 | else => @compileError("Missing R_RELATIVE definition for this target"), | 48 | else => @compileError("Missing R_RELATIVE definition for this target"), |
| 47 | }; | 49 | }; |
| 48 | | 50 | |
| ... | @@ -261,6 +263,25 @@ inline fn getDynamicSymbol() [*]const elf.Dyn { | ... | @@ -261,6 +263,25 @@ inline fn getDynamicSymbol() [*]const elf.Dyn { |
| 261 | : [ret] "=r" (-> [*]const elf.Dyn), | 263 | : [ret] "=r" (-> [*]const elf.Dyn), |
| 262 | : | 264 | : |
| 263 | : .{ .l7 = true }), | 265 | : .{ .l7 = true }), |
| | 266 | .xtensa, .xtensaeb => asm volatile ( |
| | 267 | \\ .weak _DYNAMIC |
| | 268 | \\ .hidden _DYNAMIC |
| | 269 | // Set things up such that after the `call0`, `a0` will point 1 byte before the |
| | 270 | // embedded constant. Note that `call0` is a 3-byte instruction, so we need both |
| | 271 | // `.balign` directives to be safe. |
| | 272 | \\ .balign 4 |
| | 273 | \\ .begin no-transform |
| | 274 | \\ call0 1f |
| | 275 | \\ .end no-transform |
| | 276 | \\ .balign 4 |
| | 277 | \\ .word _DYNAMIC - . |
| | 278 | \\1: |
| | 279 | \\ add a0, a0, 1 |
| | 280 | \\ l32i a8, a0, 0 |
| | 281 | \\ add %[ret], a0, a8 |
| | 282 | : [ret] "=a" (-> [*]const elf.Dyn), |
| | 283 | : |
| | 284 | : .{ .a0 = true, .a8 = true }), |
| 264 | else => { | 285 | else => { |
| 265 | @compileError("PIE startup is not yet supported for this target!"); | 286 | @compileError("PIE startup is not yet supported for this target!"); |
| 266 | }, | 287 | }, |